-
-
Notifications
You must be signed in to change notification settings - Fork 607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accommodate file encryption via ansible vault #317
Conversation
e86ef77
to
71b6c7c
Compare
@fullyint no need for |
20c90a5
to
7e1a5a3
Compare
9365d23
to
dcb9a58
Compare
@@ -1,6 +1,7 @@ | |||
[defaults] | |||
roles_path = vendor/roles | |||
force_handlers = True | |||
vault_password_file = .vault_pass.example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be set to .vault_pass
? It's one less thing to change if users want it enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The playbook fails if vault_password_file
refers to a missing file. The file .vault_pass
will be missing by default because it is .gitignore
d. Users who don't want ansible vault would have to remove this line or create the .vault_pass
file. I explain below why I didn't just omit this line and require vault users to add it.
To enable vault, we could have users create new stuff: add vault_password_file
line to ansible.cfg
and create the .vault_pass
file. I chose the alternative of having users edit example versions of each (steps 1 and 2 in this PR's first comment) because I speculate that users would be more likely to try vault if they could edit example stuff instead of create new stuff.
An added bonus of having the examples present in the repo is that one can actually skip steps 1 and 2, and do only step 3 (run the ansible-vault encrypt
command). That means one can test how easy it is to use ansible vault by just running that single command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had naively hoped that Ansible would just skip using vault_password_file
if nothing was encrypted so that this could be set to .vault_pass
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally assumed it would skip. That's what I would have preferred.
@fullyint let's move forward with this 👍 Can you work on a new doc section? |
I'm sorry if this was discussed somewhere earlier, but why are you completely moving some variables into vaults?
And then your
This has the benefit of minimizing change to playbooks and keeps existence of variables more discoverable, while still getting the benefit of ansible-vault. And if a user decides not to use vault, they can just simply replace |
I agree with the approach @mxxcon suggests. You should not have to look at two files to get the full picture. |
👍 |
@mxxcon I like that approach but I couldn't implement it directly because There would be no problem with variables such as You'll see how I approached the issue by searching this PR's diff for I'd be delighted if anyone would offer a better working implementation. |
I see. I have not fully grokked trellis yet, so I'll defer to you guys since you are more familiar with its challenges. 😃 |
Docs at roots/docs#5. I think this is ready. Thank you, @mxxcon, your comments inspired good revisions. A Few Updates
wordpress_sites:
example.com:
⋮
env:
wp_home: http://example.dev
wp_siteurl: http://example.dev/wp
wp_env: development
# Define the following variables in group_vars/development/vault.yml
# db_name:
# db_user:
# db_password:
⋮ One other change worth noting was that I removed the Vault with Variables in a Hash # 1 - Fail: If all sites use `vault_db_password`, they all have the same password
wordpress_sites:
site-1.com:
db_password: "{{ vault_db_password }}"
site-2.com:
db_password: "{{ vault_db_password }}"
# 2 - Suboptimal: Requiring users to edit variable names means more work and more risk for error
wordpress_sites:
site-1.com:
db_password: "{{ vault_db_password_1 }}"
site-2.com:
db_password: "{{ vault_db_password_2 }}"
# 3 - Fail: The `item.key` variable is only defined in the scope of the looping task and will be undefined in the more global scope of the example below
wordpress_sites:
site-1.com:
db_password: "{{ vault_wordpress_sites[item.key].env.db_password }}"
site-2.com:
db_password: "{{ vault_wordpress_sites[item.key].env.db_password }}" |
3c165df
to
645bdf9
Compare
* `admin_email` - WP admin email address (*development* only, required) | ||
* `admin_password` - WP admin user password (*development* only, required) | ||
* `admin_user` - WP admin user name (*development* only, required, in `vault.yml`) | ||
* `admin_email` - WP admin email address (*development* only, required, in `vault.yml`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
admin_email
shouldn't be in vault
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
admin_user
as well?
@swalkinshaw why not? Do you not consider these to be sensitive? Speaking of sensitive info, unless I'm misunderstanding this, is it proper for |
@mxxcon not really. Keep in mind all of this data should still be kept in private repos. I only consider "secrets" as applicable for vault. I agree that |
As @swalkinshaw suggested, I removed a few vars from the vault:
As @mxxcon suggested, I split out I updated the docs PR to reflect the above changes. |
Accommodate file encryption via ansible vault
Moves some variables to
group_vars/<environment>/vault.yml
files.To start using Ansible Vault:
.vault_pass.example
to.vault_pass
, edit the password, and probablychmod 600 .vault_pass
ansible.cfg
:vault.yml
files with command below (doesn't support fileglobs -- "ansible-vault encrypt" will not accept multiple files at once ansible/ansible#6241):Preliminary discussion in #308 where I mentioned these items:
Would we want
mysql_root_user: root
vaulted? It is currently ingroup_vars/all/database.yml
.