# 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
- 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