32
32
def ansible_inventory_directory (tmp_path_factory , grains ):
33
33
if grains ["os_family" ] != "RedHat" or grains ["os" ] == "VMware Photon OS" :
34
34
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" )
35
37
tmp_dir = tmp_path_factory .mktemp ("ansible" )
36
38
try :
37
39
yield tmp_dir
@@ -73,12 +75,26 @@ def test_ansible_playbook(salt_call_cli, ansible_inventory, tmp_path):
73
75
---
74
76
- hosts: all
75
77
tasks:
76
- - name: remove postfix
77
- yum :
78
+ - name: remove postfix dnf
79
+ ansible.builtin.dnf :
78
80
name: postfix
79
81
state: absent
80
82
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'
82
98
"""
83
99
)
84
100
remove_playbook = rundir / "remove.yml"
@@ -88,12 +104,26 @@ def test_ansible_playbook(salt_call_cli, ansible_inventory, tmp_path):
88
104
---
89
105
- hosts: all
90
106
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:
93
123
name: postfix
94
124
state: present
95
125
become: true
96
- become_user: root
126
+ when: ansible_pkg_mgr == 'apt'
97
127
"""
98
128
)
99
129
install_playbook = rundir / "install.yml"
0 commit comments