Playbooks to a new Lilik
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.

198 lines
5.2 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. ---
  2. # ***** Icinga2 *****
  3. - name: 'PGSQL | preseed IDO debconf variables'
  4. # When icinga2-ido-pgsql is installed for the first time:
  5. # - db `icinga2` is automatically created as `postgres` user
  6. # - user `nagios` for socket authentication is created
  7. # - user `nagios` is granted privilegies on db `icinga2`
  8. # - db `icinga2` is populated with DB IDO schema
  9. # - pgsql is enabled as default DB IDO
  10. debconf:
  11. name: 'icinga2-ido-pgsql'
  12. question: 'icinga2-ido-pgsql/{{ item[0] }}'
  13. vtype: '{{ item[1] }}'
  14. value: '{{ item[2] }}'
  15. loop:
  16. - [ 'dbconfig-install', 'boolean', 'true' ]
  17. - [ 'enable', 'boolean', 'true' ]
  18. - [ 'pgsql/authmethod-user', 'string', 'ident' ]
  19. - [ 'pgsql/authmethod-admin', 'string', 'ident' ]
  20. - [ 'pgsql/method', 'string', 'Unix socket' ]
  21. - [ 'db/dbname', 'string', 'icinga2' ]
  22. - [ 'db/app-user', 'string', 'nagios' ]
  23. - [ 'dbconfig-reinstall', 'boolean', 'true' ]
  24. - name: 'create icinga2 service role'
  25. include_role: name='service'
  26. vars:
  27. service_name: 'icinga2'
  28. service_packages:
  29. - 'icinga2'
  30. - 'icingacli'
  31. - 'icinga2-ido-pgsql'
  32. - 'monitoring-plugins'
  33. - 'nagios-plugins-contrib'
  34. - name: 'create directory for hosts configuration'
  35. file:
  36. path: '/etc/icinga2/conf.d/hosts/'
  37. state: 'directory'
  38. owner: 'nagios'
  39. group: 'nagios'
  40. mode: '0770'
  41. - name: 'customize icinga2 host conf.d'
  42. copy:
  43. src: 'icinga2/{{ item }}'
  44. dest: '/etc/icinga2/conf.d/{{ item }}'
  45. notify: 'reload icinga2'
  46. loop:
  47. - 'templates.conf'
  48. - 'services.conf'
  49. - 'ssh_services.conf'
  50. # ***** IcingaWeb2 *****
  51. - name: 'PGSQL | IcingaWeb2 tunings'
  52. block:
  53. - name: 'PGSQL | create IcingaWeb2 user preference DB'
  54. postgresql_db:
  55. name: 'icingaweb2'
  56. register: icingaweb2_db
  57. - name: 'PGSQL | create IcingaWeb2 socket authentication user'
  58. postgresql_user:
  59. db: 'icingaweb2'
  60. name: 'www-data'
  61. priv: 'ALL'
  62. - name: 'PGSQL | GRANT CONNECT to IDO'
  63. postgresql_privs:
  64. db: 'icinga2'
  65. privs: 'CONNECT'
  66. type: 'database'
  67. role: 'www-data'
  68. - name: 'PGSQL | GRANT SCHEMA USAGE on IDO'
  69. postgresql_privs:
  70. db: 'icinga2'
  71. privs: 'USAGE'
  72. type: 'schema'
  73. objs: 'public'
  74. role: 'www-data'
  75. - name: 'PGSQL | GRANT SELECT on all IDO tables (existing)'
  76. postgresql_privs:
  77. db: 'icinga2'
  78. privs: 'SELECT'
  79. type: 'table'
  80. schema: 'public'
  81. objs: 'ALL_IN_SCHEMA'
  82. role: 'www-data'
  83. - name: 'PGSQL | GRANT SELECT on all IDO tables (default privilege)'
  84. postgresql_privs:
  85. db: 'icinga2'
  86. privs: 'SELECT'
  87. type: 'default_privs'
  88. schema: 'public'
  89. objs: 'TABLES'
  90. role: 'www-data'
  91. target_roles: 'nagios'
  92. become: true
  93. become_method: 'su'
  94. become_user: 'postgres'
  95. - name: 'install IcingaWeb2 packages'
  96. apt:
  97. pkg:
  98. - 'icingaweb2'
  99. - 'icingaweb2-module-monitoring'
  100. - 'php-ldap'
  101. - 'php-pgsql'
  102. - 'php-intl'
  103. - 'php-imagick'
  104. - 'php-fpm'
  105. - 'rsync'
  106. state: 'present'
  107. update_cache: true
  108. cache_valid_time: 3600
  109. tags:
  110. - 'packages'
  111. - name: 'PGSQL | populate IcingaWeb2 user preference DB'
  112. shell: 'cat /usr/share/icingaweb2/etc/schema/pgsql.schema.sql | psql -d icingaweb2'
  113. become: true
  114. become_method: 'su'
  115. become_flags: '-p'
  116. become_user: 'www-data'
  117. when: icingaweb2_db.changed
  118. - name: 'LDAP | upload client root ca'
  119. copy:
  120. content: '{{ ldap_tls_server_ca }}'
  121. dest: '/etc/ldap/server_ca.crt'
  122. tags:
  123. - 'tls_int'
  124. - name: 'LDAP | configure client'
  125. copy:
  126. src: 'ldap.conf'
  127. dest: '/etc/ldap/ldap.conf'
  128. when: ldap_tls_enabled
  129. - name: 'LDAP | generate client service password'
  130. gen_passwd: 'length=32'
  131. register: 'icingaweb2_ldap_passwd'
  132. no_log: true
  133. tags:
  134. - 'service_password'
  135. - name: 'LDAP | set client service password on server'
  136. delegate_to: 'localhost'
  137. ldap_passwd:
  138. dn: 'cn={{ host_fqdn }},ou=Server,{{ ldap_basedn }}'
  139. passwd: '{{ icingaweb2_ldap_passwd.passwd }}'
  140. server_uri: 'ldap://{{ ldap_server }}'
  141. start_tls: '{{ ldap_tls_enabled }}'
  142. bind_dn: '{{ ldap_admin_dn }}'
  143. bind_pw: '{{ ldap_admin_pw }}'
  144. no_log: true
  145. tags:
  146. - 'service_password'
  147. - name: 'configure IcingaWeb2 (static files)'
  148. synchronize:
  149. src: 'icingaweb2'
  150. dest: '/etc'
  151. rsync_opts:
  152. - "--chmod=Du+rwx,Dg+rwx,Do-rwx,Fu+rw,Fg+rw,Fo-rwx"
  153. - "--chown=root:icingaweb2"
  154. - name: 'create enabledModules folder'
  155. file:
  156. path: '/etc/icingaweb2/enabledModules/'
  157. state: 'directory'
  158. owner: 'root'
  159. group: 'icingaweb2'
  160. mode: '0770'
  161. - name: 'enable IcingaWeb2 monitoring plugin'
  162. file:
  163. src: '/usr/share/icingaweb2/modules/monitoring'
  164. dest: '/etc/icingaweb2/enabledModules/monitoring'
  165. state: 'link'
  166. - name: 'configure IcingaWeb2 (templates)'
  167. template:
  168. src: 'icingaweb2/{{ item }}.j2'
  169. dest: '/etc/icingaweb2/{{ item }}'
  170. owner: 'root'
  171. group: 'icingaweb2'
  172. mode: '0660'
  173. loop:
  174. - 'resources.ini'
  175. - 'authentication.ini'
  176. - 'groups.ini'
  177. - name: 'NGINX | configure IcingaWeb2 locations'
  178. template:
  179. src: 'icinga.conf'
  180. dest: "/etc/nginx/locations/{{ icingaweb2_nginx_fqdn }}/service.conf"
  181. notify:
  182. - 'reload nginx'