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