When an Ansible task loops over list items (with_items) or elements of a dictionary (with_dict) , it makes the item
variable available during each loop.
Trellis creates the site_env
var for use in looping tasks, so the variable definition refers to an item
variable. For example, the “Create database of sites” task uses with_dict: "{{ wordpress_sites }}"
, which is probably what your task needs for item
to be defined, and for your shell
command to loop over each of your sites.
If it turns out you only need to “Authorize B2 account via CLI” just once, rather than for each site, you could just put the #B2 credentials
at the end of the vault.yml
file in their own section, with no indentation (i.e., not part of vault_wordpress_sites
). Then:
- name: Authorize B2 account via CLI
- shell: b2 authorize-account {{ site_env.b2_account_id }} {{ site_env.b2_application_key }}
+ shell: b2 authorize-account {{ b2_account_id }} {{ b2_application_key }}