main.yml 609 B

12345678910111213141516171819202122
  1. ---
  2. - name: get hosts from Zones
  3. shell:
  4. sudo su - {{ siteuser }} -c "/omd/sites/{{ siteuser }}/bin/cmk -l {{ item }} | egrep -v '{{ zones_filter }}'"
  5. register: zones_output
  6. changed_when: false
  7. with_items:
  8. - "{{ zones }}"
  9. args:
  10. warn: false
  11. loop_control:
  12. label: "{{ item }}"
  13. - blockinfile:
  14. path: "/opt/semaphore/hosts/{{ item.item }}"
  15. block: |
  16. {{ item.stdout }}
  17. create: yes
  18. with_items: "{{ zones_output.results }}"
  19. delegate_to: localhost
  20. loop_control:
  21. label: "{{ item.stdout_lines }}"