Skip to content

Commit 7d7813a

Browse files
committed
Fix ansible tests
1 parent 5ecbdeb commit 7d7813a

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

tests/pytests/integration/states/test_ansiblegate.py

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
def ansible_inventory_directory(tmp_path_factory, grains):
3333
if grains["os_family"] != "RedHat" or grains["os"] == "VMware Photon OS":
3434
pytest.skip("Currently, the test targets the RedHat OS familly only.")
35+
if grains["os"] == "Rocky" and grains["osmajorrelease"] == 8:
36+
pytest.skip("ansible-core doesn't support dnf on Rocky Linux 8")
3537
tmp_dir = tmp_path_factory.mktemp("ansible")
3638
try:
3739
yield tmp_dir
@@ -73,12 +75,26 @@ def test_ansible_playbook(salt_call_cli, ansible_inventory, tmp_path):
7375
---
7476
- hosts: all
7577
tasks:
76-
- name: remove postfix
77-
yum:
78+
- name: remove postfix dnf
79+
ansible.builtin.dnf:
7880
name: postfix
7981
state: absent
8082
become: true
81-
become_user: root
83+
when: ansible_pkg_mgr == 'dnf'
84+
85+
- name: remove postfix yum
86+
ansible.builtin.yum:
87+
name: postfix
88+
state: absent
89+
become: true
90+
when: ansible_pkg_mgr == 'yum'
91+
92+
- name: remove postfix apt
93+
ansible.builtin.apt:
94+
name: postfix
95+
state: absent
96+
become: true
97+
when: ansible_pkg_mgr == 'apt'
8298
"""
8399
)
84100
remove_playbook = rundir / "remove.yml"
@@ -88,12 +104,26 @@ def test_ansible_playbook(salt_call_cli, ansible_inventory, tmp_path):
88104
---
89105
- hosts: all
90106
tasks:
91-
- name: install postfix
92-
yum:
107+
- name: install postfix dnf
108+
ansible.builtin.dnf:
109+
name: postfix
110+
state: present
111+
become: true
112+
when: ansible_pkg_mgr == 'dnf'
113+
114+
- name: install postfix yum
115+
ansible.builtin.yum:
116+
name: postfix
117+
state: present
118+
become: true
119+
when: ansible_pkg_mgr == 'yum'
120+
121+
- name: install postfix apt
122+
ansible.builtin.apt:
93123
name: postfix
94124
state: present
95125
become: true
96-
become_user: root
126+
when: ansible_pkg_mgr == 'apt'
97127
"""
98128
)
99129
install_playbook = rundir / "install.yml"

0 commit comments

Comments
 (0)