|
69 | 69 |
|
70 | 70 | - block: |
71 | 71 | - name: Install necessary packages |
72 | | - apt: pkg={{ item }} update_cache=yes cache_valid_time=86400 |
73 | | - become: yes |
| 72 | + apt: |
| 73 | + update_cache: yes |
| 74 | + cache_valid_time: 86400 |
| 75 | + pkg: |
| 76 | + - ifupdown |
| 77 | + - openvswitch-switch |
| 78 | + - net-tools |
| 79 | + - bridge-utils |
| 80 | + - util-linux |
| 81 | + - iproute2 |
| 82 | + - vlan |
| 83 | + - apt-transport-https |
| 84 | + - ca-certificates |
| 85 | + - curl |
| 86 | + - software-properties-common |
| 87 | + - libvirt-clients |
74 | 88 | register: apt_res |
75 | 89 | retries: 2 |
76 | 90 | delay: 30 |
77 | 91 | until: apt_res is success |
78 | | - with_items: |
79 | | - - ifupdown |
80 | | - - qemu |
81 | | - - openvswitch-switch |
82 | | - - net-tools |
83 | | - - bridge-utils |
84 | | - - util-linux |
85 | | - |
86 | | - - name: Install necessary packages |
87 | | - apt: pkg={{ item }} update_cache=yes cache_valid_time=86400 |
88 | 92 | become: yes |
89 | | - register: apt_res |
90 | | - retries: 2 |
91 | | - delay: 30 |
92 | | - until: apt_res is success |
93 | | - with_items: |
94 | | - - iproute2 |
95 | | - - vlan |
96 | | - - apt-transport-https |
97 | | - - ca-certificates |
98 | | - - curl |
99 | | - - software-properties-common |
100 | | - - libvirt-clients |
101 | 93 |
|
102 | 94 | - name: Install necessary packages |
103 | 95 | register: apt_res |
|
125 | 117 | - libvirt-daemon-system |
126 | 118 | - qemu-system-x86 |
127 | 119 | become: yes |
128 | | - when: host_distribution_version.stdout == "20.04" or host_distribution_version.stdout == "22.04" |
| 120 | + when: host_distribution_version.stdout >= "20.04" |
129 | 121 | when: package_installation|bool |
130 | 122 |
|
131 | 123 | - name: Get default pip_executable |
132 | 124 | set_fact: |
133 | 125 | pip_executable: pip |
134 | | - when: pip_executable is not defined and host_distribution_version.stdout != "20.04" and host_distribution_version.stdout != "22.04" |
| 126 | + when: pip_executable is not defined and host_distribution_version.stdout < "20.04" |
135 | 127 |
|
136 | 128 | - name: Get default pip_executable |
137 | 129 | set_fact: |
138 | 130 | pip_executable: pip3 |
139 | | - when: pip_executable is not defined and (host_distribution_version.stdout == "20.04" or host_distribution_version.stdout == "22.04") |
140 | | - |
141 | | -- name: remove old python packages |
142 | | - pip: name=docker-py state=absent executable={{ pip_executable }} |
143 | | - environment: "{{ proxy_env | default({}) }}" |
144 | | - ignore_errors: yes |
| 131 | + when: pip_executable is not defined and (host_distribution_version.stdout >= "20.04") |
145 | 132 |
|
146 | 133 | - include_tasks: docker.yml |
147 | 134 | when: package_installation|bool |
|
150 | 137 | pip: name=requests version=2.32.3 state=present executable={{ pip_executable }} |
151 | 138 | become: yes |
152 | 139 | environment: "{{ proxy_env | default({}) }}" |
153 | | - when: pip_executable=="pip3" |
| 140 | + when: pip_executable=="pip3" and host_distribution_version.stdout < "24.04" |
| 141 | + |
| 142 | +- name: Install requests package |
| 143 | + pip: name=requests version=2.32.3 state=present virtualenv=/tmp/sonic-mgmt-virtualenv virtualenv_site_packages=true virtualenv_command="python3 -m venv" |
| 144 | + become: yes |
| 145 | + environment: "{{ proxy_env | default({}) }}" |
| 146 | + when: host_distribution_version.stdout >= "24.04" |
154 | 147 |
|
155 | 148 | - name: Ensure {{ ansible_user }} in docker,sudo group |
156 | 149 | user: |
|
165 | 158 | append: yes |
166 | 159 | groups: libvirt |
167 | 160 | become: yes |
168 | | - when: host_distribution_version.stdout == "20.04" or host_distribution_version.stdout == "22.04" |
| 161 | + when: host_distribution_version.stdout >= "20.04" |
169 | 162 |
|
170 | 163 | - name: Install br_netfilter kernel module |
171 | 164 | become: yes |
|
223 | 216 | # root_path is supposed to be absolute path. |
224 | 217 | - set_fact: |
225 | 218 | root_path: "{{ home_path + '/' + root_path }}" |
226 | | - when: "not '{{ root_path }}'.startswith('/')" |
| 219 | + when: "not root_path.startswith('/')" |
227 | 220 |
|
228 | 221 | - debug: msg="home_path = {{ home_path }} root_path = {{ root_path }}" |
229 | 222 |
|
|
382 | 375 | loop_control: |
383 | 376 | loop_var: dut_name |
384 | 377 | when: duts_name is defined |
| 378 | + |
| 379 | +- name: Use virtualenv for all Python scripts on Ubuntu 24.04 and newer |
| 380 | + set_fact: |
| 381 | + ansible_python_interpreter: "/tmp/sonic-mgmt-virtualenv/bin/python" |
| 382 | + when: host_distribution_version.stdout >= "24.04" |
0 commit comments