You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

59 lines
2.2 KiB

---
- include: client_debian.yml
when: ansible_distribution == 'Debian'
- include: client_centos.yml
when: ansible_distribution == 'CentOS' or ansible_distribution == 'CloudLinux' or ansible_distribution == 'Virtuozzo'
## Add the client to xymon server
- name: Ensure /etc/xymon/hosts.d exists
tags:
- xymon-client
- client-configuration
file: path=/etc/xymon/hosts.d state=directory
delegate_to: "{{ xymon_server }}"
- name: Ensure the monitoring section file is included
tags:
- xymon-client
- client-configuration
lineinfile: dest=/etc/xymon/hosts.cfg
insertafter='^page (?i){{monitoring_section}}'
line="include hosts.d/{{monitoring_file}}"
delegate_to: "{{ xymon_server }}"
when: monitoring_file is defined and monitoring_section is defined
- name: Ensure /etc/xymon/hosts.d/SECTION exists if used
tags:
- xymon-client
- client-configuration
lineinfile: dest="/etc/xymon/hosts.d/{{monitoring_file}}"
regexp="^group\s+{{monitoring_section}}$"
line="group {{monitoring_section}}"
state=present
create="yes"
mode="0644"
delegate_to: "{{ xymon_server }}"
when: monitoring_file is defined and monitoring_section is defined
- name: Add the host to the monitoring section file if used
tags:
- xymon-client
- client-configuration
lineinfile: dest="/etc/xymon/hosts.d/{{monitoring_file}}"
insertafter="^group {{monitoring_section}}"
regexp="^{{monitoring_ip}}\s+{{ansible_fqdn}} .*$"
line="{{monitoring_ip}} {{ansible_fqdn}} {{xymon_checks}}"
delegate_to: "{{ xymon_server }}"
when: monitoring_file is defined and monitoring_section is defined
- name: Add the host to the cfg file without section if needed
tags:
- xymon-client
- client-configuration
lineinfile: dest=/etc/xymon/hosts.cfg
insertafter='^group Servers'
regexp="^{{monitoring_ip}}\s+{{ansible_fqdn}} .*$"
line="{{monitoring_ip}} {{ansible_fqdn}} {{xymon_checks}}"
delegate_to: "{{ xymon_server }}"
when: monitoring_file is not defined and monitoring_section is not defined