blob: e0456bd6eedaf511227a595846ce25c871aaa694 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
#!/usr/bin/ansible-playbook --module-path=../../../library/
---
- hosts: "{{ cli_master_test }}"
gather_facts: no
user: root
vars_prompt:
- name: cli_master_test
prompt: "Master to run against"
private: false
default: localhost
vars:
secret_name: secret-int-test
ns_name: default
config_path: "/tmp/{{ secret_name }}--config.yml"
passwords_path: "/tmp/{{ secret_name }}--passwords.yml"
post_tasks:
- name: Setup our files to test with
copy:
dest: "{{ item.name }}"
content: "{{ item.content }}"
with_items:
- name: "{{ config_path }}"
content: |
value: True
- name: "{{ passwords_path }}"
content: |
test1
test2
test3
test4
- name: Make sure we're starting with a clean slate
oc_secret:
state: absent
namespace: "{{ ns_name }}"
name: "{{ secret_name }}"
register: secret_out
- name: Test adding a secret - Act
oc_secret:
state: present
namespace: "{{ ns_name }}"
name: "{{ secret_name }}"
files:
- name: config.yml
path: "{{ config_path }}"
- name: passwords.yml
path: "{{ passwords_path }}"
register: secret_out
- name: Test adding a secret - Assert
assert:
that:
- "secret_out.results.returncode == 0"
- "secret_out.changed == True"
- name: Test secret present idempotentcy - Act
oc_secret:
state: present
namespace: "{{ ns_name }}"
name: "{{ secret_name }}"
files:
- name: config.yml
path: "{{ config_path }}"
- name: passwords.yml
path: "{{ passwords_path }}"
register: secret_out
- name: Test secret present idempotentcy - Assert
assert:
that:
- "secret_out.changed == false"
- name: Test list secrets - Act
oc_secret:
state: list
namespace: "{{ ns_name }}"
name: "{{ secret_name }}"
register: secret_out
- name: Test list secrets - Assert
assert:
that:
- "secret_out.changed == false"
- "secret_out.results.exists == true"
- name: Test secret absent - Act
oc_secret:
state: absent
namespace: "{{ ns_name }}"
name: "{{ secret_name }}"
register: secret_out
- name: Test secret absent - Assert
assert:
that:
- "secret_out.changed == true"
- "secret_out.results.returncode == 0"
- name: Test secret absent idempotentcy - Act
oc_secret:
state: absent
namespace: "{{ ns_name }}"
name: "{{ secret_name }}"
register: secret_out
- name: Test secret idempotentcy - Assert
assert:
that:
- "secret_out.changed == false"
- name: Clean up the files we created
file:
state: absent
path: "{{ item }}"
with_items:
- "/tmp/{{ secret_name }}--config.yml"
- "/tmp/{{ secret_name }}--passwords.yml"
|