1 - name: Etckeeper commit if necessary
2 ansible.builtin.command: etckeeper commit "commit by ansible because installing {{ DOMAIN }}/{{ config_ss_domain }}"
5 - name: Install required packages
14 - "php{{ php_version }}-xml"
25 - "php{{ php_version }}-pgsql"
35 - python3-psycopg2 # module ansible psql
38 - name: Boucle d'ajout du user php dans plusieurs groupe
40 name: "php_{{ SIGLE }}_{{ config_ss_domain }}"
47 - "site_{{ SIGLE }}_{{ config_ss_domain }}"
49 - name: Bloc nouvelle version nextcloud
50 when: nouvelle_version is undefined
52 - name: Demande la version de nextcloud à installer
53 ansible.builtin.pause:
54 prompt: "Quelle version de nextcloud doit être utilisée"
56 register: nextcloud_version_prompt
58 - name: Definir nouvelle_version
59 ansible.builtin.set_fact:
60 nouvelle_version: "{{ nextcloud_version_prompt.user_input }}"
62 - name: Bloc ancienne version nextcloud
63 when: ancienne_version is undefined
65 - name: Demande la version de nextcloud déjà installée
66 ansible.builtin.pause:
67 prompt: "Quelle version de nextcloud déjà installée"
69 register: ancienne_version_prompt
71 - name: Definir ancienne_version
72 ansible.builtin.set_fact:
73 ancienne_version: "{{ ancienne_version_prompt.user_input }}"
75 - name: Inclure la verif de l'install nextcloud
76 ansible.builtin.include_tasks: tasks/verif_installation_nextcloud.yml
78 - name: Pour chaque base, ajouter les droits suivants à l'utilisateur php
81 community.postgresql.postgresql_privs:
83 privs: "{{ item.privs }}"
84 type: "{{ item.type |default(omit) }}"
85 objs: "{{ item.objs }}"
86 role: "{{ item.role }}"
87 grant_option: "{{ item.grant_option |default(omit) }}"
89 label: "{{ item.name }}"
91 - db: "{{ nextcloud_db_name }}"
95 role: "{{ nextcloud_php_user }}"
97 name: "GRANT ALL ON SCHEMA public TO php_{{ SIGLE }}_nuage WITH GRANT OPTION;"
99 - name: Boucle création des répertoires app, config et data nextcloud
100 ansible.builtin.file:
101 path: "{{ item.path }}"
102 state: "{{ item.state }}"
103 owner: "{{ item.owner }}"
104 group: "{{ item.group }}"
105 mode: "{{ item.mode }}"
107 label: "{{ item.path }}"
109 - path: "{{ nextcloud_webroot }}/apps"
111 owner: "{{ nextcloud_php_user }}"
112 group: "{{ nextcloud_websrv_user }}"
114 - path: "{{ nextcloud_webroot }}/config"
116 owner: "{{ nextcloud_php_user }}"
117 group: "{{ nextcloud_websrv_user }}"
119 - path: "{{ nextcloud_webroot }}/data"
121 owner: "{{ nextcloud_php_user }}"
122 group: "{{ nextcloud_websrv_user }}"
125 - name: Create nextcloud root dir symbolic link
126 ansible.builtin.file:
127 src: "{{ nextcloud_symbolic_source }}"
128 dest: "{{ nextcloud_webroot }}/nextcloud"
134 - name: Create nextcloud common app dir symbolic link
135 ansible.builtin.file:
136 src: "{{ nextcloud_common }}"
137 dest: "{{ nextcloud_webroot }}/common"
143 - name: Créer les fichiers spécifiques nextcloud
144 ansible.builtin.template:
145 src: "templates/{{ item.src }}"
146 dest: "{{ nextcloud_webroot }}/{{ item.dest }}"
147 owner: "{{ item.owner }}"
148 group: "{{ item.group }}"
149 mode: "{{ item.mode }}"
151 - src: "nextcloud_cron.j2"
153 owner: "{{ nextcloud_php_user }}"
154 group: "{{ nextcloud_websrv_user }}"
156 - src: "nextcloud_console.j2"
158 owner: "{{ nextcloud_websrv_user }}"
159 group: "{{ nextcloud_websrv_user }}"
161 - src: "nextcloud_install_config.j2"
162 dest: "config/config.php"
163 owner: "{{ nextcloud_php_user }}"
164 group: "{{ nextcloud_websrv_user }}"
167 - name: Recharger php
168 ansible.builtin.service:
172 - "php{{ php_version }}-fpm"
174 - name: Lancement du script d'installation nextcloud # noqa : command-instead-of-module
175 become_user: "{{ nextcloud_php_user }}"
177 ansible.builtin.command: >
178 ./console maintenance:install
180 --database-name="php_{{ SIGLE }}_{{ config_ss_domain }}"
181 --database-user="php_{{ SIGLE }}_{{ config_ss_domain }}"
182 --database-host="/var/run/postgresql/"
185 --admin-pass='ckoideja'
186 --data-dir="/home/sites/data/{{ TLD }}/{{ DOMAIN }}/{{ config_ss_domain }}/data/"
188 chdir: "{{ nextcloud_webroot }}"
189 register: install_result
192 - name: Afficher les logs du script d'install
193 ansible.builtin.debug:
195 when: install_result is defined
197 - name: Afficher les logs du script d'install
198 ansible.builtin.fail:
199 msg: "Le script d'install a échoué: Voir les logs ci-dessus"
200 when: install_result.failed
202 - name: Créer les fichiers spécifiques nextcloud
203 ansible.builtin.template:
204 src: "templates/{{ item.src }}"
205 dest: "{{ nextcloud_webroot }}/{{ item.dest }}"
206 owner: "{{ item.owner }}"
207 group: "{{ item.group }}"
208 mode: "{{ item.mode }}"
210 - src: "nextcloud_sigle_config.j2"
211 dest: "config/{{ SIGLE }}.config.php"
212 owner: "{{ nextcloud_php_user }}"
213 group: "{{ nextcloud_websrv_user }}"
216 - name: Creation d'un lien symbolique vers la configuration nextcloud common
217 ansible.builtin.file:
218 src: "../../../../nextcloud/common.config.php"
219 path: "{{ nextcloud_webroot }}/config/common.config.php"
225 - name: Pour chaque base, ajouter les droits suivants à l'utilisateur php
226 become_user: postgres
228 community.postgresql.postgresql_privs:
230 privs: "{{ item.privs }}"
231 type: "{{ item.type | default(omit) }}"
232 objs: "{{ item.objs }}"
233 role: "{{ item.role }}"
234 grant_option: "{{ item.grant_option | default(omit) }}"
236 label: "{{ item.name }}"
238 - db: "{{ nextcloud_db_name }}"
239 privs: "USAGE,CREATE"
242 role: "{{ nextcloud_php_user }}"
243 name: "GRANT USAGE,CREATE ON SCHEMA public TO php_{{ SIGLE }}_nuage;"
244 # - db: "{{ nextcloud_db_name }}"
247 # objs: "pg_namespace"
248 # role: "{{ nextcloud_php_user }}"
249 # name: "GRANT SELECT ON TABLE pg_namespace TO php_{{ SIGLE }}_nuage;"
250 # - db: "{{ nextcloud_db_name }}"
253 # objs: "pg_collation"
254 # role: "{{ nextcloud_php_user }}"
255 # name: "GRANT SELECT ON TABLE pg_collation TO php_{{ SIGLE }}_nuage;"
256 # - db: "{{ nextcloud_db_name }}"
260 # role: "{{ nextcloud_php_user }}"
261 # name: "GRANT SELECT ON TABLE pg_index TO php_{{ SIGLE }}_nuage;"
262 # - db: "{{ nextcloud_db_name }}"
266 # role: "{{ nextcloud_php_user }}"
267 # name: "GRANT SELECT ON TABLE pg_attrdef TO php_{{ SIGLE }}_nuage;"
268 # - db: "{{ nextcloud_db_name }}"
271 # objs: "pg_description"
272 # role: "{{ nextcloud_php_user }}"
273 # name: "GRANT SELECT ON TABLE pg_description TO php_{{ SIGLE }}_nuage;"
274 # - db: "{{ nextcloud_db_name }}"
277 # objs: "pg_settings"
278 # role: "{{ nextcloud_php_user }}"
279 # name: "GRANT SELECT ON TABLE pg_settings TO php_{{ SIGLE }}_nuage;"
280 # - db: "{{ nextcloud_db_name }}"
282 # objs: "pg_database"
283 # role: "{{ nextcloud_php_user }}"
284 # name: "GRANT SELECT ON pg_database TO php_{{ SIGLE }}_nuage;"
286 - name: Creation d'un fichier cron pour /etc/cron.d
287 ansible.builtin.cron:
288 name: "nextcloud {{ SIGLE }}_{{ config_ss_domain }} taches d'arriere plan toutes les 5 mins"
290 user: "php_{{ SIGLE }}_{{ config_ss_domain }}"
291 job: "{{ nextcloud_webroot }}/cron"
293 - name: Recharger plusieurs services
294 ansible.builtin.service:
298 - "php{{ php_version }}-fpm"