C4sp3R
Jan 08, 2020Nimbostratus
F5's monitor ansible module
Is there an elegant way to export/save the different types of monitors locally?
Because currently it seems you have to save the different types of monitors individually, e.g.:
- name: Saving HTTPS monitors
copy:
content: "{{ item | to_nice_yaml }}"
dest: ./f5/{{inventory_hostname}}/monitors/https_monitors/{{item.name}}.yml
loop: "{{results.https_monitors }}"
- name: Saving HTTP monitors
copy:
content: "{{ item | to_nice_yaml }}"
dest: ./f5/{{inventory_hostname}}/monitors/http_monitors/{{item.name}}.yml
loop: "{{results.http_monitors }}"
- name: Saving ICMP monitors
copy:
content: "{{ item | to_nice_yaml }}"
dest: ./f5/{{inventory_hostname}}/monitors/icmp_monitors/{{item.name}}.yml
loop: "{{results.icmp_monitors }}"
.
.
.
Apart from that a small sidenote (maybe i'm grasping the concept of ansible wrong), but wouldn't it be better to introduce a key with the type of monitor instead of creating a dictionary for every type, as the current approach makes automatic iterating hard if the types change for some reason.