|
6 | 6 | vars:
|
7 | 7 | # Ansible specific Version or "latest"
|
8 | 8 | ANSIBLE_VERSION: 4.10.0
|
| 9 | + VENV_PATH: /var/tmp/.ansible |
9 | 10 | tasks:
|
10 | 11 | ############## To avoid some issues with cloud-init and unattended upgrades ###############
|
11 | 12 | - name: Avoid unattended upgrades
|
|
99 | 100 | ################### Install Ansible/pip requisites #########################
|
100 | 101 |
|
101 | 102 | - name: Debian/Ubuntu install requisites with apt
|
102 |
| - apt: name=python3-pip,wget,python3-setuptools,python3-psutil,sshpass,openssh-client,unzip install_recommends=no |
| 103 | + apt: name=python3-pip,wget,python3-setuptools,sshpass,openssh-client,unzip install_recommends=no |
103 | 104 | when: ansible_os_family == "Debian"
|
104 | 105 |
|
105 | 106 | - name: Yum install requisites RH 7/8 or Fedora
|
106 |
| - command: yum install -y python3-pip python3-setuptools python3-psutil sshpass openssh-clients |
| 107 | + command: yum install -y python3-pip python3-setuptools sshpass openssh-clients |
107 | 108 | when: ansible_os_family == "RedHat"
|
108 | 109 |
|
109 | 110 | - name: Zypper install requirements Suse
|
110 |
| - zypper: name=python3-pip,python3-setuptools,python3-psutil,wget,python3-cryptography state=present |
| 111 | + zypper: name=python3-pip,python3-setuptools,wget,python3-cryptography state=present |
111 | 112 | when: ansible_os_family == "Suse"
|
112 | 113 |
|
113 | 114 | - name: Install python-setuptools
|
|
116 | 117 |
|
117 | 118 | ######################################### Use pip to enable to set the version #############################################
|
118 | 119 |
|
| 120 | + - name: Set extra_args var |
| 121 | + set_fact: |
| 122 | + extra_args: '' |
| 123 | + |
| 124 | + - name: Set extra_args var in py3.11 |
| 125 | + set_fact: |
| 126 | + extra_args: --break-system-packages |
| 127 | + when: ansible_python_version is version('3.11', '>=') |
| 128 | + |
| 129 | + - name: Install virtualenv with pip |
| 130 | + pip: |
| 131 | + name: virtualenv |
| 132 | + executable: pip3 |
| 133 | + extra_args: "{{ extra_args }}" |
| 134 | + |
119 | 135 | # Version over 21 does not work with python 3.6 or older
|
120 | 136 | - name: Upgrade pip in py3.6-
|
121 | 137 | pip:
|
122 | 138 | name: pip>18.0,<21.0
|
123 |
| - executable: pip3 |
| 139 | + virtualenv: "{{ VENV_PATH }}" |
124 | 140 | # in some old distros we need to trust in the pypi to avoid SSL errors
|
125 | 141 | extra_args: --trusted-host files.pythonhosted.org --trusted-host pypi.org --trusted-host pypi.python.org
|
126 | 142 | when: ansible_python_version is version('3.7', '<')
|
127 | 143 |
|
128 | 144 | - name: Upgrade pip in py3.7-py3.8
|
129 | 145 | pip:
|
130 | 146 | name: pip>20.0
|
131 |
| - executable: pip3 |
| 147 | + virtualenv: "{{ VENV_PATH }}" |
132 | 148 | when: ansible_python_version is version('3.7', '>=') and ansible_python_version is version('3.9', '<')
|
133 | 149 |
|
134 | 150 | - name: Upgrade pip in py3.9-py3.10
|
135 | 151 | pip:
|
136 | 152 | name: pip>=22.0
|
137 |
| - executable: pip3 |
| 153 | + virtualenv: "{{ VENV_PATH }}" |
138 | 154 | when: ansible_python_version is version('3.9', '>=') and ansible_python_version is version('3.11', '<')
|
139 | 155 |
|
140 | 156 | # Version 66 (#2497) fails
|
141 | 157 | - name: Upgrade setuptools with Pip in py3.11-
|
142 | 158 | pip:
|
143 | 159 | name: setuptools<66.0.0
|
144 |
| - executable: pip3 |
| 160 | + virtualenv: "{{ VENV_PATH }}" |
145 | 161 | when: ansible_python_version is version('3.11', '<')
|
146 | 162 |
|
147 | 163 | - name: Set extra_args var
|
148 | 164 | set_fact:
|
149 | 165 | extra_args: --prefer-binary
|
150 | 166 |
|
151 |
| - - name: Set extra_args var in py3.11 |
152 |
| - set_fact: |
153 |
| - extra_args: --prefer-binary --break-system-packages |
154 |
| - when: ansible_python_version is version('3.11', '>=') |
| 167 | + - name: Install psutil |
| 168 | + pip: |
| 169 | + name: psutil |
| 170 | + virtualenv: "{{ VENV_PATH }}" |
| 171 | + extra_args: "{{ extra_args }}" |
155 | 172 |
|
156 | 173 | - name: Install cryptography & pyOpenSSL in py3.11-
|
157 | 174 | pip:
|
158 | 175 | name:
|
159 | 176 | - cryptography>36.0.0,<39.0.0
|
160 | 177 | - pyOpenSSL>20.0,<22.1.0
|
161 |
| - executable: pip3 |
| 178 | + virtualenv: "{{ VENV_PATH }}" |
162 | 179 | extra_args: "{{ extra_args }}"
|
163 | 180 | when: ansible_python_version is version('3.11', '<')
|
164 | 181 |
|
|
167 | 184 | name:
|
168 | 185 | - cryptography>36.0.0
|
169 | 186 | - pyOpenSSL>20.0
|
170 |
| - executable: pip3 |
| 187 | + virtualenv: "{{ VENV_PATH }}" |
171 | 188 | extra_args: "{{ extra_args }}"
|
172 | 189 | when: ansible_python_version is version('3.11', '>=')
|
173 | 190 |
|
|
178 | 195 | - pyyaml
|
179 | 196 | - paramiko>=2.9.5
|
180 | 197 | - packaging
|
181 |
| - executable: pip3 |
| 198 | + virtualenv: "{{ VENV_PATH }}" |
182 | 199 | extra_args: "{{ extra_args }}"
|
183 | 200 |
|
184 | 201 | - name: Set Ansible newer version for python 3.8+
|
|
201 | 218 | pip:
|
202 | 219 | name: ansible
|
203 | 220 | version: "{{ ANSIBLE_VERSION }}"
|
204 |
| - executable: pip3 |
| 221 | + virtualenv: "{{ VENV_PATH }}" |
205 | 222 | extra_args: "{{ extra_args }}"
|
206 | 223 | when: ANSIBLE_VERSION != "latest"
|
207 | 224 |
|
208 | 225 | - name: Install latest ansible version with Pip
|
209 | 226 | pip:
|
210 | 227 | name: ansible
|
211 |
| - executable: pip3 |
| 228 | + virtualenv: "{{ VENV_PATH }}" |
212 | 229 | extra_args: "{{ extra_args }}"
|
213 | 230 | when: ANSIBLE_VERSION == "latest"
|
214 | 231 |
|
|
219 | 236 | name:
|
220 | 237 | - jmespath
|
221 | 238 | - scp
|
222 |
| - executable: pip3 |
| 239 | + virtualenv: "{{ VENV_PATH }}" |
223 | 240 | extra_args: "{{ extra_args }}"
|
224 | 241 |
|
225 | 242 | - name: Install pywinrm with Pip
|
226 | 243 | pip:
|
227 | 244 | name: pywinrm
|
228 |
| - executable: pip3 |
| 245 | + virtualenv: "{{ VENV_PATH }}" |
229 | 246 | extra_args: "{{ extra_args }}"
|
230 | 247 | ignore_errors: yes
|
231 | 248 |
|
|
0 commit comments