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.

137 lines
4.8 KiB

  1. ---
  2. ## Install and configure xymon client ##
  3. # Binaries
  4. - name: install xymon client debian
  5. apt: pkg={{item}} state=present update_cache=yes
  6. tags:
  7. - client-packages
  8. - xymon-client
  9. with_items:
  10. - xymon-client
  11. - hobbit-plugins
  12. when: ansible_distribution == 'Debian'
  13. - name: Install xymon client CentOS
  14. tags:
  15. - xymon-client
  16. - client-packages
  17. yum: pkg=xymon-client state=installed
  18. when: ansible_distribution == 'CentOS' or ansible_distribution == 'CloudLinux'
  19. # Configuration
  20. - name: Configure Xymon ip on old Debian
  21. tags:
  22. - xymon-client
  23. - client-configuration
  24. lineinfile: name=/etc/default/hobbit-client regexp='^HOBBITSERVERS=' line='HOBBITSERVERS="{{xymon_server}}"'
  25. notify: restart hobbit-client
  26. when: ansible_distribution == 'Debian' and ansible_distribution_release != 'jessie'
  27. - name: Configure Xymon ip on Jessie
  28. tags:
  29. - xymon-client
  30. - client-configuration
  31. lineinfile: name=/etc/default/xymon-client regexp='^XYMONSERVERS=' line='XYMONSERVERS="{{xymon_server}}"'
  32. notify: restart xymon-client
  33. when: ansible_distribution == 'Debian' and ansible_distribution_release == 'jessie'
  34. - name: Configure Xymon ip on CentOS
  35. tags:
  36. - xymon-client
  37. - client-configuration
  38. lineinfile: name=/etc/sysconfig/xymon-client regexp='^XYMONSERVERS=' line='XYMONSERVERS="{{xymon_server}}"'
  39. notify: restart xymon-client
  40. when: ansible_distribution == 'CentOS' or ansible_distribution == 'CloudLinux'
  41. - name: Configure local Xymon name on old debian
  42. tags:
  43. - xymon-client
  44. - client-configuration
  45. lineinfile: name=/etc/default/hobbit-client regexp='^CLIENTHOSTNAME=' line='CLIENTHOSTNAME="{{ansible_fqdn}}"'
  46. notify: restart hobbit-client
  47. when: ansible_distribution == 'Debian' and ansible_distribution_release != 'jessie' # and ansible_distribution_version < '7'
  48. - name: Configure local Xymon name on Jessie
  49. tags:
  50. - xymon-client
  51. - client-configuration
  52. lineinfile: name=/etc/default/xymon-client regexp='^CLIENTHOSTNAME=' line='CLIENTHOSTNAME="{{ansible_fqdn}}"'
  53. notify: restart hobbit-client
  54. when: ansible_distribution == 'Debian' and ansible_distribution_release == 'jessie'
  55. - name: Configure local Xymon name on Centos
  56. tags:
  57. - xymon-client
  58. - client-configuration
  59. lineinfile: name=/etc/sysconfig/xymon-client regexp='^CLIENTHOSTNAME=' line='CLIENTHOSTNAME="{{ansible_fqdn}}"'
  60. notify: restart xymon-client
  61. when: ansible_distribution == 'CentOS' or ansible_distribution == 'CloudLinux'
  62. - name: Set xymon cron for APT
  63. tags:
  64. - xymon-client
  65. - client-configuration
  66. cron:
  67. name="check update for Xymon"
  68. minute="45"
  69. hour="*/4"
  70. 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"
  71. cron_file="xymon-apt"
  72. state=present
  73. user=root
  74. when: ansible_distribution == 'Debian'
  75. ## Add the client to xymon server
  76. - name: Ensure /etc/xymon/hosts.d exists
  77. tags:
  78. - xymon-client
  79. - client-configuration
  80. file: path=/etc/xymon/hosts.d state=directory
  81. delegate_to: "{{ xymon_server }}"
  82. - name: Ensure the monitoring section file is included
  83. tags:
  84. - xymon-client
  85. - client-configuration
  86. lineinfile: dest=/etc/xymon/hosts.cfg
  87. insertafter='^page (?i){{monitoring_section}}'
  88. line="include hosts.d/{{monitoring_file}}"
  89. delegate_to: "{{ xymon_server }}"
  90. when: monitoring_file is defined and monitoring_section is defined
  91. - name: Ensure /etc/xymon/hosts.d/SECTION exists if used
  92. tags:
  93. - xymon-client
  94. - client-configuration
  95. lineinfile: dest="/etc/xymon/hosts.d/{{monitoring_file}}"
  96. regexp="^group\s+{{monitoring_section}}$"
  97. line="group {{monitoring_section}}"
  98. state=present
  99. create="yes"
  100. mode="0644"
  101. delegate_to: "{{ xymon_server }}"
  102. when: monitoring_file is defined and monitoring_section is defined
  103. - name: Add the host to the monitoring section file if used
  104. tags:
  105. - xymon-client
  106. - client-configuration
  107. lineinfile: dest="/etc/xymon/hosts.d/{{monitoring_file}}"
  108. insertafter="^group {{monitoring_section}}"
  109. regexp="^{{monitoring_ip}}\s+{{ansible_fqdn}} .*$"
  110. line="{{monitoring_ip}} {{ansible_fqdn}} {{xymon_checks}}"
  111. delegate_to: "{{ xymon_server }}"
  112. when: monitoring_file is defined and monitoring_section is defined
  113. - name: Add the host to the cfg file without section if needed
  114. tags:
  115. - xymon-client
  116. - client-configuration
  117. lineinfile: dest=/etc/xymon/hosts.cfg
  118. insertafter='^group Servers'
  119. regexp="^{{monitoring_ip}}\s+{{ansible_fqdn}} .*$"
  120. line="{{monitoring_ip}} {{ansible_fqdn}} {{xymon_checks}}"
  121. delegate_to: "{{ xymon_server }}"
  122. when: monitoring_file is not defined and monitoring_section is not defined