Using the global auth.json
file didn’t seem to be working for me and the most recent version of the Delicious Brains docs only mention using an auth.json
file "alongside the composer.json
file.
So I am currently (and redundantly) using the composer config
command to generate (or add to) the ~/.composer/auth.json
file, and the Jinga template to create the one alongside the composer.json
in the current release directory.
- name: Setup composer.deliciousbrains.com username
composer:
global_command: yes
command: config
arguments: http-basic.composer.deliciousbrains.com username {{ vault_delicious_brains_username }}
when: vault_delicious_brains_username is defined
- name: Setup composer.deliciousbrains.com password
composer:
global_command: yes
command: config
arguments: http-basic.composer.deliciousbrains.com password {{ vault_delicious_brains_password }}
when: vault_delicious_brains_password is defined
- name: Create composer auth.json for deliciousbrains
template:
src: "{{ playbook_dir }}/deploy-hooks/auth.json.j2"
dest: "{{ deploy_helper.new_release_path }}/auth.json"
mode: "0600"
The template pulls the vault variables from the top level of the vault file(s) (per env):
{
"http-basic": {
"composer.deliciousbrains.com": {
"username": "{{ vault_delicious_brains_username }}",
"password": "{{ vault_delicious_brains_password }}"
}
}
}
Which in the vault file look like this:
vault_delicious_brains_username: "bla bla bla from delicious brains"
vault_delicious_brains_password: "bla bla bla from delicious brains"
But a slightly easier approach might be to put the Delicious Brains credentials in group_vars/all/vault.yml
:
vault_wordpress_env_defaults:
delicious_brains_username: "bla bla bla from delicious brains"
delicious_brains_password: "bla bla bla from delicious brains"
With a template like this that pulls from the env_defaults dictionary:
{
"http-basic": {
"composer.deliciousbrains.com": {
"username": "{{ vault_wordpress_env_defaults.delicious_brains_username }}",
"password": "{{ vault_wordpress_env_defaults.delicious_brains_password }}"
}
}
}
In the meantime I have contacted Delicious Brains to ask if they currently support Global auth.json
authentication.