Updated approach:
Ensure finished WordPress setup and installing additonal languages in finalize-after site hook:
In case of formal variant languages it can be helpful to also install the non-formal language as a fallback because plugins can be disproportionally translated for the non-formal variant.
https://wordpress.org/plugins/language-fallback/
- name: Install WP (required for installing languages on non-transferred site)
command: wp core {{ project.multisite.enabled | default(false) | ternary('multisite-install', 'install') }}
--allow-root
--url="{{ site_env.wp_home }}"
{% if project.multisite.enabled | default(false) %}
--base="{{ project.multisite.base_path | default('/') }}"
--subdomains="{{ project.multisite.subdomains | default('false') }}"
{% endif %}
--title="{{ project.site_title | default(site) }}"
--admin_user="{{ project.admin_user | default('admin') }}"
--admin_password="{{ vault_wordpress_sites[site].admin_password }}"
--admin_email="{{ project.admin_email }}"
args:
chdir: "{{ deploy_helper.current_path }}"
register: wp_install
changed_when: "'WordPress is already installed.' not in wp_install.stdout and 'The network already exists.' not in wp_install.stdout"
- name: Install WP language de_DE
command: wp core language install de_DE
args:
chdir: "{{ deploy_helper.current_path }}"
- name: Install WP language de_DE_formal
command: wp core language install de_DE_formal --activate
args:
chdir: "{{ deploy_helper.current_path }}"
- name: Update active language
command: wp core language update
args:
chdir: "{{ deploy_helper.current_path }}"
The username / password for WordPress setup can reflect the real credentials (before transferring the database to system, e.g. using a plugin instead, which in turn requires an admin login) are stored in vault.yml
which should be the correct place for secrets:
# Variables to accompany `group_vars/production/wordpress_sites.yml`
# Note: the site name (`example.com`) must match up with the site name in the above file.
vault_wordpress_sites:
example.com:
env:
db_password: "example_dbpassword"
# Generate your keys here: https://roots.io/salts.html
auth_key: "generateme"
secure_auth_key: "generateme"
logged_in_key: "generateme"
nonce_key: "generateme"
auth_salt: "generateme"
secure_auth_salt: "generateme"
logged_in_salt: "generateme"
nonce_salt: "generateme"
admin_user: "wordpress-admin-username"
admin_password: "wordpress-admin-password"
And finally for speeding up and preventing gaps of missing language for longer duration during deploy:
roles/deploy/defaults/main.yml (at line 14):
# There are certain folders you'll want to copy from release to release to speed up deploys.
# Examples: Composer's `vendor` folder, npm's `node_modules`.
# These should not be part of project_shared_children since dependencies need to be atomic and tied to a deploy.
project_copy_folders:
- vendor
- web/app/languages