Commit 655e11f7 authored by okhin's avatar okhin 🚴

Managing wordpress sites for multisite system

parent 1ec135a1
......@@ -101,13 +101,48 @@
register: wordpress_network_activated_plugins
changed_when: wordpress_network_activated_plugins.rc >= 1
- name: créé les utilisateurs
- name: vérifie les utilisateurs
loop: "{{ wordpress_users }}"
command: "php {{ wordpress_wpcli_path }} user get '{{ item.name }}' --path={{ wordpress_path }}"
register: wordpress_user_absent
changed_when: wordpress_user_absent.rc >= 1
failed_when: False
- name: créé les utilisateurs
loop: "{{ wordpress_user_absent.results }}"
command: "php {{ wordpress_wpcli_path }} user create '{{ item.name }}' {{ item.email }} --send-email --role={{item.role}} --path={{ wordpress_path }}"
when: wordpress_user_absent.changed
- name: donne à {{ item }} les droits superadmin
- name: donne les droits superadmin
loop: "{{ wordpress_superusers }}"
command: "php {{ wordpress_wpcli_path }} super-admin add {{ item }} --path={{ wordpress_path }}"
register: wordpress_superuser_result
changed_when: "wordpress_superuser_result.stdout != 'Success: Super admins remain unchanged.'"
- name: crée les sites
loop: "{{ wordpress_site }}"
command: "php {{ wordpress_wpcli_path }} site create --slug='{{ item.slug }}' --path={{ wordpress_path }} --email={{ item.admin_email }} --private --title='{{ item.title }}'"
register: wordpress_sites_created
changed_when: wordpress_sites_created.rc == 0
failed_when: 'wordpress_sites_created.rc >= 1 and wordpress_sites_created.stderr != "Error: Sorry, that site already exists!"'
- name: configure les options des sites
loop: "{{ wordpress_site | subelements('options', skip_missing=True) }}"
command: "php {{ wordpress_wpcli_path }} site option update {{ item.1.name }} '{{ item.1.value }}' --path={{ wordpress_path }} --url='{{ item.0.url }}'"
register: wordpress_site_options
changed_when: wordpress_site_options.rc == 0 and not "unchanged" in wordpress_site_options.stdout
- name: active les themes des sites
loop: "{{ wordpress_site }}"
command: "php {{ wordpress_wpcli_path }} theme activate {{ item.theme }} --path={{ wordpress_path }} --url='{{ item.url }}'"
register: wordpress_themes_sites_activated
changed_when: wordpress_themes_sites_activated.rc == 0 and not "already active" in wordpress_themes_sites_activated.stderr
- name: active les extensions du site
loop: "{{ wordpress_site | subelements('plugins', skip_missing=True) }}"
command: "php {{wordpress_wpcli_path }} plugin activate {{ item.1 }} --path={{ wordpress_path }} --url='{{ item.0.url }}'"
register: wordpress_plugins_sites_activated
changed_when: wordpress_plugins_sites_activated.rc == 0 and not "already activated" in wordpress_plugins_sites_activated.stdout
become: yes
become_user: "{{ wordpress_unix_user }}"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment