|
|
01db47 |
From e96ef4e98e523f20c25777308c093ebbff272b2d Mon Sep 17 00:00:00 2001
|
|
|
01db47 |
From: Rafael Guterres Jeffman <rjeffman@redhat.com>
|
|
|
01db47 |
Date: Wed, 5 Aug 2020 15:24:15 -0300
|
|
|
01db47 |
Subject: [PATCH] Updated documentation for ipavault module in the source code.
|
|
|
01db47 |
|
|
|
01db47 |
This change fixes a wrong parameter name in the documentation of
|
|
|
01db47 |
RESULT_VALUES, and also provide a correct YAML snippet to ensure
|
|
|
01db47 |
presence of an asymmetric vault with a formatted private key.
|
|
|
01db47 |
---
|
|
|
01db47 |
plugins/modules/ipavault.py | 4 ++--
|
|
|
01db47 |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
01db47 |
|
|
|
01db47 |
diff --git a/plugins/modules/ipavault.py b/plugins/modules/ipavault.py
|
|
|
01db47 |
index 46c6fcd..84645c7 100644
|
|
|
01db47 |
--- a/plugins/modules/ipavault.py
|
|
|
01db47 |
+++ b/plugins/modules/ipavault.py
|
|
|
01db47 |
@@ -267,7 +267,7 @@ EXAMPLES = """
|
|
|
01db47 |
username: user01
|
|
|
01db47 |
description: An asymmetric vault
|
|
|
01db47 |
vault_type: asymmetric
|
|
|
01db47 |
- public_key:
|
|
|
01db47 |
+ public_key: |
|
|
|
01db47 |
LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlHZk1BMEdDU3FHU0liM0RRRUJBUVVBQTR
|
|
|
01db47 |
HTkFEQ0JpUUtCZ1FDdGFudjRkK3ptSTZ0T3ova1RXdGowY3AxRAowUENoYy8vR0pJMTUzTi
|
|
|
01db47 |
9CN3UrN0h3SXlRVlZoNUlXZG1UcCtkWXYzd09yeVpPbzYvbHN5eFJaZ2pZRDRwQ3VGCjlxM
|
|
|
01db47 |
@@ -303,7 +303,7 @@ EXAMPLES = """
|
|
|
01db47 |
"""
|
|
|
01db47 |
|
|
|
01db47 |
RETURN = """
|
|
|
01db47 |
-user:
|
|
|
01db47 |
+data:
|
|
|
01db47 |
description: The vault data.
|
|
|
01db47 |
returned: If state is retrieved.
|
|
|
01db47 |
type: string
|
|
|
01db47 |
--
|
|
|
01db47 |
2.26.2
|
|
|
01db47 |
|
|
|
01db47 |
From 7dd0b547c47b4fd617960490b8553a5036e3b30c Mon Sep 17 00:00:00 2001
|
|
|
01db47 |
From: Rafael Guterres Jeffman <rjeffman@redhat.com>
|
|
|
01db47 |
Date: Mon, 10 Aug 2020 16:02:09 -0300
|
|
|
01db47 |
Subject: [PATCH] Modified return value for ipavault module.
|
|
|
01db47 |
|
|
|
01db47 |
The ipavault module was returning a single string value when retrieving
|
|
|
01db47 |
data. To keep consistency with other modules, it should return a dict
|
|
|
01db47 |
with the `data` variable in it.
|
|
|
01db47 |
|
|
|
01db47 |
This change modifies the result of ipavault to be a dict and also fixes
|
|
|
01db47 |
relevant tests, examples and documentation.
|
|
|
01db47 |
---
|
|
|
01db47 |
README-vault.md | 5 +++++
|
|
|
01db47 |
.../vault/retrive-data-asymmetric-vault.yml | 2 +-
|
|
|
01db47 |
.../vault/retrive-data-symmetric-vault.yml | 2 +-
|
|
|
01db47 |
plugins/modules/ipavault.py | 19 +++++++++++++------
|
|
|
01db47 |
tests/vault/test_vault_asymmetric.yml | 12 ++++++------
|
|
|
01db47 |
tests/vault/test_vault_standard.yml | 8 ++++----
|
|
|
01db47 |
tests/vault/test_vault_symmetric.yml | 14 +++++++-------
|
|
|
01db47 |
7 files changed, 37 insertions(+), 25 deletions(-)
|
|
|
01db47 |
|
|
|
01db47 |
diff --git a/README-vault.md b/README-vault.md
|
|
|
01db47 |
index fa1d3e1..91d311d 100644
|
|
|
01db47 |
--- a/README-vault.md
|
|
|
01db47 |
+++ b/README-vault.md
|
|
|
01db47 |
@@ -248,6 +248,11 @@ Variable | Description | Returned When
|
|
|
01db47 |
-------- | ----------- | -------------
|
|
|
01db47 |
`data` | The data stored in the vault. | If `state` is `retrieved`.
|
|
|
01db47 |
|
|
|
01db47 |
+Variable | Description | Returned When
|
|
|
01db47 |
+-------- | ----------- | -------------
|
|
|
01db47 |
+`vault` | Vault dict with archived data. (dict) Options: | If `state` is `retrieved`.
|
|
|
01db47 |
+ | `data` - The vault data. | Always
|
|
|
01db47 |
+
|
|
|
01db47 |
|
|
|
01db47 |
Notes
|
|
|
01db47 |
=====
|
|
|
01db47 |
diff --git a/playbooks/vault/retrive-data-asymmetric-vault.yml b/playbooks/vault/retrive-data-asymmetric-vault.yml
|
|
|
01db47 |
index 5f67c59..f71f826 100644
|
|
|
01db47 |
--- a/playbooks/vault/retrive-data-asymmetric-vault.yml
|
|
|
01db47 |
+++ b/playbooks/vault/retrive-data-asymmetric-vault.yml
|
|
|
01db47 |
@@ -14,4 +14,4 @@
|
|
|
01db47 |
state: retrieved
|
|
|
01db47 |
register: result
|
|
|
01db47 |
- debug:
|
|
|
01db47 |
- msg: "Data: {{ result.data }}"
|
|
|
01db47 |
+ msg: "Data: {{ result.vault.data }}"
|
|
|
01db47 |
diff --git a/playbooks/vault/retrive-data-symmetric-vault.yml b/playbooks/vault/retrive-data-symmetric-vault.yml
|
|
|
01db47 |
index 163f8b9..24692a8 100644
|
|
|
01db47 |
--- a/playbooks/vault/retrive-data-symmetric-vault.yml
|
|
|
01db47 |
+++ b/playbooks/vault/retrive-data-symmetric-vault.yml
|
|
|
01db47 |
@@ -14,4 +14,4 @@
|
|
|
01db47 |
state: retrieved
|
|
|
01db47 |
register: result
|
|
|
01db47 |
- debug:
|
|
|
01db47 |
- msg: "{{ result.data | b64decode }}"
|
|
|
01db47 |
+ msg: "{{ result.vault.data }}"
|
|
|
01db47 |
diff --git a/plugins/modules/ipavault.py b/plugins/modules/ipavault.py
|
|
|
01db47 |
index 84645c7..6a3c73e 100644
|
|
|
01db47 |
--- a/plugins/modules/ipavault.py
|
|
|
01db47 |
+++ b/plugins/modules/ipavault.py
|
|
|
01db47 |
@@ -303,10 +303,15 @@ EXAMPLES = """
|
|
|
01db47 |
"""
|
|
|
01db47 |
|
|
|
01db47 |
RETURN = """
|
|
|
01db47 |
-data:
|
|
|
01db47 |
- description: The vault data.
|
|
|
01db47 |
- returned: If state is retrieved.
|
|
|
01db47 |
- type: string
|
|
|
01db47 |
+vault:
|
|
|
01db47 |
+ description: Vault dict with archived data.
|
|
|
01db47 |
+ returned: If state is `retrieved`.
|
|
|
01db47 |
+ type: dict
|
|
|
01db47 |
+ options:
|
|
|
01db47 |
+ data:
|
|
|
01db47 |
+ description: The vault data.
|
|
|
01db47 |
+ returned: always
|
|
|
01db47 |
+ type: string
|
|
|
01db47 |
"""
|
|
|
01db47 |
|
|
|
01db47 |
import os
|
|
|
01db47 |
@@ -910,9 +915,11 @@ def main():
|
|
|
01db47 |
if 'result' not in result:
|
|
|
01db47 |
raise Exception("No result obtained.")
|
|
|
01db47 |
if 'data' in result['result']:
|
|
|
01db47 |
- exit_args['data'] = result['result']['data']
|
|
|
01db47 |
+ data_return = exit_args.setdefault('vault', {})
|
|
|
01db47 |
+ data_return['data'] = result['result']['data']
|
|
|
01db47 |
elif 'vault_data' in result['result']:
|
|
|
01db47 |
- exit_args['data'] = result['result']['vault_data']
|
|
|
01db47 |
+ data_return = exit_args.setdefault('vault', {})
|
|
|
01db47 |
+ data_return['data'] = result['result']['vault_data']
|
|
|
01db47 |
else:
|
|
|
01db47 |
raise Exception("No data retrieved.")
|
|
|
01db47 |
changed = False
|
|
|
01db47 |
diff --git a/tests/vault/test_vault_asymmetric.yml b/tests/vault/test_vault_asymmetric.yml
|
|
|
01db47 |
index 1a1d3dc..268922c 100644
|
|
|
01db47 |
--- a/tests/vault/test_vault_asymmetric.yml
|
|
|
01db47 |
+++ b/tests/vault/test_vault_asymmetric.yml
|
|
|
01db47 |
@@ -42,7 +42,7 @@
|
|
|
01db47 |
private_key: "{{ lookup('file', 'private.pem') | b64encode }}"
|
|
|
01db47 |
state: retrieved
|
|
|
01db47 |
register: result
|
|
|
01db47 |
- failed_when: result.data != 'Hello World.' or result.changed
|
|
|
01db47 |
+ failed_when: result.vault.data != 'Hello World.' or result.changed
|
|
|
01db47 |
|
|
|
01db47 |
- name: Retrieve data from asymmetric vault into file {{ ansible_env.HOME }}/data.txt.
|
|
|
01db47 |
ipavault:
|
|
|
01db47 |
@@ -75,7 +75,7 @@
|
|
|
01db47 |
private_key: "{{ lookup('file', 'private.pem') | b64encode }}"
|
|
|
01db47 |
state: retrieved
|
|
|
01db47 |
register: result
|
|
|
01db47 |
- failed_when: result.data != 'The world of π is half rounded.' or result.changed
|
|
|
01db47 |
+ failed_when: result.vault.data != 'The world of π is half rounded.' or result.changed
|
|
|
01db47 |
|
|
|
01db47 |
- name: Archive data in asymmetric vault, from file.
|
|
|
01db47 |
ipavault:
|
|
|
01db47 |
@@ -93,7 +93,7 @@
|
|
|
01db47 |
private_key: "{{ lookup('file', 'private.pem') | b64encode }}"
|
|
|
01db47 |
state: retrieved
|
|
|
01db47 |
register: result
|
|
|
01db47 |
- failed_when: result.data != 'Another World.' or result.changed
|
|
|
01db47 |
+ failed_when: result.vault.data != 'Another World.' or result.changed
|
|
|
01db47 |
|
|
|
01db47 |
- name: Archive data with single character to asymmetric vault
|
|
|
01db47 |
ipavault:
|
|
|
01db47 |
@@ -110,7 +110,7 @@
|
|
|
01db47 |
private_key: "{{ lookup('file', 'private.pem') | b64encode }}"
|
|
|
01db47 |
state: retrieved
|
|
|
01db47 |
register: result
|
|
|
01db47 |
- failed_when: result.data != 'c' or result.changed
|
|
|
01db47 |
+ failed_when: result.vault.data != 'c' or result.changed
|
|
|
01db47 |
|
|
|
01db47 |
- name: Ensure asymmetric vault is absent
|
|
|
01db47 |
ipavault:
|
|
|
01db47 |
@@ -161,7 +161,7 @@
|
|
|
01db47 |
private_key: "{{ lookup('file', 'private.pem') | b64encode }}"
|
|
|
01db47 |
state: retrieved
|
|
|
01db47 |
register: result
|
|
|
01db47 |
- failed_when: result.data != 'Hello World.' or result.changed
|
|
|
01db47 |
+ failed_when: result.vault.data != 'Hello World.' or result.changed
|
|
|
01db47 |
|
|
|
01db47 |
- name: Retrieve data from asymmetric vault, with password file.
|
|
|
01db47 |
ipavault:
|
|
|
01db47 |
@@ -170,7 +170,7 @@
|
|
|
01db47 |
private_key_file: "{{ ansible_env.HOME }}/private.pem"
|
|
|
01db47 |
state: retrieved
|
|
|
01db47 |
register: result
|
|
|
01db47 |
- failed_when: result.data != 'Hello World.' or result.changed
|
|
|
01db47 |
+ failed_when: result.vault.data != 'Hello World.' or result.changed
|
|
|
01db47 |
|
|
|
01db47 |
- name: Ensure asymmetric vault is absent
|
|
|
01db47 |
ipavault:
|
|
|
01db47 |
diff --git a/tests/vault/test_vault_standard.yml b/tests/vault/test_vault_standard.yml
|
|
|
01db47 |
index 5e0da98..6ccb0d5 100644
|
|
|
01db47 |
--- a/tests/vault/test_vault_standard.yml
|
|
|
01db47 |
+++ b/tests/vault/test_vault_standard.yml
|
|
|
01db47 |
@@ -39,7 +39,7 @@
|
|
|
01db47 |
name: stdvault
|
|
|
01db47 |
state: retrieved
|
|
|
01db47 |
register: result
|
|
|
01db47 |
- failed_when: result.data != 'Hello World.' or result.changed
|
|
|
01db47 |
+ failed_when: result.vault.data != 'Hello World.' or result.changed
|
|
|
01db47 |
|
|
|
01db47 |
- name: Retrieve data from standard vault into file {{ ansible_env.HOME }}/data.txt.
|
|
|
01db47 |
ipavault:
|
|
|
01db47 |
@@ -70,7 +70,7 @@
|
|
|
01db47 |
name: stdvault
|
|
|
01db47 |
state: retrieved
|
|
|
01db47 |
register: result
|
|
|
01db47 |
- failed_when: result.data != 'The world of π is half rounded.' or result.changed
|
|
|
01db47 |
+ failed_when: result.vault.data != 'The world of π is half rounded.' or result.changed
|
|
|
01db47 |
|
|
|
01db47 |
- name: Archive data in standard vault, from file.
|
|
|
01db47 |
ipavault:
|
|
|
01db47 |
@@ -87,7 +87,7 @@
|
|
|
01db47 |
name: stdvault
|
|
|
01db47 |
state: retrieved
|
|
|
01db47 |
register: result
|
|
|
01db47 |
- failed_when: result.data != 'Another World.' or result.changed
|
|
|
01db47 |
+ failed_when: result.vault.data != 'Another World.' or result.changed
|
|
|
01db47 |
|
|
|
01db47 |
- name: Archive data with single character to standard vault
|
|
|
01db47 |
ipavault:
|
|
|
01db47 |
@@ -103,7 +103,7 @@
|
|
|
01db47 |
name: stdvault
|
|
|
01db47 |
state: retrieved
|
|
|
01db47 |
register: result
|
|
|
01db47 |
- failed_when: result.data != 'c' or result.changed
|
|
|
01db47 |
+ failed_when: result.vault.data != 'c' or result.changed
|
|
|
01db47 |
|
|
|
01db47 |
- name: Ensure standard vault is absent
|
|
|
01db47 |
ipavault:
|
|
|
01db47 |
diff --git a/tests/vault/test_vault_symmetric.yml b/tests/vault/test_vault_symmetric.yml
|
|
|
01db47 |
index a6072d8..bedc221 100644
|
|
|
01db47 |
--- a/tests/vault/test_vault_symmetric.yml
|
|
|
01db47 |
+++ b/tests/vault/test_vault_symmetric.yml
|
|
|
01db47 |
@@ -43,7 +43,7 @@
|
|
|
01db47 |
password: SomeVAULTpassword
|
|
|
01db47 |
state: retrieved
|
|
|
01db47 |
register: result
|
|
|
01db47 |
- failed_when: result.data != 'Hello World.' or result.changed
|
|
|
01db47 |
+ failed_when: result.vault.data != 'Hello World.' or result.changed
|
|
|
01db47 |
|
|
|
01db47 |
- name: Retrieve data from symmetric vault into file {{ ansible_env.HOME }}/data.txt.
|
|
|
01db47 |
ipavault:
|
|
|
01db47 |
@@ -77,7 +77,7 @@
|
|
|
01db47 |
password: SomeVAULTpassword
|
|
|
01db47 |
state: retrieved
|
|
|
01db47 |
register: result
|
|
|
01db47 |
- failed_when: result.data != 'The world of π is half rounded.' or result.changed
|
|
|
01db47 |
+ failed_when: result.vault.data != 'The world of π is half rounded.' or result.changed
|
|
|
01db47 |
|
|
|
01db47 |
- name: Archive data in symmetric vault, from file.
|
|
|
01db47 |
ipavault:
|
|
|
01db47 |
@@ -95,7 +95,7 @@
|
|
|
01db47 |
password: SomeVAULTpassword
|
|
|
01db47 |
state: retrieved
|
|
|
01db47 |
register: result
|
|
|
01db47 |
- failed_when: result.data != 'Another World.' or result.changed
|
|
|
01db47 |
+ failed_when: result.vault.data != 'Another World.' or result.changed
|
|
|
01db47 |
|
|
|
01db47 |
- name: Archive data with single character to symmetric vault
|
|
|
01db47 |
ipavault:
|
|
|
01db47 |
@@ -113,7 +113,7 @@
|
|
|
01db47 |
password: SomeVAULTpassword
|
|
|
01db47 |
state: retrieved
|
|
|
01db47 |
register: result
|
|
|
01db47 |
- failed_when: result.data != 'c' or result.changed
|
|
|
01db47 |
+ failed_when: result.vault.data != 'c' or result.changed
|
|
|
01db47 |
|
|
|
01db47 |
- name: Ensure symmetric vault is absent
|
|
|
01db47 |
ipavault:
|
|
|
01db47 |
@@ -167,7 +167,7 @@
|
|
|
01db47 |
password: SomeVAULTpassword
|
|
|
01db47 |
state: retrieved
|
|
|
01db47 |
register: result
|
|
|
01db47 |
- failed_when: result.data != 'Hello World.' or result.changed
|
|
|
01db47 |
+ failed_when: result.vault.data != 'Hello World.' or result.changed
|
|
|
01db47 |
|
|
|
01db47 |
- name: Retrieve data from symmetric vault, with password file.
|
|
|
01db47 |
ipavault:
|
|
|
01db47 |
@@ -176,7 +176,7 @@
|
|
|
01db47 |
password_file: "{{ ansible_env.HOME }}/password.txt"
|
|
|
01db47 |
state: retrieved
|
|
|
01db47 |
register: result
|
|
|
01db47 |
- failed_when: result.data != 'Hello World.' or result.changed
|
|
|
01db47 |
+ failed_when: result.vault.data != 'Hello World.' or result.changed
|
|
|
01db47 |
|
|
|
01db47 |
- name: Change vault password.
|
|
|
01db47 |
ipavault:
|
|
|
01db47 |
@@ -212,7 +212,7 @@
|
|
|
01db47 |
password: SomeNEWpassword
|
|
|
01db47 |
state: retrieved
|
|
|
01db47 |
register: result
|
|
|
01db47 |
- failed_when: result.data != 'Hello World.' or result.changed
|
|
|
01db47 |
+ failed_when: result.vault.data != 'Hello World.' or result.changed
|
|
|
01db47 |
|
|
|
01db47 |
- name: Try to add vault with multiple passwords.
|
|
|
01db47 |
ipavault:
|
|
|
01db47 |
--
|
|
|
01db47 |
2.26.2
|
|
|
01db47 |
|