| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- ---
- - name: "Install Zabbix agent using yum/dnf/apt"
- hosts: all
- gather_facts: True
- become: true
- tasks:
- - name: "msg print to stdout: Debug ansible_facts"
- debug:
- msg:
- # - "{{ ansible_facts.service_mgr }}"
- - ansible_facts.distribution "{{ ansible_facts.distribution }}"
- - ansible_facts.distribution_major_version "{{ ansible_facts.distribution_major_version }}"
- - ansible_facts.distribution_file_variety "{{ ansible_facts.distribution_file_variety }}"
- - ansible_facts.nodename "{{ ansible_facts.nodename }}"
- - name: Populate systemd service_facts
- service_facts:
- - name: perform copy of zabbix agent config file (rewrites existing file)
- copy:
- src: include/zabbix_agent2.conf
- dest: /etc/zabbix/zabbix_agent2.conf
- owner: zabbix
- group: root
- mode: '0640'
- when: ansible_facts.nodename != "confluence.***CONTENTS REDACTED***"
- - name: Remove old log file
- file:
- path: /var/log/zabbix/zabbix_agentd.log
- state: absent
- # Restart systemd service
- - name: restart zabbix-agent.service, systemd
- systemd:
- name: zabbix-agent
- enabled: True
- masked: no
- state: restarted
- ignore_errors: true
- when:
- - ansible_facts.service_mgr == "systemd"
- - "'zabbix-agent.service' in services"
- - name: restart zabbix-agent2.service, systemd
- systemd:
- name: zabbix-agent2
- enabled: True
- masked: no
- state: restarted
- when:
- - ansible_facts.service_mgr == "systemd"
- - "'zabbix-agent2.service' in services"
- ignore_errors: true
|