blob: 7d8142763ad9bcb137a81c107853e2bad4bdfa36 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
---
- name: Prepare
hosts: localhost
connection: local
pre_tasks:
- name: "Create MySQL Container"
docker_container:
name: "{{ item.name }}-db"
image: mysql:8.0
state: started
recreate: true
networks:
- name: zabbix
env:
MYSQL_ROOT_PASSWORD: changeme
no_log: true
with_items: "{{ molecule_yml.platforms }}"
when:
- '"mysql" in item.groups'
- name: "Create postgresql Container"
docker_container:
name: "{{ item.name }}-db"
image: postgres:13
state: started
recreate: true
networks:
- name: zabbix
env:
POSTGRES_PASSWORD: changeme
no_log: true
with_items: "{{ molecule_yml.platforms }}"
when:
- '"pgsql" in item.groups'
- name: Prepare
hosts: all
pre_tasks:
- name: "Create group for imaginary host"
add_host:
name: imaginary-host
groups:
- mysql
- postgresql
changed_when: false
- name: "Installing packages on CentOS"
ansible.builtin.yum:
name:
- net-tools
- which
- sudo
state: present
register: installation_dependencies
until: installation_dependencies is succeeded
when:
- ansible_os_family == 'RedHat'
- name: "Installing packages (CentOS7)"
ansible.builtin.yum:
name:
- centos-release-scl
state: present
register: installation_dependencies
when:
- ansible_os_family == 'RedHat'
- ansible_distribution_major_version == '7'
- name: "Installing MySQL on CentOS"
ansible.builtin.yum:
name:
- mysql
state: present
register: installation_dependencies
until: installation_dependencies is succeeded
when:
- ansible_os_family == 'RedHat'
- inventory_hostname in groups['mysql']
- name: Check if warn parameter can be used for shell module
ansible.builtin.set_fact:
produce_warn: false
when: ansible_version.full is version("2.14", "<")
- name: "Apt update"
ansible.builtin.shell: "apt-get update"
args:
warn: "{{ produce_warn | default(omit) }}"
register: installation_dependencies
until: installation_dependencies is succeeded
when:
- ansible_os_family != 'RedHat'
- name: "Installing packages on NON-CentOS"
ansible.builtin.apt:
name:
- net-tools
- apt-utils
- python3-pip
- gpg-agent
- sudo
- curl
update_cache: true
state: present
register: installation_dependencies
until: installation_dependencies is succeeded
when:
- ansible_os_family != 'RedHat'
- name: "Configure SUDO."
ansible.builtin.lineinfile:
dest: /etc/sudoers
line: "Defaults !requiretty"
state: present
- name: "Make sure the docs are installed."
ansible.builtin.lineinfile:
dest: /etc/yum.conf
line: "tsflags=nodocs"
state: absent
when:
- ansible_os_family == 'RedHat'
- name: PyMySQL
ansible.builtin.pip:
name: PyMySQL
register: installation_dependencies
until: installation_dependencies is succeeded
when:
- inventory_hostname in groups['mysql']
- name: Enabeling PHP 7.4
ansible.builtin.command: dnf module enable php:7.4 -y
when:
- ansible_os_family == 'RedHat'
- ansible_distribution_major_version == "8"
- name: Set PHP packages (Centos 8+)
ansible.builtin.set_fact:
php_packages:
- php
- php-cli
- php-common
- php-devel
- php-fpm
- php-gd
- php-ldap
- php-mbstring
- php-opcache
- php-pdo
- php-pear
- php-pecl-apcu
- php-xml
when:
- ansible_distribution_major_version >= '8'
- ansible_os_family == "RedHat"
- name: Set PHP Version (Ubuntu 2204)
ansible.builtin.set_fact:
__php_default_version_debian: "8.1"
when:
- ansible_distribution_major_version >= '22'
- ansible_os_family == "Debian"
- name: Set PHP Version (Ubuntu 2404)
ansible.builtin.set_fact:
__php_default_version_debian: "8.3"
when:
- ansible_distribution_major_version >= '24'
- ansible_os_family == "Debian"
- name: Set PHP packages (Ubuntu 2204 & 2404)
ansible.builtin.set_fact:
__php_packages:
- php{{ __php_default_version_debian }}-common
- php{{ __php_default_version_debian }}-cli
- php{{ __php_default_version_debian }}-dev
- php{{ __php_default_version_debian }}-fpm
- libpcre3-dev
- php{{ __php_default_version_debian }}-gd
- php{{ __php_default_version_debian }}-curl
- php{{ __php_default_version_debian }}-imap
- php-json
- php{{ __php_default_version_debian }}-opcache
- php{{ __php_default_version_debian }}-xml
- php{{ __php_default_version_debian }}-mbstring
- php{{ __php_default_version_debian }}-apcu
- php{{ __php_default_version_debian }}-sqlite3
when:
- ansible_distribution_major_version >= '22'
- ansible_os_family == "Debian"
roles:
- role: geerlingguy.apache
when:
- zabbix_web_http_server == "apache"
- role: geerlingguy.nginx
when:
- zabbix_web_http_server == "nginx"
- role: geerlingguy.php
- role: zabbix_server
post_tasks:
- name: "Remove file"
ansible.builtin.file:
path: "{{ item }}"
state: absent
with_items:
- /var/www/html/index.html
|