Skip to content

Commit d36c0a0

Browse files
committed
Fix ansible tests
1 parent 5ecbdeb commit d36c0a0

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

tests/pytests/integration/states/test_ansiblegate.py

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import logging
6+
import os
67
import shutil
78
import textwrap
89

@@ -32,6 +33,8 @@
3233
def ansible_inventory_directory(tmp_path_factory, grains):
3334
if grains["os_family"] != "RedHat" or grains["os"] == "VMware Photon OS":
3435
pytest.skip("Currently, the test targets the RedHat OS familly only.")
36+
if grains["os"] == "Rocky" and grains["osmajorrelease"] == 8:
37+
pytest.skip("ansible-core doesn't support dnf on Rocky Linux 8")
3538
tmp_dir = tmp_path_factory.mktemp("ansible")
3639
try:
3740
yield tmp_dir
@@ -73,12 +76,26 @@ def test_ansible_playbook(salt_call_cli, ansible_inventory, tmp_path):
7376
---
7477
- hosts: all
7578
tasks:
76-
- name: remove postfix
77-
yum:
79+
- name: remove postfix dnf
80+
ansible.builtin.dnf:
7881
name: postfix
7982
state: absent
8083
become: true
81-
become_user: root
84+
when: ansible_pkg_mgr == 'dnf'
85+
86+
- name: remove postfix yum
87+
ansible.builtin.yum:
88+
name: postfix
89+
state: absent
90+
become: true
91+
when: ansible_pkg_mgr == 'yum'
92+
93+
- name: remove postfix apt
94+
ansible.builtin.apt:
95+
name: postfix
96+
state: absent
97+
become: true
98+
when: ansible_pkg_mgr == 'apt'
8299
"""
83100
)
84101
remove_playbook = rundir / "remove.yml"
@@ -88,12 +105,26 @@ def test_ansible_playbook(salt_call_cli, ansible_inventory, tmp_path):
88105
---
89106
- hosts: all
90107
tasks:
91-
- name: install postfix
92-
yum:
108+
- name: install postfix dnf
109+
ansible.builtin.dnf:
110+
name: postfix
111+
state: present
112+
become: true
113+
when: ansible_pkg_mgr == 'dnf'
114+
115+
- name: install postfix yum
116+
ansible.builtin.yum:
117+
name: postfix
118+
state: present
119+
become: true
120+
when: ansible_pkg_mgr == 'yum'
121+
122+
- name: install postfix apt
123+
ansible.builtin.apt:
93124
name: postfix
94125
state: present
95126
become: true
96-
become_user: root
127+
when: ansible_pkg_mgr == 'apt'
97128
"""
98129
)
99130
install_playbook = rundir / "install.yml"

0 commit comments

Comments
 (0)