meza
meza copied to clipboard
Allow specifying specific servers, not just groups, in custom crons
Currently we have the following, which allows specifying server_type
for custom crons.
{% if custom_crons is defined %}
#
# The following jobs are custom definitions from this meza-instance's config
#
{% for cron in custom_crons %}{% if inventory_hostname in groups[cron.server_type] %}
{{ cron.time }} {{ cron.job }}
{% endif %}{% endfor %}
This allows a configuration like:
custom_crons:
- server_type: app-servers
time: "* * * * *"
cron: echo "this is a test" >> /tmp/test.txt
It would probably better to specify servers
and allow it to be either a single server or a group or servers (or perhaps multiple servers, such that these are all possible:
servers: app-servers
...
servers: app-servers[0]
...
servers: [ 'app-servers', 'parsoid-servers' ]
...
servers: [ 'app-servers', parsoid-servers[0] ]
The above may not work to determine the difference between strings and lists, so maybe need to do:
servers: "{{ groups['app-servers'] }}"
...
servers: "{{ groups['app-servers'][0] }}"
...
servers: "{{ groups['app-servers'] + groups['parsoid-servers'] }}"
...
servers: "{{ groups['app-servers'] + [ groups['parsoid-servers'][0] ] }}"