@ -0,0 +1,16 @@ | |||
--- | |||
- name: restart xymon-hobbit-service | |||
service: name={{ client_name }}-client state=restarted | |||
- name: reload xymon-hobbit-service | |||
service: name={{ client_name }}-client state=reloaded | |||
- name: restart hobbit-client | |||
service: name=hobbit-client state=restarted | |||
- name: restart xymon-client | |||
service: name=xymon-client state=restarted | |||
- name: restart apache | |||
service: name=apache2 state=restarted |
@ -0,0 +1,137 @@ | |||
--- | |||
## Install and configure xymon client ## | |||
# Binaries | |||
- name: install xymon client debian | |||
apt: pkg={{item}} state=present update_cache=yes | |||
tags: | |||
- client-packages | |||
- xymon-client | |||
with_items: | |||
- xymon-client | |||
- hobbit-plugins | |||
when: ansible_distribution == 'Debian' | |||
- name: Install xymon client CentOS | |||
tags: | |||
- xymon-client | |||
- client-packages | |||
yum: pkg=xymon-client state=installed | |||
when: ansible_distribution == 'CentOS' or ansible_distribution == 'CloudLinux' | |||
# Configuration | |||
- name: Configure Xymon ip on old Debian | |||
tags: | |||
- xymon-client | |||
- client-configuration | |||
lineinfile: name=/etc/default/hobbit-client regexp='^HOBBITSERVERS=' line='HOBBITSERVERS="{{xymon_server}}"' | |||
notify: restart hobbit-client | |||
when: ansible_distribution == 'Debian' and ansible_distribution_release != 'jessie' | |||
- name: Configure Xymon ip on Jessie | |||
tags: | |||
- xymon-client | |||
- client-configuration | |||
lineinfile: name=/etc/default/xymon-client regexp='^XYMONSERVERS=' line='XYMONSERVERS="{{xymon_server}}"' | |||
notify: restart xymon-client | |||
when: ansible_distribution == 'Debian' and ansible_distribution_release == 'jessie' | |||
- name: Configure Xymon ip on CentOS | |||
tags: | |||
- xymon-client | |||
- client-configuration | |||
lineinfile: name=/etc/sysconfig/xymon-client regexp='^XYMONSERVERS=' line='XYMONSERVERS="{{xymon_server}}"' | |||
notify: restart xymon-client | |||
when: ansible_distribution == 'CentOS' or ansible_distribution == 'CloudLinux' | |||
- name: Configure local Xymon name on old debian | |||
tags: | |||
- xymon-client | |||
- client-configuration | |||
lineinfile: name=/etc/default/hobbit-client regexp='^CLIENTHOSTNAME=' line='CLIENTHOSTNAME="{{ansible_fqdn}}"' | |||
notify: restart hobbit-client | |||
when: ansible_distribution == 'Debian' and ansible_distribution_release != 'jessie' # and ansible_distribution_version < '7' | |||
- name: Configure local Xymon name on Jessie | |||
tags: | |||
- xymon-client | |||
- client-configuration | |||
lineinfile: name=/etc/default/xymon-client regexp='^CLIENTHOSTNAME=' line='CLIENTHOSTNAME="{{ansible_fqdn}}"' | |||
notify: restart hobbit-client | |||
when: ansible_distribution == 'Debian' and ansible_distribution_release == 'jessie' | |||
- name: Configure local Xymon name on Centos | |||
tags: | |||
- xymon-client | |||
- client-configuration | |||
lineinfile: name=/etc/sysconfig/xymon-client regexp='^CLIENTHOSTNAME=' line='CLIENTHOSTNAME="{{ansible_fqdn}}"' | |||
notify: restart xymon-client | |||
when: ansible_distribution == 'CentOS' or ansible_distribution == 'CloudLinux' | |||
- name: Set xymon cron for APT | |||
tags: | |||
- xymon-client | |||
- client-configuration | |||
cron: | |||
name="check update for Xymon" | |||
minute="45" | |||
hour="*/4" | |||
job="apt-get update -qq > /var/lib/apt/update_output 2>&1 && [ ! -s /var/lib/apt/update_output ] && date -u > /var/lib/apt/update_success" | |||
cron_file="xymon-apt" | |||
state=present | |||
user=root | |||
when: ansible_distribution == 'Debian' | |||
## 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 |
@ -0,0 +1,86 @@ | |||
--- | |||
## | |||
## | |||
## Role to install xymon client or xymon server on host depending what is needed | |||
## | |||
## Tags : | |||
## - xymon-server : binaries and configuration server side | |||
## - xymon-client : binaries and configuration client side (need a working server) | |||
## - client-configuration : used to configure client only (no binaries) | |||
## - client-packages : used only install client binaries (no configuration) | |||
## - server-configuration : used to configure server only (no binaries) | |||
## - server-packages : used to only install server binaries (no configuration) | |||
######## | |||
##Check vars | |||
- name: check xymon_server | |||
fail: msg="Missing variable xymon_server" | |||
tags: | |||
- xymon-client | |||
- xymon-server | |||
when: xymon_server is not defined | |||
- name: check xymon_checks | |||
fail: msg="Missing variable xymon_checks" | |||
tags: | |||
- xymon-client | |||
- client-configuration | |||
when: xymon_checks is not defined | |||
- name: check monitoring_ip | |||
fail: msg="Missing variable monitoring_ip" | |||
tags: | |||
- xymon-client | |||
- client-configuration | |||
when: monitoring_ip is not defined | |||
- name: check server htpasswd name | |||
fail: msg="Missing variable xymon_htname" | |||
tags: | |||
- xymon-server | |||
- server-configuration | |||
when: xymon_htname is not defined | |||
- name: check server htpasswd password | |||
fail: msg="Missing variable xymon_htpasswd" | |||
tags: | |||
- xymon-server | |||
- server-configuration | |||
when: xymon_htpasswd is not defined | |||
## Custom Facts | |||
- name: Set Facts Debian | |||
set_fact: | |||
xymon_cfg_path: "/usr/lib/hobbit/client/etc/clientlaunch.d" | |||
xymon_ext_path: "/usr/lib/hobbit/client/ext" | |||
xymon_binary: "/usr/lib/hobbit/client/bin/bb" | |||
client_name: "hobbit" | |||
client_name_cfg: "$HOBBITCLIENTHOME" | |||
client_name_logs: "$BBCLIENTLOGS" | |||
tags: | |||
- xymon-client | |||
- xymon-server | |||
- configuration | |||
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' | |||
- name: Set Facts CentOs | |||
set_fact: | |||
xymon_cfg_path: "/etc/xymon-client/client.d" | |||
xymon_ext_path: "/etc/xymon-client/ext" | |||
xymon_binary: "/usr/share/xymon-client/bin/xymon" | |||
client_name: "xymon" | |||
client_name_cfg: "$XYMONCLIENTHOME" | |||
client_name_logs: "$XYMONCLIENTLOGS" | |||
tags: | |||
- xymon-client | |||
- xymon-server | |||
- configuration | |||
when: ansible_distribution == 'CentOS' or ansible_distribution == 'CloudLinux' | |||
##Main tasks | |||
- include: server.yml | |||
- include: client.yml | |||
@ -0,0 +1,189 @@ | |||
--- | |||
## Installation and configuration for Xymon server ## | |||
# Binaries | |||
- name: install xymon server binaries - download | |||
get_url: url=http://sourceforge.net/projects/xymon/files/latest/download?source=directory dest=/tmp/xymon_server.tar.gz | |||
tags: | |||
- xymon-server | |||
- server-packages | |||
- name: install xymon server binaries - untar | |||
unarchive: src=/tmp/xymon_server.tar.gz dest=/tmp/ copy=no | |||
tags: | |||
- xymon-server | |||
- server-packages | |||
- name: install xymon server binaries - register release | |||
shell: ls -d /tmp/xymon-* | awk -F'-' '{print $2}' | |||
register: xymon_release | |||
tags: | |||
- xymon-server | |||
- server-packages | |||
- name: install xymon server binaries - display release | |||
fail: msg="Using xymon server version {{ xymon_release.stdout }}." | |||
ignore_errors: yes | |||
tags: | |||
- xymon-server | |||
- server-packages | |||
- name: install xymon server binaries - display warning | |||
fail: msg="Now building packages. WARN! It may take some time." | |||
ignore_errors: yes | |||
tags: | |||
- xymon-server | |||
- server-packages | |||
## Debian | |||
- name: Debian, install xymon server dependencies | |||
apt: pkg={{item}} state=present update_cache=yes | |||
tags: | |||
- server-packages | |||
- server-configuration | |||
- xymon-server | |||
with_items: | |||
- apache2 | |||
- rrdtool | |||
- librrd-dev | |||
- libpcre3-dev | |||
- libssl-dev | |||
- ldap-utils | |||
- libldap2-dev | |||
- fping | |||
- libc-ares-dev | |||
- python-passlib | |||
when: ansible_distribution == 'Debian' | |||
- name: Debian, install xymon server binaries - make deb | |||
shell: ./build/makedeb.sh {{ xymon_release.stdout }} | |||
args: | |||
executable: /bin/bash | |||
chdir: /tmp/xymon-{{ xymon_release.stdout }}/ | |||
tags: | |||
- xymon-server | |||
- server-packages | |||
when: ansible_distribution == 'Debian' | |||
- name: Debian, install xymon server binaries - create pid directory | |||
file: | |||
path=/var/run/xymon | |||
state=directory mode=0755 | |||
owner=xymon | |||
group=xymon | |||
tags: | |||
- xymon-server | |||
- server-packages | |||
- name: Debian, install xymon server binaries - install deb server | |||
apt: deb=/tmp/xymon-{{ xymon_release.stdout }}/debbuild/xymon_{{ xymon_release.stdout }}_amd64.deb | |||
tags: | |||
- xymon-server | |||
- server-packages | |||
when: ansible_distribution == 'Debian' | |||
notify: restart apache | |||
- name: Debian, install xymon server binaries - install deb client | |||
apt: deb=/tmp/xymon-{{ xymon_release.stdout }}/debbuild/xymon-client_{{ xymon_release.stdout }}_amd64.deb | |||
tags: | |||
- xymon-server | |||
- server-packages | |||
when: ansible_distribution == 'Debian' | |||
## Centos NOT READY YET | |||
#- name: Centos, add xymon group | |||
#group: | |||
#name=xymon | |||
#state=present | |||
#tags: | |||
#- xymon-server | |||
#- server-packages | |||
#when: ansible_distribution == 'CentOS' or ansible_distribution == 'CloudLinux' | |||
#- name: Centos, add xymon user | |||
#user: | |||
#name=xymon | |||
#group=xymon | |||
#createhome=yes | |||
#tags: | |||
#- xymon-server | |||
#- server-packages | |||
#when: ansible_distribution == 'CentOS' or ansible_distribution == 'CloudLinux' | |||
#- name: Centos, install xymon server dependencies | |||
#yum: pkg={{item}} state=installed | |||
#with_items: | |||
#- gcc | |||
#- make | |||
#- fping | |||
#- pcre-devel | |||
#- openssl-devel | |||
#- openldap-devel | |||
#- rrdtool-devel | |||
#tags: | |||
#- xymon-server | |||
#- server-packages | |||
#when: ansible_distribution == 'CentOS' or ansible_distribution == 'CloudLinux' | |||
#- name: Centos, install xymon server binaries - configure | |||
#shell: ./configure --server | |||
#args: | |||
#executable: /bin/bash | |||
#chdir: /tmp/xymon-{{ xymon_release.stdout }}/ | |||
#tags: | |||
#- xymon-server | |||
#- server-packages | |||
#when: ansible_distribution == 'CentOS' or ansible_distribution == 'CloudLinux' | |||
#- name: Centos, install xymon server binaries - make & make install | |||
#shell: make && make install | |||
#args: | |||
#executable: /bin/bash | |||
#chdir: /tmp/xymon-{{ xymon_release.stdout }}/ | |||
#tags: | |||
#- xymon-server | |||
#- server-packages | |||
#when: ansible_distribution == 'CentOS' or ansible_distribution == 'CloudLinux' | |||
#- name: Centos, install xymon server binaries - init file | |||
#shell: mv /tmp/xymon-{{ xymon_release.stdout }}/rpm/xymon-init.d /etc/init.d/xymon | |||
#args: | |||
#executable: /bin/bash | |||
#tags: | |||
#- xymon-server | |||
#- server-packages | |||
#when: ansible_distribution == 'CentOS' or ansible_distribution == 'CloudLinux' | |||
## Xymon server configuration | |||
- name: enable global group Server in conf | |||
lineinfile: dest=/etc/xymon/hosts.cfg | |||
regexp="^#group Servers$" | |||
line="group Servers" | |||
backrefs=yes | |||
tags: | |||
- xymon-server | |||
- server-configuration | |||
## Apache for xymon server | |||
- name: generate htpasswd file for xymon-server | |||
htpasswd: | |||
path="/usr/local/xymon/server/etc/xymonpasswd" | |||
name={{xymon_htname}} | |||
password={{xymon_htpasswd}} | |||
create=yes | |||
state=present | |||
tags: | |||
- xymon-server | |||
- server-configuration | |||
when: ansible_distribution == 'Debian' | |||
- name: Apache configuration done | |||
fail: msg="You can now connect to http://yourserver/xymon/" | |||
ignore_errors: yes | |||
tags: | |||
- xymon-server | |||
- server-configuration |
@ -0,0 +1,8 @@ | |||
--- | |||
- name: Install and configure xymon-client or xymon-server | |||
hosts: all | |||
user: root | |||
gather_facts: yes | |||
roles: | |||
- xymon |