Skip to content
This repository has been archived by the owner on Jul 4, 2018. It is now read-only.

moira-alert/ansible-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

THIS REPOSITORY MAY BE REMOVED WITHOUT FURTHER NOTICE AFTER 31 AUG 2018

THIS REPOSITORY IS NO LONGER MAINTAINED

ansible-module

Ansible module to create, update and delete Moira triggers based on python-moira-client

User Guide

Installation

Module parameters

Playbook tasks

First run

Installation

Python Moira client

Make sure you have python-moira-client installed:

pip install moira-client

Moira Trigger module

Clone ansible-module project inside your Ansible library directory specified in ansible.cfg file:

cd /path/to/library
git clone https://github.com/moira-alert/ansible-module moira_trigger

Module parameters

Required parameters

The parameters listed below are required to be specified for every task:

Parameter Description Type Required Choices
api_url Url of Moira API String True
state Desired state of a trigger String True present
absent
name Trigger name String True
targets List of trigger targets List True

Any others can be used with their default values.

Note: Both static and dynamic parameters can be specified for every trigger.
See the difference between these two groups here.

Static parameters

Parameter Description Type Required Choices Default Example
api_url Url of Moira API String True http://localhost/api/
login Auth Login (for 'X-Webauth-User' header) String False None admin
auth_user Auth User (Basic Auth) String False None admin
auth_pass Auth Password (Basic Auth) String False None pass
state Desired state of a trigger String True present
absent
present
name Trigger name String True test1
ttl Time to Live (in seconds) String False '600' '600'
ttl_state Trigger state at the expiration of 'ttl' String False NODATA
ERROR
WARN
OK
NODATA WARN
targets List of trigger targets List True - test1.rps
- test2.rps
warn_value Value to set WARN status Int False None 300
error_value Value to set ERROR status Int False None 600

Dynamic parameters

Parameter Description Type Required Default Example
desc Trigger description String False Empty String trigger test description
expression Python expression String False Empty String ERROR if t1 > 10 else WARN if t1 > 1 else OK
disabled_days Days for trigger to be in silent mode Set False {} ? Mon
? Wed
tags List of trigger tags List False [] - first_tag
- second_tag

Playbook tasks

Creating new triggers

Use state 'present' to create and edit existing triggers:

 - name: MoiraAnsible
   moira_trigger:
      ...
      state: present
      ...  

Note: See required parameters section and playbook example for more information.

Changing existing triggers

To remove any of the dynamic parameters from the existing trigger you can simply remove the related key
from your playbook.

The table below shows which value be assigned to a parameter if the related key isn't specified within a playbook.

Parameter Value to be assigned
Static Last used value
Dynamic Default value

Note: Since its name required to find existing trigger do not use state 'present' to change triggers names. It's important to avoid multiple trigger creation with same parameters but different names. Triggers can be renamed by re-creation.

Deleting triggers

To delete existing triggers use state 'absent':

 - name: MoiraAnsible
   moira_trigger:
      ...
      state: absent
      ...  

First run

Check mode

To see how module works without making any changes execute ansible-playbook with the following flags:

ansible-playbook -vvvv moira_triggers.yml --check

Playbook example

   - name: MoiraAnsible
     moira_trigger:
        api_url: http://localhost/api/
        state: present
        name: '{{ item.name }}'
        desc: trigger test description
        warn_value: 300
        error_value: 600
        ttl_state: ERROR
        tags:
          - first_tag
          - second_tag
        targets: '{{ item.targets }}'
        disabled_days:
          ? Mon
          ? Wed
     with_items:
       - name: test1
         targets:
           - test1.rps
           - test2.rps
       - name: test2
         targets:
           - test3.rps
           - test4.rps

Releases

No releases published

Packages

No packages published

Languages