forked from sonic-net/sonic-mgmt
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'sonic-net:master' into master
- Loading branch information
Showing
13 changed files
with
703 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,234 @@ | ||
- name: Check flag file to see if server is configured | ||
stat: | ||
path: /var/run/sonic/server_ready | ||
register: server_ready | ||
|
||
- name: Check if force configure server is set | ||
set_fact: | ||
force_configure_server: false | ||
when: force_configure_server is not defined | ||
|
||
- block: | ||
- name: Firstly clear the server ready flag file | ||
file: | ||
path: /var/run/sonic/server_ready | ||
state: absent | ||
become: yes | ||
|
||
- name: Set default apt_lock_timeout | ||
set_fact: | ||
support_apt_lock_timeout: false | ||
|
||
# Ansible apt module supports argument "lock_timeout" since ansible core version 2.12 | ||
# - https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_module.html#parameter-lock_timeout | ||
# We can take advantage of this argument to avoid potential apt lock conflicts while running add-topo in parallel | ||
# for multiple testbeds on the same server. | ||
# The problem is that ansible version in sonic-mgmt docker image is not upgraded to 2.12 yet. So, we need to | ||
# check ansible version and set the support_apt_lock_timeout flag accordingly. Then we can use this flag to | ||
# decide whether to use lock_timeout argument in apt module or not. In the future, when ansible version in | ||
# sonic-mgmt docker image is upgraded to 2.12, we can benefit from the lock_timeout argument directly. | ||
- name: Support apt lock_timeout or not | ||
set_fact: | ||
support_apt_lock_timeout: true | ||
when: | ||
- ansible_version.major|int >= 2 | ||
- ansible_version.minor|int >= 12 | ||
|
||
- name: Check if kernel upgrade needed | ||
set_fact: | ||
kernel_upgrade_needed: true | ||
when: | ||
- host_distribution.stdout == "Ubuntu" | ||
- host_distribution_version.stdout == "17.04" | ||
- host_kernel.stdout.find('4.10.0') != -1 | ||
- "{{ host_kernel.stdout | regex_replace('4.10.0-([0-9]+)-.*', '\\1') | int < 25 }}" | ||
|
||
- block: | ||
- debug: msg="{{ host_kernel.stdout }}" | ||
|
||
- name: Upgrade kernel package | ||
apt: pkg={{ item }} state=latest | ||
become: yes | ||
with_items: | ||
- linux-image-generic | ||
- linux-image-extra-virtual | ||
when: not support_apt_lock_timeout|bool | ||
|
||
- name: Upgrade kernel package | ||
apt: pkg={{ item }} state=latest lock_timeout=600 | ||
become: yes | ||
with_items: | ||
- linux-image-generic | ||
- linux-image-extra-virtual | ||
when: support_apt_lock_timeout|bool | ||
|
||
- name: Prompt for rebooting | ||
fail: | ||
msg: "Kernel upgraded, need to reboot!" | ||
when: | ||
- kernel_upgrade_needed is defined | ||
- package_installation|bool | ||
|
||
- block: | ||
- name: Install necessary packages | ||
apt: pkg={{ item }} update_cache=yes cache_valid_time=86400 | ||
become: yes | ||
with_items: | ||
- ifupdown | ||
- qemu | ||
- openvswitch-switch | ||
- net-tools | ||
- bridge-utils | ||
- util-linux | ||
- iproute2 | ||
- vlan | ||
- apt-transport-https | ||
- ca-certificates | ||
- curl | ||
- software-properties-common | ||
- libvirt-clients | ||
when: not support_apt_lock_timeout|bool | ||
|
||
- name: Install necessary packages | ||
apt: pkg={{ item }} update_cache=yes cache_valid_time=86400 lock_timeout=600 | ||
become: yes | ||
with_items: | ||
- ifupdown | ||
- qemu | ||
- openvswitch-switch | ||
- net-tools | ||
- bridge-utils | ||
- util-linux | ||
- iproute2 | ||
- vlan | ||
- apt-transport-https | ||
- ca-certificates | ||
- curl | ||
- software-properties-common | ||
- libvirt-clients | ||
when: support_apt_lock_timeout|bool | ||
|
||
- name: Install necessary packages | ||
apt: | ||
pkg: | ||
- python | ||
- libvirt-bin | ||
- python-libvirt | ||
- python-pip | ||
become: yes | ||
when: | ||
- host_distribution_version.stdout == "18.04" | ||
- not support_apt_lock_timeout|bool | ||
|
||
- name: Install necessary packages | ||
apt: | ||
pkg: | ||
- python | ||
- libvirt-bin | ||
- python-libvirt | ||
- python-pip | ||
lock_timeout: 600 | ||
become: yes | ||
when: | ||
- host_distribution_version.stdout == "18.04" | ||
- support_apt_lock_timeout|bool | ||
|
||
- name: Install necessary packages | ||
apt: | ||
pkg: | ||
- python3-libvirt | ||
- python3-pip | ||
- libvirt-daemon-system | ||
- qemu-system-x86 | ||
become: yes | ||
when: | ||
- host_distribution_version.stdout == "20.04" or host_distribution_version.stdout == "22.04" | ||
- not support_apt_lock_timeout|bool | ||
|
||
- name: Install necessary packages | ||
apt: | ||
pkg: | ||
- python3-libvirt | ||
- python3-pip | ||
- libvirt-daemon-system | ||
- qemu-system-x86 | ||
lock_timeout: 600 | ||
become: yes | ||
when: | ||
- host_distribution_version.stdout == "20.04" or host_distribution_version.stdout == "22.04" | ||
- support_apt_lock_timeout|bool | ||
|
||
when: package_installation|bool | ||
|
||
- name: remove old python packages | ||
pip: name=docker-py state=absent executable={{ pip_executable }} | ||
environment: "{{ proxy_env | default({}) }}" | ||
ignore_errors: yes | ||
|
||
- include_tasks: docker.yml | ||
when: package_installation|bool | ||
|
||
- name: Ensure {{ ansible_user }} in docker,sudo group | ||
user: | ||
name: "{{ ansible_user }}" | ||
append: yes | ||
groups: docker,sudo | ||
become: yes | ||
|
||
- name: Ensure {{ ansible_user }} in libvirt group | ||
user: | ||
name: "{{ ansible_user }}" | ||
append: yes | ||
groups: libvirt | ||
become: yes | ||
when: host_distribution_version.stdout == "20.04" or host_distribution_version.stdout == "22.04" | ||
|
||
- name: Install br_netfilter kernel module | ||
become: yes | ||
modprobe: name=br_netfilter state=present | ||
|
||
- name: Set sysctl bridge parameters for testbed | ||
sysctl: | ||
name: "{{ item }}" | ||
value: "0" | ||
sysctl_set: yes | ||
become: yes | ||
with_items: | ||
- net.bridge.bridge-nf-call-arptables | ||
- net.bridge.bridge-nf-call-ip6tables | ||
- net.bridge.bridge-nf-call-iptables | ||
|
||
- name: Set sysctl RCVBUF max parameter for testbed | ||
sysctl: | ||
name: "net.core.rmem_max" | ||
value: "509430500" | ||
sysctl_set: yes | ||
become: yes | ||
|
||
- name: Set sysctl RCVBUF default parameter for testbed | ||
sysctl: | ||
name: "net.core.rmem_default" | ||
value: "31457280" | ||
sysctl_set: yes | ||
become: yes | ||
|
||
- name: Setup external front port | ||
include_tasks: external_port.yml | ||
when: external_port is defined | ||
|
||
- name: Setup internal management network | ||
include_tasks: internal_mgmt_network.yml | ||
when: internal_mgmt_network is defined and internal_mgmt_network == True | ||
|
||
- name: Prepare parent directory | ||
shell: | ||
cmd: "mkdir -p /var/run/sonic" | ||
become: yes | ||
|
||
- name: Set the server ready flag file | ||
file: | ||
path: /var/run/sonic/server_ready | ||
state: touch | ||
become: yes | ||
|
||
when: not server_ready.stat.exists or force_configure_server|bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.