update_config_file.yaml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ---
  2. - name: "Install Zabbix agent using yum/dnf/apt"
  3. hosts: all
  4. gather_facts: True
  5. become: true
  6. tasks:
  7. - name: "msg print to stdout: Debug ansible_facts"
  8. debug:
  9. msg:
  10. # - "{{ ansible_facts.service_mgr }}"
  11. - ansible_facts.distribution "{{ ansible_facts.distribution }}"
  12. - ansible_facts.distribution_major_version "{{ ansible_facts.distribution_major_version }}"
  13. - ansible_facts.distribution_file_variety "{{ ansible_facts.distribution_file_variety }}"
  14. - ansible_facts.nodename "{{ ansible_facts.nodename }}"
  15. - name: Populate systemd service_facts
  16. service_facts:
  17. - name: perform copy of zabbix agent config file (rewrites existing file)
  18. copy:
  19. src: include/zabbix_agent2.conf
  20. dest: /etc/zabbix/zabbix_agent2.conf
  21. owner: zabbix
  22. group: root
  23. mode: '0640'
  24. when: ansible_facts.nodename != "confluence.***CONTENTS REDACTED***"
  25. - name: Remove old log file
  26. file:
  27. path: /var/log/zabbix/zabbix_agentd.log
  28. state: absent
  29. # Restart systemd service
  30. - name: restart zabbix-agent.service, systemd
  31. systemd:
  32. name: zabbix-agent
  33. enabled: True
  34. masked: no
  35. state: restarted
  36. ignore_errors: true
  37. when:
  38. - ansible_facts.service_mgr == "systemd"
  39. - "'zabbix-agent.service' in services"
  40. - name: restart zabbix-agent2.service, systemd
  41. systemd:
  42. name: zabbix-agent2
  43. enabled: True
  44. masked: no
  45. state: restarted
  46. when:
  47. - ansible_facts.service_mgr == "systemd"
  48. - "'zabbix-agent2.service' in services"
  49. ignore_errors: true