Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/ejabberd_user/tasks/main.yml

raw
1 ---
2 ####################################################################
3 # WARNING: These are designed specifically for Ansible tests #
4 # and should not be used as examples of how to write Ansible roles #
5 ####################################################################
6
7 # Copyright (c) Ansible Project
8 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
9 # SPDX-License-Identifier: GPL-3.0-or-later
10
11 - name: Bail out if not supported
12 ansible.builtin.meta: end_play
13 # TODO: remove Archlinux from the list
14 # TODO: remove Ubuntu 24.04 or newer from the list
15 # TODO: remove Debian 13 (Trixie) from the list
16 when: >
17 ansible_facts.distribution in ('Alpine', 'openSUSE Leap', 'CentOS', 'Fedora', 'Archlinux')
18 or (ansible_facts.distribution == 'Ubuntu' and ansible_facts.distribution_major_version | int >= 24)
19 or (ansible_facts.distribution == 'Debian' and ansible_facts.distribution_major_version == '13')
20
21 - name: Remove ejabberd
22 ansible.builtin.package:
23 name: ejabberd
24 state: absent
25
26 - name: Create user without ejabberdctl installed
27 community.general.ejabberd_user:
28 host: localhost
29 username: alice
30 password: pa$$w0rd
31 state: present
32 register: user_no_ejabberdctl
33 ignore_errors: true
34
35 - name: Install ejabberd
36 ansible.builtin.package:
37 name: ejabberd
38 state: present
39 notify: Remove ejabberd
40
41 - name: Make runnable on Arch
42 community.general.ini_file:
43 path: /usr/lib/systemd/system/ejabberd.service
44 section: Service
45 option: "{{ item }}"
46 state: absent
47 loop:
48 - PrivateDevices
49 - AmbientCapabilities
50 when: ansible_facts.distribution == 'Archlinux'
51
52 - name: Make installable on Arch
53 systemd:
54 daemon_reload: true
55 when: ansible_facts.distribution == 'Archlinux'
56
57 - ansible.builtin.service:
58 name: ejabberd
59 state: started
60
61 - name: Create user alice (check)
62 community.general.ejabberd_user:
63 host: localhost
64 username: alice
65 password: pa$$w0rd
66 state: present
67 check_mode: true
68 register: user_alice_check
69
70 - name: Create user alice
71 community.general.ejabberd_user:
72 host: localhost
73 username: alice
74 password: pa$$w0rd
75 state: present
76 register: user_alice
77
78 - name: Create user alice (idempotency)
79 community.general.ejabberd_user:
80 host: localhost
81 username: alice
82 password: pa$$w0rd
83 state: present
84 register: user_alice_idempot
85
86 - name: Create user alice (change password)
87 community.general.ejabberd_user:
88 host: localhost
89 username: alice
90 password: different_pa$$w0rd
91 state: present
92 register: user_alice_chgpw
93
94 - name: Remove user alice (check)
95 community.general.ejabberd_user:
96 host: localhost
97 username: alice
98 state: absent
99 register: remove_alice_check
100 check_mode: true
101
102 - name: Remove user alice
103 community.general.ejabberd_user:
104 host: localhost
105 username: alice
106 state: absent
107 register: remove_alice
108
109 - name: Remove user alice (idempotency)
110 community.general.ejabberd_user:
111 host: localhost
112 username: alice
113 state: absent
114 register: remove_alice_idempot
115
116 - name: Assertions
117 ansible.builtin.assert:
118 that:
119 - user_no_ejabberdctl is failed
120 - "'Failed to find required executable' in user_no_ejabberdctl.msg"
121 - user_alice_check is changed
122 - user_alice is changed
123 - user_alice_idempot is not changed
124 - user_alice_chgpw is changed
125 - remove_alice_check is changed
126 - remove_alice is changed
127 - remove_alice_idempot is not changed