Merge branch 'rc-5.0-demo' of ssh://git.digitalenergy.online:2221/rudecs/decort-ansible into rc-5.0-demo
commit
dd28084b76
@ -0,0 +1,14 @@
|
||||
---
|
||||
#
|
||||
# This playbook create engine "test".
|
||||
#
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- hashivault_secret_engine:
|
||||
url: "https://vault.domain.local"
|
||||
authtype: ldap
|
||||
username: "user"
|
||||
password: "p@ssword"
|
||||
state: present
|
||||
name: test
|
||||
backend: generic
|
@ -0,0 +1,17 @@
|
||||
---
|
||||
#
|
||||
# This playbook create secret "secret" with data foo:foe. If secret "secret" exists - add data foo:foe.
|
||||
#
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- hashivault_secret:
|
||||
url: "https://vault.domain.local"
|
||||
authtype: ldap
|
||||
username: "user"
|
||||
password: "p@ssword"
|
||||
mount_point: "kv"
|
||||
state: present
|
||||
permanent: true
|
||||
secret: secret
|
||||
data:
|
||||
foo: foe
|
@ -0,0 +1,35 @@
|
||||
---
|
||||
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- hashivault_read:
|
||||
url: "https://vault.domain.local"
|
||||
authtype: ldap
|
||||
username: "user"
|
||||
password: "p@ssword"
|
||||
mount_point: kv
|
||||
secret: secrets/myaccount
|
||||
key: app_secret
|
||||
version: 2
|
||||
register: key
|
||||
|
||||
- name: create a VM using app_secret from hashicorp vault
|
||||
decort_kvmvm:
|
||||
annotation: "VM managed by decort_kvmvm module"
|
||||
authenticator: oauth2
|
||||
app_id: "" # Application id from SSO Digital Energy
|
||||
app_secret: "{{ key }}" # API key from SSO Digital Energy
|
||||
controller_url: "https://cloud.digitalenergy.online"
|
||||
name: hashivault_read_example
|
||||
cpu: 2
|
||||
ram: 2048
|
||||
boot_disk: 10
|
||||
image_name: "DECS Ubuntu 18.04 v1.2.3" #Name of OS image
|
||||
networks:
|
||||
- type: VINS
|
||||
id: 99 #VINS id
|
||||
tags: "Ansible hashivault_read example"
|
||||
state: present
|
||||
rg_id: 99 #Resource group id
|
||||
delegate_to: localhost
|
||||
register: simple_vm
|
@ -0,0 +1,31 @@
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Read a kv2 secret with kv mount point
|
||||
vars:
|
||||
ansible_hashi_vault_auth_method: ldap
|
||||
ansible_hashi_vault_username: username
|
||||
ansible_hashi_vault_password: pwd
|
||||
ansible_hashi_vault_engine_mount_point: kv
|
||||
ansible.builtin.set_fact:
|
||||
response: "{{ lookup('community.hashi_vault.vault_kv2_get', 'secret', url='https://vault.domain.local') }}"
|
||||
|
||||
- name: create a VM using app_secret from hashicorp vault
|
||||
decort_kvmvm:
|
||||
annotation: "VM managed by decort_kvmvm module"
|
||||
authenticator: oauth2
|
||||
app_id: "" # Application id from SSO Digital Energy
|
||||
app_secret: "{{ response.data.password }}" # API key from SSO Digital Energy
|
||||
controller_url: "https://cloud.digitalenergy.online"
|
||||
name: hashivault_read_example
|
||||
cpu: 2
|
||||
ram: 2048
|
||||
boot_disk: 10
|
||||
image_name: "DECS Ubuntu 18.04 v1.2.3" #Name of OS image
|
||||
networks:
|
||||
- type: VINS
|
||||
id: 99 #VINS id
|
||||
tags: "Ansible hashivault_read example"
|
||||
state: present
|
||||
rg_id: 99 #Resource group id
|
||||
delegate_to: localhost
|
||||
register: simple_vm
|
@ -0,0 +1,16 @@
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Get auth token from vault
|
||||
set_fact:
|
||||
login_data: "{{ lookup('community.hashi_vault.vault_login', url='https://vault.domain.local', auth_method='ldap', username='username', password='pwd') }}"
|
||||
|
||||
- name: Perform multiple kv2 reads with a single Vault login, showing the secrets
|
||||
vars:
|
||||
ansible_hashi_vault_auth_method: token
|
||||
ansible_hashi_vault_token: '{{ login_data | community.hashi_vault.vault_login_token }}'
|
||||
ansible_hashi_vault_engine_mount_point: kv
|
||||
paths:
|
||||
- secret
|
||||
- secret2
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('community.hashi_vault.vault_kv2_get', *paths, auth_method='token', url='https://vault.domain.local') }}"
|
@ -0,0 +1,18 @@
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Read a kv2 secret with the default mount point
|
||||
vars:
|
||||
ansible_hashi_vault_auth_method: ldap
|
||||
ansible_hashi_vault_username: username
|
||||
ansible_hashi_vault_password: pwd
|
||||
ansible_hashi_vault_engine_mount_point: kv
|
||||
ansible.builtin.set_fact:
|
||||
response: "{{ lookup('community.hashi_vault.vault_kv2_get', 'secret', url='https://vault.domain.local') }}"
|
||||
|
||||
- name: Display the results
|
||||
ansible.builtin.debug:
|
||||
msg:
|
||||
- "Secret: {{ response.secret }}"
|
||||
- "Data: {{ response.data }} (contains secret data & metadata in kv2)"
|
||||
- "Metadata: {{ response.metadata }}"
|
||||
- "Full response: {{ response.raw }}"
|
@ -0,0 +1,13 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- hashivault_read:
|
||||
url: "https://vault.domain.local"
|
||||
authtype: ldap
|
||||
username: "uset"
|
||||
password: "p@ssword"
|
||||
mount_point: kv
|
||||
secret: secret
|
||||
key: foo
|
||||
version: 2
|
||||
register: key
|
@ -0,0 +1,42 @@
|
||||
---
|
||||
#
|
||||
# DECORT vins module example
|
||||
#
|
||||
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: obtain JWT
|
||||
decort_jwt:
|
||||
oauth2_url: "https://sso.digitalenergy.online"
|
||||
validity: 1200
|
||||
register: my_jwt
|
||||
delegate_to: localhost
|
||||
|
||||
- name: print out JWT
|
||||
debug:
|
||||
var: my_jwt.jwt
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Manage ViNS at resource group level
|
||||
decort_vins:
|
||||
authenticator: jwt
|
||||
jwt: "{{ my_jwt.jwt }}"
|
||||
controller_url: "https://cloud.digitalenergy.online"
|
||||
vins_name: "vins_connected_by_decort_vins_module"
|
||||
state: present
|
||||
rg_id: 98
|
||||
connect_to:
|
||||
- type: VINS
|
||||
id: 864
|
||||
ipaddr: 192.168.5.66
|
||||
netmask: 24
|
||||
- type: VINS
|
||||
id: 196
|
||||
ipaddr: 192.168.9.133
|
||||
netmask: 24
|
||||
register: managed_vins
|
||||
|
||||
- name: print VINS facter
|
||||
debug:
|
||||
msg: "{{managed_vins.facts.password}}"
|
||||
when: managed_vins.facts.password is defined
|
Loading…
Reference in new issue