Skip to content
This repository was archived by the owner on Feb 13, 2023. It is now read-only.

Commit ac841e1

Browse files
committed
Fixes #1244: Add support for a secrets.yml file with Ansible Vault.
1 parent a096a56 commit ac841e1

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

docs/other/production.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,26 @@ _Note: Having the variable set locally takes precedence over having it on the re
3333

3434
As a precaution not to accidentally provision a production server with insecure configurations, you should set your security hardening configurations in `config.yml`, your local development overrides in `vagrant.config.yml` and finally any additional production specific overrides in `prod.config.yml`. This way, a production environment will never be provisioned with development tools, even if the `prod.config.yml` is not read.
3535

36+
## Ansible Vault support
37+
38+
Drupal VM will include a `secrets.yml` file included in your VM's configuration directory (alongside `config.yml`, `local.config.yml`, etc.) that you can use to store sensitive variables (e.g. MySQL's root password, Drupal's admin password). For extra security, you can encrypt this file, and require a password whenever the variable is used.
39+
40+
First, you'd create an Ansible Vault encrypted file:
41+
42+
$ ansible-vault create secrets.yml
43+
44+
Create the file inside your VM's configuration directory, add any plaintext passwords, and save it. Ansible Vault will encrypt the file, and you can edit the file using `ansible-vault edit`.
45+
46+
When running `vagrant` commands, make sure you tell the Ansible provisioner to use `--ask-vault-pass`, e.g.:
47+
48+
DRUPALVM_ANSIBLE_ARGS='--ask-vault-pass' vagrant [command]
49+
50+
And if you need to override one of the secrets stored in that file, you can do so through an environment-specific config file, for example:
51+
52+
vagrant.config.yml
53+
prod.config.yml
54+
[etc.]
55+
3656
## Example: Drupal VM on DigitalOcean
3757

3858
The [`examples/prod` directory](https://github.com/geerlingguy/drupal-vm/tree/master/examples/prod) contains an example production configuration for Drupal VM which can be used to deploy Drupal VM to a production environment on a cloud provider like DigitalOcean, Linode, or AWS.

provisioning/playbook.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
with_fileglob:
2020
- "{{ config_dir }}/config.yml"
2121
- "{{ config_dir }}/local.config.yml"
22+
- "{{ config_dir }}/secrets.yml"
2223
- "{{ config_dir }}/{{ lookup('env', 'DRUPALVM_ENV')|default(drupalvm_env, true)|default(ansible_env.DRUPALVM_ENV)|default(omit) }}.config.yml"
2324
tags: ['always']
2425

0 commit comments

Comments
 (0)