1 - name: Install required packages
10 - "php{{ php_version }}-xml"
21 - "php{{ php_version }}-pgsql"
30 - python3-psycopg2 #module ansible psql
33 - name: Boucle d'ajout du user php dans plusieurs groupe
35 name: "php_{{ SIGLE }}_{{ SITE }}"
42 - "site_{{ SIGLE }}_{{ SITE }}"
44 - name: Bloc nextcloud_version
45 when: nouvelle_version is undefined
47 - name: Demande la version de nextcloud à installer
48 ansible.builtin.pause:
49 prompt: "Quelle version de nextcloud doit être utilisée"
51 register: nextcloud_version_prompt
53 - name: Definir nouvelle_version
54 ansible.builtin.set_fact:
55 nouvelle_version: "{{ nextcloud_version_prompt.user_input }}"
57 - name: Demande la version de nextcloud déjà installée
58 ansible.builtin.pause:
59 prompt: "Quelle version de nextcloud déjà installée"
61 register: ancienne_version_prompt
63 - name: Definir ancienne_version
64 ansible.builtin.set_fact:
65 ancienne_version: "{{ ancienne_version_prompt.user_input }}"
67 - name: Inclure la verif de l'install nextcloud
68 ansible.builtin.include_tasks: tasks/verif_installation_nextcloud.yml
70 - name: "[PostgreSQL] - {{ nextcloud_php_user }} role is created."
73 community.postgresql.postgresql_user:
74 name: "{{ nextcloud_php_user }}"
76 role_attr_flags: CREATEDB
78 - name: "[PostgreSQL] - {{ nextcloud_db_name }} database is created."
81 community.postgresql.postgresql_db:
82 name: "{{ nextcloud_db_name }}"
84 owner: "{{ nextcloud_php_user }}"
89 - name: Pour chaque base, ajouter les droits suivants à l'utilisateur php
92 community.postgresql.postgresql_privs:
94 privs: "{{ item.privs }}"
95 type: "{{ item.type |default(omit)}}"
96 objs: "{{ item.objs }}"
97 role: "{{ item.role }}"
98 grant_option: "{{ item.grant_option |default(omit) }}"
100 label: "{{ item.name }}"
102 - db: "{{ nextcloud_db_name }}"
106 role: "{{ nextcloud_php_user }}"
108 name: "GRANT ALL ON SCHEMA public TO php_{{ SIGLE }}_nuage WITH GRANT OPTION;"
110 - name: Autoriser l'utilisateur php à se connecter à la bdd nextcloud
111 community.postgresql.postgresql_pg_hba:
112 dest: "/etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"
114 users: "php_{{ SIGLE}}_{{SITE}}"
115 databases: "php_{{ SIGLE}}_{{SITE}}"
117 keep_comments_at_rules: true
118 comment: "autoriser le user php_{{ SIGLE}}_{{SITE}} à se connecter à la bdd du meme nom"
120 - name: Boucle création des répertoires app, config et data nextcloud
121 ansible.builtin.file:
122 path: "{{ item.path }}"
123 state: "{{ item.state }}"
124 owner: "{{ item.owner }}"
125 group: "{{ item.group }}"
126 mode: "{{ item.mode }}"
128 label: "{{ item.path }}"
130 - path: "{{ nextcloud_webroot }}/apps"
132 owner: "{{ nextcloud_php_user }}"
133 group: "{{ nextcloud_websrv_user }}"
135 - path: "{{ nextcloud_webroot }}/config"
137 owner: "{{ nextcloud_php_user }}"
138 group: "{{ nextcloud_websrv_user }}"
140 - path: "{{ nextcloud_webroot }}/data"
142 owner: "{{ nextcloud_php_user }}"
143 group: "{{ nextcloud_websrv_user }}"
146 - name: Create nextcloud root dir symbolic link
147 ansible.builtin.file:
148 src: "{{ nextcloud_symbolic_source }}"
149 dest: "{{ nextcloud_webroot }}/nextcloud"
155 - name: Create nextcloud common app dir symbolic link
156 ansible.builtin.file:
157 src: "{{ nextcloud_symbolic_common }}"
158 dest: "{{ nextcloud_webroot }}/common"
164 - name: créer les fichiers spécifiques nextcloud
165 ansible.builtin.template:
166 src: "templates/{{ item.src }}"
167 dest: "{{ nextcloud_webroot }}/{{ item.dest }}"
168 owner: "{{ item.owner }}"
169 group: "{{ item.group}}"
170 mode: "{{ item.mode }}"
172 - src: "nextcloud_cron.j2"
174 owner: "{{ nextcloud_php_user }}"
175 group: "{{ nextcloud_websrv_user }}"
177 - src: "nextcloud_console.j2"
179 owner: "{{ nextcloud_websrv_user }}"
180 group: "{{ nextcloud_websrv_user }}"
182 - src: "nextcloud_install_config.j2"
183 dest: "config/config.php"
184 owner: "{{ nextcloud_php_user }}"
185 group: "{{ nextcloud_websrv_user }}"
188 # - name: Lancement du script d'installation nextcloud # noqa : command-instead-of-module
189 # become_user: "{{ nextcloud_php_user }}"
191 # ansible.builtin.command: >
192 # ./console maintenance:install
194 # --database-name="php_{{ SIGLE }}_{{ SITE }}"
195 # --database-user="php_{{ SIGLE }}_{{ SITE }}/data/"
196 # --database-host="/var/run/postgresql/"
197 # --admin-user='admin'
198 # --admin-pass='ckoideja'
199 # --data-dir="/home/sites/data/$TLD/{{ DOMAIN }}/{{ SITE }}/data/"
201 # chdir: "{{ nextcloud_webroot }}"
202 # register: install_result
204 # - name: créer les fichiers spécifiques nextcloud
205 # ansible.builtin.template:
206 # src: "templates/{{ item.src }}"
207 # dest: "{{ nextcloud_webroot }}/{{ item.dest }}"
208 # owner: "{{ item.owner }}"
209 # group: "{{ item.group}}"
210 # mode: "{{ item.mode }}"
212 # - src: "nextcloud_sigle_config.j2"
213 # dest: "config/{{ SIGLE }}.config.php"
214 # owner: "{{ nextcloud_php_user }}"
215 # group: "{{ nextcloud_websrv_user }}"
218 # - name: Creation d'un lien symbolique vers le configuration nextcloud commun
219 # ansible.builtin.file:
220 # src: "../../../../nextcloud/common/common.config.php"
221 # dest: "config/common.config.php"
227 # - name: Create sigle nextcloud config
228 # become_user: "{{ nextcloud_php_user }}"
230 # ansible.builtin.template:
231 # src: templates/sigle.config.php.j2
232 # dest: "{{ nextcloud_webroot }}/config/sigle.config.php"
233 # owner: "{{ nextcloud_php_user }}"
234 # group: "{{ nextcloud_websrv_user }}"
235 # mode: '640' # or u=rwx,g=r,o=
237 # - name: Pour chaque base, ajouter les droits suivants à l'utilisateur php
238 # become_user: postgres
240 # community.postgresql.postgresql_privs:
241 # db: "{{ item.db }}"
242 # privs: "{{ item.privs }}"
243 # type: "{{ item.type |default(omit)}}"
244 # objs: "{{ item.objs }}"
245 # role: "{{ item.role }}"
246 # grant_option: "{{ item.grant_option |default(omit) }}"
248 # label: "{{ item.name }}"
250 # - db: "{{ nextcloud_db_name }}"
251 # privs: "USAGE,CREATE"
254 # role: "{{ nextcloud_php_user }}"
255 # name: "GRANT USAGE,CREATE ON SCHEMA public TO php_{{ SIGLE }}_nuage;"
256 # - db: "{{ nextcloud_db_name }}"
259 # objs: "pg_namespace"
260 # role: "{{ nextcloud_php_user }}"
261 # name: "GRANT SELECT ON TABLE pg_namespace TO php_{{ SIGLE }}_nuage;"
262 # - db: "{{ nextcloud_db_name }}"
265 # objs: "pg_collation"
266 # role: "{{ nextcloud_php_user }}"
267 # name: "GRANT SELECT ON TABLE pg_collation TO php_{{ SIGLE }}_nuage;"
268 # - db: "{{ nextcloud_db_name }}"
272 # role: "{{ nextcloud_php_user }}"
273 # name: "GRANT SELECT ON TABLE pg_index TO php_{{ SIGLE }}_nuage;"
274 # - db: "{{ nextcloud_db_name }}"
278 # role: "{{ nextcloud_php_user }}"
279 # name: "GRANT SELECT ON TABLE pg_attrdef TO php_{{ SIGLE }}_nuage;"
280 # - db: "{{ nextcloud_db_name }}"
283 # objs: "pg_description"
284 # role: "{{ nextcloud_php_user }}"
285 # name: "GRANT SELECT ON TABLE pg_description TO php_{{ SIGLE }}_nuage;"
286 # - db: "{{ nextcloud_db_name }}"
289 # objs: "pg_settings"
290 # role: "{{ nextcloud_php_user }}"
291 # name: "GRANT SELECT ON TABLE pg_settings TO php_{{ SIGLE }}_nuage;"
292 # - db: "{{ nextcloud_db_name }}"
294 # objs: "pg_database"
295 # role: "{{ nextcloud_php_user }}"
296 # name: "GRANT SELECT ON pg_database TO php_{{ SIGLE }}_nuage;"
298 # - name: Creation d'un fichier cron pour /etc/cron.d
299 # ansible.builtin.cron:
300 # name: "nextcloud {{ SIGLE }}_{{ SITE }} taches d'arriere plan "
302 # user: "php_{{ SIGLE}}_{{SITE}}"
303 # job: "{{ nextcloud_source }}/cron"
305 # - name: Recharger plusieurs services
306 # ansible.builtin.service:
311 # - "php{{ php_version }}-fpm"