-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8139a6
commit 1e43d42
Showing
14 changed files
with
215 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
|
||
######################################################### | ||
## Hashicorp Vault SSH Secret Engine module ## | ||
######################################################### | ||
|
||
######################################################### | ||
## Get SSH Secrets engine ## | ||
######################################################### | ||
|
||
|
||
######################################################### | ||
## Create SSH Secrets engine ## | ||
######################################################### | ||
|
||
- name: Create Vault KV secret engine | ||
when: action == 'create_secret_engine' | ||
block: | ||
|
||
# Validate variables | ||
- name: Validate variables for Vault create_secret_engine action. | ||
ansible.builtin.assert: | ||
that: "{{ varitem }} is defined" | ||
fail_msg: "Required variable '{{ varitem }}' has not been provided." | ||
quiet: true | ||
loop_control: | ||
loop_var: varitem | ||
loop: | ||
- vault_name | ||
- vault_description | ||
|
||
# Create Hashicorp secrets engine via api. Authenticate with vault_token. | ||
- name: Create Hashicorp secrets engine via api | ||
ansible.builtin.uri: | ||
url: "{{ vault_address }}/v1/sys/mounts/{{ vault_name }}" | ||
validate_certs: false | ||
method: POST | ||
status_code: 204 | ||
headers: | ||
X-Vault-Token: "{{ vault_token }}" | ||
body_format: json | ||
body: | ||
type: ssh | ||
description: "{{ vault_description }}" | ||
|
||
|
||
|
||
|
||
######################################################### | ||
## Destroy KV Secrets engine ## | ||
######################################################### | ||
|
||
- name: Destroy Vault SSH secret engine | ||
when: action == 'destroy_secret_engine' | ||
block: | ||
|
||
# Validate local variables | ||
- name: Validate variables for Vault destroy_secret_engine action. | ||
ansible.builtin.assert: | ||
that: "{{ varitem }} is defined" | ||
fail_msg: "Required variable '{{ varitem }}' has not been provided." | ||
quiet: true | ||
loop_control: | ||
loop_var: varitem | ||
loop: | ||
- vault_name | ||
|
||
# Destroy Hashicorp secrets engine via api. Authenticate with vault_token. | ||
- name: "Destroy Hashicorp secrets engine {{ vault_name }}" | ||
ansible.builtin.uri: | ||
url: "{{ vault_address }}/v1/sys/mounts/{{ vault_name }}" | ||
validate_certs: false | ||
method: DELETE | ||
status_code: 204 | ||
headers: | ||
X-Vault-Token: "{{ vault_token }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
|
||
- name: Playbook to test development | ||
hosts: lab_server | ||
tasks: | ||
|
||
|
||
|
||
|
||
######################################################### | ||
## Configuration Vault PKI ## | ||
######################################################### | ||
|
||
# Clear variable, be sure it is not used from a previous run. | ||
- name: Clear variable vault_name | ||
ansible.builtin.set_fact: | ||
vault_name: "" | ||
no_log: true | ||
|
||
# Clear variable, be sure it is not used from a previous run. | ||
- name: Clear variable vault_description | ||
ansible.builtin.set_fact: | ||
vault_description: "" | ||
no_log: true | ||
|
||
# Create secret engine | ||
- name: Create secret engine | ||
ansible.builtin.include_role: | ||
name: vault | ||
tasks_from: secret_engine.yml | ||
vars: | ||
action: create_secret_engine | ||
vault_address: "http://192.168.11.22:8200" | ||
vault_token: "hvs.5XYaP4XJwdV5FqeJpQalQRXr" | ||
vault_name: "certificates" | ||
vault_description: "Certificates secrets store" | ||
vault_type: "pki" | ||
|
||
# Delete secret engine | ||
- name: Delete secret engine | ||
ansible.builtin.include_role: | ||
name: vault | ||
tasks_from: secret_engine.yml | ||
vars: | ||
action: destroy_secret_engine | ||
vault_address: "http://192.168.11.22:8200" | ||
vault_token: "hvs.5XYaP4XJwdV5FqeJpQalQRXr" | ||
vault_name: "lab-marcelvenema-com" | ||
vault_type: "kv" | ||
|
||
|