2.4 KiB
2.4 KiB
| title | summary |
|---|---|
| SOPS: New Host | How to Setup SOPS for a New Host |
SOPS: New Host
The following outlines the steps to take for setting up SOPS for a new host (myservice).
Every host needs a SOPS configuration as every host should be set up to run ansible-pull.
- Create a new age key for ansible-pull for the host:
age-keygen - Add the public key part to the
.sops.yamlunder:
You can use the existing configuration as guidance.keys: # ... hosts: chaosknoten: age: &host_chaosknoten_age_keys # ... - &host_myservice_ansible_pull_age_key <age public key here>
For VMs not on Chaosknoten, choose the appropriate section. - Add a new creation rule for the hosts
host_varsfile to the.sops.yaml.
It should most likely hold all admin keys plus the host entry you just added and look something like this:
You can use existing creation rules as a reference.creation_rules: # ... ## host vars # chaosknoten hosts # ... - path_regex: "inventories/chaosknoten/host_vars/myservice\\.sops\\..+" key_groups: - pgp: *admin_gpg_keys age: - *host_myservice_ansible_pull_age_key
For VMs not on Chaosknoten, choose the appropriate section. - Re-encrypt for the newly added key (mainly
group_vars/all.sops.yaml):
If GPG yells at you, follow the instructions in infra-secrets.find inventories -name "*.sops.*" | xargs sops updatekeys --yes - Create a SOPS secrets file in the
host_varssubdirectory of the relevant inventory. The name of the file should be of the format<hostname>.sops.yamlto get picked up by the vars plugin and to match the previously created creation rule.
For this example the following command accomplishes this:sops inventories/chaosknoten/host_vars/myservice.sops.yaml- With the editor now open, delete the example content and add the previously generated age private key like this:
Note that SOPS only encrypts the values, not the keys.ansible_pull__age_private_key: <age private key here>
- With the editor now open, delete the example content and add the previously generated age private key like this: