|
23 | 23 | tags: |
24 | 24 | - molecule-idempotence-notest |
25 | 25 |
|
| 26 | + - name: install icinga2 basic packages |
| 27 | + apt: |
| 28 | + name: gnupg |
| 29 | + state: present |
| 30 | + update_cache: true |
| 31 | + when: ansible_os_family == 'Debian' |
| 32 | + tags: |
| 33 | + - molecule-idempotence-notest |
| 34 | + |
| 35 | + - name: add icinga2 repo key |
| 36 | + apt_key: |
| 37 | + url: "http://packages.icinga.com/icinga.key" |
| 38 | + state: present |
| 39 | + when: ansible_os_family == 'Debian' |
| 40 | + tags: |
| 41 | + - molecule-idempotence-notest |
| 42 | + |
| 43 | + - name: add icinga2 repository |
| 44 | + apt_repository: |
| 45 | + repo: "{{ item }}" |
| 46 | + state: present |
| 47 | + update_cache: true |
| 48 | + with_items: |
| 49 | + - deb http://packages.icinga.com/debian icinga-bullseye main |
| 50 | + - deb-src http://packages.icinga.com/debian icinga-bullseye main |
| 51 | + when: ansible_os_family == 'Debian' |
| 52 | + tags: |
| 53 | + - molecule-idempotence-notest |
| 54 | + |
| 55 | + - name: install icinga2 build dependencies |
| 56 | + apt: |
| 57 | + pkg: "icinga2" |
| 58 | + state: "build-dep" |
| 59 | + update_cache: true |
| 60 | + when: ansible_os_family == 'Debian' |
| 61 | + tags: |
| 62 | + - molecule-idempotence-notest |
| 63 | + |
| 64 | + - name: install icinga2 basic packages |
| 65 | + apt: |
| 66 | + name: "icinga2" |
| 67 | + state: "present" |
| 68 | + update_cache: true |
| 69 | + when: ansible_os_family == 'Debian' |
| 70 | + tags: |
| 71 | + - molecule-idempotence-notest |
| 72 | + |
26 | 73 | collections: |
27 | 74 | - t_systems_mms.ansible_collection_icinga |
28 | 75 |
|
|
51 | 98 | state: file |
52 | 99 | register: result_icinga2_conf |
53 | 100 |
|
54 | | - - name: validate icinga2.conf results |
| 101 | + - name: validate icinga2.conf results for RedHat based Distributions |
55 | 102 | assert: |
56 | 103 | that: |
57 | 104 | - "result_icinga2_conf.state == 'file'" |
58 | 105 | - "result_icinga2_conf.mode == '0640'" |
59 | 106 | - "result_icinga2_conf.owner == 'icinga'" |
60 | 107 | - "result_icinga2_conf.group == 'icinga'" |
| 108 | + when: ansible_os_family == 'RedHat' |
| 109 | + |
| 110 | + - name: validate icinga2.conf results for Debian based Distributions |
| 111 | + assert: |
| 112 | + that: |
| 113 | + - "result_icinga2_conf.state == 'file'" |
| 114 | + - "result_icinga2_conf.mode == '0640'" |
| 115 | + - "result_icinga2_conf.owner == 'nagios'" |
| 116 | + - "result_icinga2_conf.group == 'nagios'" |
| 117 | + when: ansible_os_family == 'Debian' |
61 | 118 |
|
62 | 119 | - name: verify that constants.conf exists |
63 | 120 | file: |
64 | 121 | path: /etc/icinga2/constants.conf |
65 | 122 | state: file |
66 | 123 | register: result_constants_conf |
67 | 124 |
|
68 | | - - name: validate constants.conf results |
| 125 | + - name: validate constants.conf results for RedHat based Distributions |
69 | 126 | assert: |
70 | 127 | that: |
71 | 128 | - "result_constants_conf.state == 'file'" |
72 | 129 | - "result_constants_conf.mode == '0640'" |
73 | 130 | - "result_constants_conf.owner == 'icinga'" |
74 | 131 | - "result_constants_conf.group == 'icinga'" |
| 132 | + when: ansible_os_family == 'RedHat' |
| 133 | + |
| 134 | + - name: validate constants.conf results for Debian based Distributions |
| 135 | + assert: |
| 136 | + that: |
| 137 | + - "result_constants_conf.state == 'file'" |
| 138 | + - "result_constants_conf.mode == '0640'" |
| 139 | + - "result_constants_conf.owner == 'nagios'" |
| 140 | + - "result_constants_conf.group == 'nagios'" |
| 141 | + when: ansible_os_family == 'Debian' |
75 | 142 |
|
76 | 143 | - name: verify that zones.conf exists |
77 | 144 | file: |
78 | 145 | path: /etc/icinga2/zones.conf |
79 | 146 | state: file |
80 | 147 | register: result_zones_conf |
81 | 148 |
|
82 | | - - name: validate zones.conf results |
| 149 | + - name: validate zones.conf results for RedHat based Distributions |
83 | 150 | assert: |
84 | 151 | that: |
85 | 152 | - "result_zones_conf.state == 'file'" |
86 | 153 | - "result_zones_conf.mode == '0640'" |
87 | 154 | - "result_zones_conf.owner == 'icinga'" |
88 | 155 | - "result_zones_conf.group == 'icinga'" |
| 156 | + when: ansible_os_family == 'RedHat' |
| 157 | + |
| 158 | + - name: validate zones.conf results for Debian based Distributions |
| 159 | + assert: |
| 160 | + that: |
| 161 | + - "result_zones_conf.state == 'file'" |
| 162 | + - "result_zones_conf.mode == '0640'" |
| 163 | + - "result_zones_conf.owner == 'nagios'" |
| 164 | + - "result_zones_conf.group == 'nagios'" |
| 165 | + when: ansible_os_family == 'Debian' |
89 | 166 |
|
90 | 167 | - name: verify that api.conf exists |
91 | 168 | file: |
92 | 169 | path: /etc/icinga2/features-available/api.conf |
93 | 170 | state: file |
94 | 171 | register: result_api_conf |
95 | 172 |
|
96 | | - - name: validate api.conf results |
| 173 | + - name: validate api.conf results for RedHat based Distributions |
97 | 174 | assert: |
98 | 175 | that: |
99 | 176 | - "result_api_conf.state == 'file'" |
100 | 177 | - "result_api_conf.mode == '0640'" |
101 | 178 | - "result_api_conf.owner == 'icinga'" |
102 | 179 | - "result_api_conf.group == 'icinga'" |
| 180 | + when: ansible_os_family == 'RedHat' |
| 181 | + |
| 182 | + - name: validate api.conf results for Debian based Distributions |
| 183 | + assert: |
| 184 | + that: |
| 185 | + - "result_api_conf.state == 'file'" |
| 186 | + - "result_api_conf.mode == '0640'" |
| 187 | + - "result_api_conf.owner == 'nagios'" |
| 188 | + - "result_api_conf.group == 'nagios'" |
| 189 | + when: ansible_os_family == 'Debian' |
| 190 | + |
| 191 | + # - name: verify that icinga2 package is installed |
| 192 | + # yum: |
| 193 | + # name: icinga2 |
| 194 | + # state: present |
| 195 | + # when: ansible_os_family == 'RedHat' |
| 196 | + |
| 197 | + # - name: verify that icinga2 package is installed for Debian based systems |
| 198 | + # apt: |
| 199 | + # name: icinga2 |
| 200 | + # state: present |
| 201 | + # when: ansible_os_family == 'Debian' |
103 | 202 |
|
104 | 203 | - name: verify that icinga2 package is installed |
105 | | - yum: |
| 204 | + ansible.builtin.package: |
106 | 205 | name: icinga2 |
107 | 206 | state: present |
108 | | - when: ansible_os_family == 'RedHat' |
|
0 commit comments