# commande pour lancer le playbook: ansible-playbook creation_nouveau_site.yml
# attention - Par défaut ce scipt se lancer vers ligatures
-# pour ne jouer que la partie permettant de générer le certificat SSL pour le HTTPS lancer la commance ci-dessous (attention il faut recharger nginx manuellement à la fin):
+# pour ne jouer que la partie permettant de générer le certificat SSL pour le HTTPS lancer la commance ci-dessous:
+# ansible-playbook creation_nouveau_site.yml --tags "https"
+
+# pour ne jouer que la partie permettant de configrer un accès SFTP lancer la commance ci-dessous:
# ansible-playbook creation_nouveau_site.yml --tags "https"
- name: Promp pour définir les variables du nouveau ite
- name: Inclure les configurations optionnelles d'un site www
ansible.builtin.include_tasks: tasks/config_options_www.yml
- tags: https
+ tags:
+ - https
+ - sftp
- name: Inclure la configuration d'un site web basique
ansible.builtin.include_tasks: tasks/config_www.yml
ansible.builtin.include_tasks: tasks/config_backup.yml
- name: Inclure le configuration SFTP
- ansible.builtin.include_tasks: tasks/config_sftp.yml
+ ansible.builtin.include_tasks:
+ file: tasks/config_sftp.yml
+ apply:
+ tags: sftp
when: sftp_key != '' and sftp_key != 'non'
+ tags: sftp
src: "/home/sites/data/wordpress/"
dest: "/home/sites/data/{{ TLD }}/{{ DOMAIN }}/{{ config_ss_domain }}/"
remote_src: true # because the copy is from remote host to remote host
- mode: '754' # or 'u=rwx,g=rx,o=r'
- owner: "php_{{ SIGLE }}_{{ config_ss_domain }}"
+ mode: '2750' # or 'u=rwx,g=rx,o=r'
+ owner: "site_{{ SIGLE }}_{{ config_ss_domain }}"
group: "site_{{ SIGLE }}_{{ config_ss_domain }}"
- name: Créer les fichiers spécifiques wp
community.mysql.mysql_user:
name: "php_{{ SIGLE }}_{{ config_ss_domain }}"
priv: "php_{{ SIGLE }}_{{ config_ss_domain }}.*:ALL"
+ plugin: unix_socket
state: present
login_unix_socket: /run/mysqld/mysqld.sock
name: nginx
state: reloaded
when: SITE != 'nuage' and SITE != 'paheko' and SITE != 'WP' and template_site == 'http'
+
+# ne jamais executer cette tâche sauf si le playbook est appelé avec le tag https - fin du playbook
+- name: Recharger le service nginx
+ ansible.builtin.service:
+ name: nginx
+ state: reloaded
+ tags:
+ - https
+ - never
\ No newline at end of file
block:
- name: Demande la version de nextcloud déjà installée
ansible.builtin.pause:
- prompt: "Quelle version de nextcloud déjà installée? (default: 26.0.4)"
+ prompt: "Quelle version de nextcloud déjà installée? (default: 26.0.4.2)"
echo: true
register: ancienne_version_prompt
- name: Definir ancienne_version
ansible.builtin.set_fact:
- ancienne_version: "{{ ( ancienne_version_prompt.user_input | length == 0 ) | ternary ('26.0.4', ancienne_version_prompt.user_input) }}"
+ ancienne_version: "{{ ( ancienne_version_prompt.user_input | length == 0 ) | ternary ('26.0.4.2', ancienne_version_prompt.user_input) }}"
- name: Inclure la verif de l'install nextcloud
ansible.builtin.include_tasks: tasks/verif_installation_nextcloud.yml
# role: "{{ nextcloud_php_user }}"
# name: "GRANT SELECT ON pg_database TO php_{{ SIGLE }}_nuage;"
+# on rend aléatoire la minutes de l'heure à laquelle les tâches d'arriere plan nextcloud tournent entre les différentes instance pour répartir la charge
- name: Creation d'un fichier cron pour /etc/cron.d
ansible.builtin.cron:
name: "nextcloud {{ SIGLE }}_{{ config_ss_domain }} taches d'arriere plan toutes les 5 mins"
- minute: "*/5"
+ minute: "{{ 5 | random }}-59/5"
user: "php_{{ SIGLE }}_{{ config_ss_domain }}"
job: "{{ nextcloud_webroot }}/cron"
- name: Demande sous-domaine
- tags: https
+ tags:
+ - https
+ - sftp
ansible.builtin.pause:
prompt: 'quel sous-domaine faut-il configurer?(ex: www/gestion)'
echo: true
- default: '{{ SITE }}'
register: config_ss_domain_promp
when: SITE != 'nuage'
-- name: Bloc demande des autres options
+- name: Demande php
+ ansible.builtin.pause:
+ prompt: 'Faut-il configurer un pool PHP?(oui/non)'
+ echo: true
+ register: config_php_promp
when: SITE != 'paheko' and SITE != 'nuage' and SITE != 'WP'
- block:
- - name: Demande php
- ansible.builtin.pause:
- prompt: 'Faut-il configurer un pool PHP?(oui/non)'
- echo: true
- register: config_php_promp
+- name: Demande bdd
+ ansible.builtin.pause:
+ prompt: 'Faut-il configurer une base de données SQL?(ex: mariadb/postgres/non)'
+ echo: true
+ register: config_bdd_promp
+ when: SITE != 'paheko' and SITE != 'nuage' and SITE != 'WP'
- - name: Demande bdd
- ansible.builtin.pause:
- prompt: 'Faut-il configurer une base de données SQL?(ex: mariadb/postgres/non)'
- echo: true
- register: config_bdd_promp
+- name: Demande sftp_key
+ ansible.builtin.pause:
+ prompt: 'besoin de configurer un accès SFTP pour ce compte (vide ou clé public)'
+ echo: true
+ register: sftp_key_promp
+ when: SITE != 'paheko' and SITE != 'nuage'
+ tags: sftp
- - name: Demande sftp_key
- ansible.builtin.pause:
- prompt: 'besoin de configurer un accès SFTP pour ce compte (vide ou clé public)'
- echo: true
- register: sftp_key_promp
+- name: Definir config_ss_domain
+ tags:
+ - https
+ - sftp
+ ansible.builtin.set_fact:
+ config_ss_domain: "{{ ( SITE == 'nuage' | default ('') ) | ternary (SITE, config_ss_domain_promp.user_input) }}"
- name: Definir config_php
ansible.builtin.set_fact:
config_php: "{{ ( config_php_promp.user_input | default ('') | length == 0 ) | ternary ('non', config_php_promp.user_input) }}"
-- name: Definir config_ss_domain
- tags: https
- ansible.builtin.set_fact:
- config_ss_domain: "{{ ( SITE == 'nuage' | default ('') ) | ternary (SITE, config_ss_domain_promp.user_input) }}"
-
- name: Definir config_bdd
ansible.builtin.set_fact:
config_bdd: "{{ ( config_bdd_promp.user_input | default ('') | length == 0 ) | ternary ('non', config_bdd_promp.user_input) }}"
- name: Definir sftp_key
+ tags: sftp
ansible.builtin.set_fact:
sftp_key: "{{ sftp_key_promp.user_input | default('non') }}"
\ No newline at end of file