Before rushing to create a new issue in the Trelis repository, I want to clear this up in forum first.
So by default WordPress is installed for all sites on ansible-playbook run, according to these lines:
(No explicit site_install: true seems to be necessary because of the line when: item.value.site_install | default(true)).
However, on a deploy on a freshly provisoned server the following error occurs:
non-zero return code
Error: The site you have requested is not installed.
Run `wp core install`.
fatal: [staging-v]: FAILED! => {"changed": true, "cmd": ["wp", "core", "language", "install", "de_DE"], "delta": "0:00:00.091690", "end": "2018-03-17 01:13:31.859997", "rc": 1, "start": "2018-03-17 01:13:31.768307", "stderr_lines": ["Error: The site you have requested is not installed.", "Run `wp core install`."], "stdout": "", "stdout_lines": []}
This happens when a new language should be installed.
As current workaround, an extra wp core install task was
added to deploy hook prior installing a new language.
But this shouldn’t be actually necessary because the site should already
have been installed for all sites during prior provisioning?
Edit: wordpress-install is only included in dev environment. Why not also in staging and production environments?
Now I need to access the right vault keys, or alternatively,
the project key for retrieving the right vault keys
(for admin_password) from vault_wordpress_sites.
Maybe this is helpful for someone, this I am using now in *-finalize-after deploy hook for preparing WordPress in order to install other languages on a yet non-prepared site:
- name: Install WP (required for installing languages on empty 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"