I came across this thread and remembered I’d solved this problem last year, when I was tweaking the script to set the default language and site tagline (both come from groups_vars/<env>/wordpress_sites.yml
).
Here’s my solution, which is in roles/wordpress-install/tasks/main.yml
:
- name: Install WP Site Language
command: wp core language install "{{ item.value.site_language }}" --allow-root
args:
chdir: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/"
with_dict: "{{ wordpress_sites }}"
when:
- item.value.site_language | default(false)
- wp_install.changed
- name: Activate WP Site Language
command: wp core language activate "{{ item.value.site_language }}" --allow-root
args:
chdir: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/"
with_dict: "{{ wordpress_sites }}"
when:
- item.value.site_language | default(false)
- "'{{ item.value.site_language }}' in wp_install.results[0].item.value.site_language"
- name: Update WP Tagline
command: wp option update blogdescription "{{ item.value.site_tagline }}" --allow-root
args:
chdir: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/"
with_dict: "{{ wordpress_sites }}"
when:
- item.value.site_tagline | default(false)
- wp_install.changed