Compare commits
2 commits
cf32d4f8f6
...
ab51b331df
| Author | SHA1 | Date | |
|---|---|---|---|
| ab51b331df | |||
|
4574dbf4ba |
8 changed files with 97 additions and 0 deletions
|
|
@ -291,3 +291,5 @@ msmtp_hosts:
|
||||||
renovate_hosts:
|
renovate_hosts:
|
||||||
hosts:
|
hosts:
|
||||||
renovate:
|
renovate:
|
||||||
|
secrets_hosts:
|
||||||
|
hosts:
|
||||||
|
|
|
||||||
2
inventories/external/hosts.yaml
vendored
2
inventories/external/hosts.yaml
vendored
|
|
@ -22,3 +22,5 @@ infrastructure_authorized_keys_hosts:
|
||||||
ansible_pull_hosts:
|
ansible_pull_hosts:
|
||||||
hosts:
|
hosts:
|
||||||
status:
|
status:
|
||||||
|
secrets_hosts:
|
||||||
|
hosts:
|
||||||
|
|
|
||||||
|
|
@ -57,3 +57,5 @@ ansible_pull_hosts:
|
||||||
light:
|
light:
|
||||||
waybackproxy:
|
waybackproxy:
|
||||||
yate:
|
yate:
|
||||||
|
secrets_hosts:
|
||||||
|
hosts:
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,13 @@
|
||||||
tags:
|
tags:
|
||||||
- base_config
|
- base_config
|
||||||
|
|
||||||
|
- name: Ensure secrets deployment on secrets_hosts
|
||||||
|
hosts: secrets_hosts
|
||||||
|
roles:
|
||||||
|
- secrets
|
||||||
|
tags:
|
||||||
|
- secrets
|
||||||
|
|
||||||
- name: Ensure systemd-networkd config deployment on systemd_networkd_hosts
|
- name: Ensure systemd-networkd config deployment on systemd_networkd_hosts
|
||||||
hosts: systemd_networkd_hosts
|
hosts: systemd_networkd_hosts
|
||||||
roles:
|
roles:
|
||||||
|
|
|
||||||
24
roles/secrets/README.md
Normal file
24
roles/secrets/README.md
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
# Role `secrets`
|
||||||
|
|
||||||
|
Allows storing the given secret contents in the configured files.
|
||||||
|
|
||||||
|
## Supported Distributions
|
||||||
|
|
||||||
|
Should work on Debian-based distributions.
|
||||||
|
|
||||||
|
## Required Arguments
|
||||||
|
|
||||||
|
None.
|
||||||
|
|
||||||
|
## Optional Arguments
|
||||||
|
|
||||||
|
- `secrets__secrets`: List of secrets.
|
||||||
|
Defaults to the empty list (`[ ]`).
|
||||||
|
- `secrets__secrets.*.name`: (File)name for the secret (in the `/etc/ansible_secrets` directory).
|
||||||
|
- `secrets__secrets.*.content`: The secret content to store.
|
||||||
|
- `secrets__secrets.*.owner`: The owner of the secret file.
|
||||||
|
Defaults to `root`.
|
||||||
|
- `secrets__secrets.*.group`: The group of the secret file.
|
||||||
|
Defaults to `root`.
|
||||||
|
- `secrets__secrets.*.mode`: The mode of the secret file.
|
||||||
|
Defaults to `0640`.
|
||||||
1
roles/secrets/defaults/main.yaml
Normal file
1
roles/secrets/defaults/main.yaml
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
secrets__secrets: [ ]
|
||||||
6
roles/secrets/meta/argument_specs.yaml
Normal file
6
roles/secrets/meta/argument_specs.yaml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
argument_specs:
|
||||||
|
main:
|
||||||
|
options:
|
||||||
|
secrets__secrets:
|
||||||
|
type: list
|
||||||
|
required: false
|
||||||
53
roles/secrets/tasks/main.yaml
Normal file
53
roles/secrets/tasks/main.yaml
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
- name: validate secret configs
|
||||||
|
ansible.builtin.validate_argument_spec:
|
||||||
|
argument_spec: "{{ required_data }}"
|
||||||
|
provided_arguments:
|
||||||
|
config: "{{ item }}"
|
||||||
|
loop: "{{ secrets__secrets }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.name }}"
|
||||||
|
vars:
|
||||||
|
required_data:
|
||||||
|
config:
|
||||||
|
type: dict
|
||||||
|
required: true
|
||||||
|
options:
|
||||||
|
name:
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
owner:
|
||||||
|
type: str
|
||||||
|
required: false
|
||||||
|
default: root
|
||||||
|
group:
|
||||||
|
type: str
|
||||||
|
required: false
|
||||||
|
default: root
|
||||||
|
mode:
|
||||||
|
type: str
|
||||||
|
required: false
|
||||||
|
default: "0640"
|
||||||
|
|
||||||
|
- name: ensure secrets directory exists
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "/etc/ansible_secrets"
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0750"
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: ensure secrets are present
|
||||||
|
ansible.builtin.copy:
|
||||||
|
content: "{{ item.content }}"
|
||||||
|
dest: "/etc/ansible_secrets/{{ item.name }}"
|
||||||
|
mode: "{{ item.mode | default('0640') }}"
|
||||||
|
owner: "{{ item.owner | default('root') }}"
|
||||||
|
group: "{{ item.group | default('root') }}"
|
||||||
|
become: true
|
||||||
|
loop: "{{ secrets__secrets }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.name }}"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue