Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/influxdb_user/tasks/tests.yml

raw
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 - name: Install influxdb python module
7 pip: name=influxdb
8
9 - name: Test add admin user in check mode
10 block:
11 - name: Add admin user
12 influxdb_user: user_name=admin user_password=admin admin=yes
13 check_mode: true
14 register: add_admin_user
15
16 - name: Check that admin user adding succeeds with a change
17 assert:
18 that:
19 - add_admin_user is changed
20
21 - name: Test add admin user
22 block:
23 - name: Add admin user
24 influxdb_user: user_name=admin user_password=admin admin=yes
25 register: add_admin_user
26
27 - name: Check that admin user adding succeeds with a change
28 assert:
29 that:
30 - add_admin_user is changed
31
32 - name: Test add admin user idempotence
33 block:
34 - name: Add admin user
35 influxdb_user: user_name=admin user_password=admin admin=yes
36 register: add_admin_user
37
38 - name: Check that admin user adding succeeds without a change
39 assert:
40 that:
41 - add_admin_user is not changed
42
43 - name: Enable authentication and restart service
44 block:
45 - name: Enable authentication
46 lineinfile:
47 path: /etc/influxdb/influxdb.conf
48 regexp: 'auth-enabled ='
49 line: ' auth-enabled = true'
50
51 - name: Restart InfluxDB service
52 service: name=influxdb state=restarted
53
54 - name: Test add user in check mode when authentication enabled
55 block:
56 - name: Add user
57 influxdb_user: user_name=user user_password=user login_username=admin login_password=admin
58 check_mode: true
59 register: add_user_with_auth_enabled
60
61 - name: Check that adding user with enabled authentication succeeds with a change
62 assert:
63 that:
64 - add_user_with_auth_enabled is changed
65
66 - name: Test add user when authentication enabled
67 block:
68 - name: Add user
69 influxdb_user: user_name=user user_password=user login_username=admin login_password=admin
70 register: add_user_with_auth_enabled
71
72 - name: Check that adding user with enabled authentication succeeds with a change
73 assert:
74 that:
75 - add_user_with_auth_enabled is changed
76
77 - name: Test add user when authentication enabled idempotence
78 block:
79 - name: Add the same user
80 influxdb_user: user_name=user user_password=user login_username=admin login_password=admin
81 register: same_user
82
83 - name: Check that adding same user succeeds without a change
84 assert:
85 that:
86 - same_user is not changed
87
88 - name: Test change user password in check mode
89 block:
90 - name: Change user password
91 influxdb_user: user_name=user user_password=user2 login_username=admin login_password=admin
92 check_mode: true
93 register: change_password
94
95 - name: Check that password changing succeeds with a change
96 assert:
97 that:
98 - change_password is changed
99
100 - name: Test change user password
101 block:
102 - name: Change user password
103 influxdb_user: user_name=user user_password=user2 login_username=admin login_password=admin
104 register: change_password
105
106 - name: Check that password changing succeeds with a change
107 assert:
108 that:
109 - change_password is changed
110
111 - name: Test remove user in check mode
112 block:
113 - name: Remove user
114 influxdb_user: user_name=user state=absent login_username=admin login_password=admin
115 check_mode: true
116 register: remove_user
117
118 - name: Check that removing user succeeds with a change
119 assert:
120 that:
121 - remove_user is changed
122
123 - name: Test remove user
124 block:
125 - name: Remove user
126 influxdb_user: user_name=user state=absent login_username=admin login_password=admin
127 register: remove_user
128
129 - name: Check that removing user succeeds with a change
130 assert:
131 that:
132 - remove_user is changed
133
134 - name: Test remove user idempotence
135 block:
136 - name: Remove user
137 influxdb_user: user_name=user state=absent login_username=admin login_password=admin
138 register: remove_user
139
140 - name: Check that removing user succeeds without a change
141 assert:
142 that:
143 - remove_user is not changed