Skip to content

Commit cab974a

Browse files
committed
store secrets with Ansibie Vault
* encrypt secrets.yml as an Ansible Vault * fetch vault password from Bitwarden cli
1 parent acd1920 commit cab974a

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

Makefile

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
ANSIBLE_VAULT_FLAGS = --vault-password-file files/bw_vault_password.sh
12
CERTBOT_SCRIPT = files/certbot.sh
23
CERTBOT_WORKDIR = files/certbot.d
4+
EDITOR = code --wait
5+
36
# Run pre-commit checks on all files
47
check:
58
pre-commit run --all-files
@@ -10,6 +13,10 @@ envsetup:
1013
ansible-galaxy collection install -U -r requirements.yml
1114
pre-commit install
1215

16+
# Edit Ansible Vault
17+
vaultedit:
18+
env EDITOR="$(EDITOR)" ansible-vault edit $(ANSIBLE_VAULT_FLAGS) vars/secrets.yml
19+
1320
## The following tasks run the certbot helper script
1421
## Naming: certbot-(issue|renew)
1522

@@ -24,43 +31,43 @@ certbot-renew:
2431
## Order in Makefile: all, groups, nodes
2532

2633
setup-all:
27-
ansible-playbook setup.yml
34+
ansible-playbook setup.yml $(ANSIBLE_VAULT_FLAGS)
2835

2936
setup-guests:
30-
ansible-playbook setup.yml --limit guests
37+
ansible-playbook setup.yml $(ANSIBLE_VAULT_FLAGS) --limit guests
3138

3239
setup-proxmox:
33-
ansible-playbook setup.yml --limit proxmox
40+
ansible-playbook setup.yml $(ANSIBLE_VAULT_FLAGS) --limit proxmox
3441

3542
setup-containers:
36-
ansible-playbook setup.yml --limit v-containers
43+
ansible-playbook setup.yml $(ANSIBLE_VAULT_FLAGS) --limit v-containers
3744

3845
setup-postgres:
39-
ansible-playbook setup.yml --limit postgres
46+
ansible-playbook setup.yml $(ANSIBLE_VAULT_FLAGS) --limit postgres
4047

4148
setup-pihole:
42-
ansible-playbook setup.yml --limit pihole
49+
ansible-playbook setup.yml $(ANSIBLE_VAULT_FLAGS) --limit pihole
4350

4451
setup-storage:
45-
ansible-playbook setup.yml --limit storage
52+
ansible-playbook setup.yml $(ANSIBLE_VAULT_FLAGS) --limit storage
4653

4754
upgrade-all:
48-
ansible-playbook upgrade.yml
55+
ansible-playbook upgrade.yml $(ANSIBLE_VAULT_FLAGS)
4956

5057
upgrade-guests:
51-
ansible-playbook upgrade.yml --limit guests
58+
ansible-playbook upgrade.yml $(ANSIBLE_VAULT_FLAGS) --limit guests
5259

5360
upgrade-proxmox:
54-
ansible-playbook upgrade.yml --limit proxmox
61+
ansible-playbook upgrade.yml $(ANSIBLE_VAULT_FLAGS) --limit proxmox
5562

5663
upgrade-containers:
57-
ansible-playbook upgrade.yml --limit v-containers
64+
ansible-playbook upgrade.yml $(ANSIBLE_VAULT_FLAGS) --limit v-containers
5865

5966
upgrade-postgres:
60-
ansible-playbook upgrade.yml --limit postgres
67+
ansible-playbook upgrade.yml $(ANSIBLE_VAULT_FLAGS) --limit postgres
6168

6269
upgrade-pihole:
63-
ansible-playbook upgrade.yml --limit pihole
70+
ansible-playbook upgrade.yml $(ANSIBLE_VAULT_FLAGS) --limit pihole
6471

6572
upgrade-storage:
66-
ansible-playbook upgrade.yml --limit storage
73+
ansible-playbook upgrade.yml $(ANSIBLE_VAULT_FLAGS) --limit storage

files/bw_vault_password.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "Please enter your Bitwarden credentials when prompted." 1>&2
5+
bw get password "Infra Ansible Vault"

0 commit comments

Comments
 (0)