---
# file: csit/tasks/main.yml
-- name: Upload config to rename network interfaces
- copy:
- src: files/99-vppdevice.yaml
- dest: /etc/netplan/99-vppdevice.yaml
- owner: root
- group: root
- mode: 0644
-
-- name: Apply network config changes
- command: /usr/sbin/netplan apply
-
-- name: Install required system tools and packages
- apt:
+# CentOS 8 specific
+- name: CentOS - Install epel repositories
+ dnf:
name:
- - wget
- - curl
- - python-pip
- - virtualenv
- - libpcap-dev
- state: present
-
-- name: Adjust number of hugepages
- sysctl:
- name: vm.nr_hugepages
- value: 512
- state: present
- sysctl_file: /etc/sysctl.d/90-csit.conf
- reload: yes
+ - 'epel-release'
+ when:
+ - ansible_distribution|lower == 'centos'
+
+- name: CentOS - Enable PowerTools
+ command: >
+ dnf config-manager
+ --set-enabled PowerTools
+ when:
+ - ansible_distribution|lower == 'centos'
+
+# NOTE: containerd.io >1.2.0-3 requirement disabled by RH
+# Unable to install current docker version as of now
+# Using docker-ce-3:18.09.1-3.el7
+- name: CentOS - Add docker-ce repo
+ command: >
+ dnf config-manager
+ --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
+ when:
+ - ansible_distribution|lower == 'centos'
+
+- name: CentOS - Install docker-ce
+ dnf:
+ name:
+ - 'docker-ce-3:18.09.1-3.el7'
+ when:
+ - ansible_distribution|lower == 'centos'
-- name: Add an Apt signing key, for docker-ce repository
+# Ubuntu specific
+- name: Ubuntu - Add docker-ce GPG key
apt_key:
- url: https://download.docker.com/linux/ubuntu/gpg
- state: present
+ url: 'https://download.docker.com/linux/ubuntu/gpg'
+ when:
+ - ansible_distribution|lower == 'ubuntu'
-- name: Add docker-ce apt repository if not present
+- name: Ubuntu - Add docker-ce repo
apt_repository:
- repo: "deb https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
- state: present
+ repo: 'deb https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable'
+ filename: 'docker'
+ mode: 644
+ when:
+ - ansible_distribution|lower == 'ubuntu'
-- name: Install docker-ce if it's not already installed
+- name: Ubuntu - Install docker-ce
apt:
- name: docker-ce
- state: present
+ name:
+ - 'docker-ce'
+ - 'containerd.io'
+ - 'docker-ce-cli'
+ when:
+ - ansible_distribution|lower == 'ubuntu'
+
+# General
+- name: Install required system tools and packages
+ package:
+ name: "{{ csit_packages | join(',') }}"
+ state: 'latest'
+ update_cache: 'yes'
+
+- name: Adjust number of hugepages
+ sysctl:
+ name: 'vm.nr_hugepages'
+ value: '512'
+ state: 'present'
+ sysctl_file: '/etc/sysctl.d/90-csit.conf'
+ reload: 'yes'
- name: "Add user for running tests: {{ csit.test_user.name }}"
user:
- name: "{{ csit.test_user.name }}"
- password: "{{ csit.test_user.password }}"
- home: "{{ csit.test_user.home }}"
- shell: "{{ csit.test_user.shell }}"
+ name: '{{ csit.test_user.name }}'
+ password: '{{ csit.test_user.password }}'
+ home: '{{ csit.test_user.home }}'
+ shell: '{{ csit.test_user.shell }}'
- name: "Allow passwordless sudo for user: {{ csit.test_user.name }}"
lineinfile:
- path: "/etc/sudoers.d/{{ csit.test_user.name }}"
- line: "{{ csit.test_user.name }} ALL=(ALL) NOPASSWD:ALL"
- create: yes
+ path: '/etc/sudoers.d/{{ csit.test_user.name }}'
+ line: '{{ csit.test_user.name }} ALL=(ALL) NOPASSWD:ALL'
+ create: 'yes'
+ mode: 660
- name: Add vagrant user to docker group
user:
- name: vagrant
+ name: 'vagrant'
groups:
- - docker
+ - 'docker'
- name: Reload groups for current session
- command: /usr/bin/newgrp docker
+ command: '/usr/bin/newgrp docker'
- name: Load required kernel modules
modprobe:
- name: "{{ item }}"
- state: present
+ name: '{{ item }}'
+ state: 'present'
with_items:
- vfio-pci
- name: Enable required kernel modules on boot
lineinfile:
- path: /etc/modules
- line: "{{ item }}"
- state: present
+ path: '/etc/modules'
+ line: '{{ item }}'
+ create: 'yes'
+ state: 'present'
insertafter: EOF
with_items:
- vfio-pci
- name: Clone CSIT repository
become_user: vagrant
git:
- repo: "{{ csit.repository.url }}"
- dest: "{{ csit.home }}"
+ repo: '{{ csit.repository.url }}'
+ dest: '{{ csit.home }}'
accept_hostkey: yes
- version: "{{ csit.repository.version }}"
-
-- name: Install and update pip and virtualenv
- become_user: vagrant
- pip:
- name:
- - pip
- - virtualenv
- state: latest
+ version: '{{ csit.repository.version }}'
- name: Prepare python virtual environmant for CSIT
become_user: vagrant
- command: "/usr/bin/virtualenv {{ csit.home }}/env"
+ command: '/usr/bin/virtualenv --python=/usr/bin/python3 {{ csit.home }}/env'
args:
- chdir: "{{ csit.home }}"
- creates: "{{ csit.home }}/env/bin/activate"
+ chdir: '{{ csit.home }}'
+ creates: '{{ csit.home }}/env/bin/activate'
- name: Install python dependencies (from {{ csit.home }}/requirements.txt)
become_user: vagrant
- shell: source {{ csit.home }}/env/bin/activate && pip install --timeout 300 -r {{ csit.home }}/requirements.txt
+ shell: |
+ source '{{ csit.home }}/env/bin/activate' &&
+ pip3 install --timeout 300 -r '{{ csit.home }}/requirements.txt'
args:
- executable: /bin/bash
+ executable: '/bin/bash'
- name: Load csit docker image from local drive if it exists (/vagrant/csit-sut.tar)
shell: |