Due to ansible/jinja2 templating, it is difficult to use the monitor message template variables as they need to be surrounded by `{{` and `}}`, this change addresses that issue by allowing the user to use `[[` and `]]` instead.
add exit_json code to succesfully exit, when you want to delete the already
deleted host.
Without this, playbook fails with
`Specify at least one group for creating host`
which is not correct message.
Some do not use the json module directly so don't need import json.
Some needed to fallback to simplejson with no traceback if neither was installed
Fixes#1298
Instead of waiting for up to a certain number of retries we set a high
timeout and only re-check every five seconds. Certain services can
take a minute or more to start and we want to avoid waisting resources
by polling too often.
@mpeters reported that we're not checking that the named service is
actually there after a reload. And that sometimes monit doesn't actually
return anything at all after a reload.
If there are already ongoing actions for a process managed by monit, the
module would exit unsuccessfully. It could also give off false positives
because it did not determine whether the service was started/stopped
when it was in a pending state. Which might be turning the service off,
but the action was to start it.
For example "Running - pending stop" would be regarded as the service
running and "state=enabled" would do nothing.
This will make Ansible wait for the state to finalize, or a timeout decided
by the new `max_retries` option, before it decides what to do.
This fixes issue #244.
I issued a command with action=disable_alerts host=webserver services=all set and get this results:
"nagios_commands": [
"[1438593631] DISABLE_SVC_NOTIFICATIONS;webserver;a",
"[1438593631] DISABLE_SVC_NOTIFICATIONS;webserver;l",
"[1438593631] DISABLE_SVC_NOTIFICATIONS;webserver;l"
]
This is not a big deal because i have just overlooked the action=silence command. Nevertheless a more predictable result would be a nice thing to have.