FrameworkSetup: increase timeout
[csit.git] / resources / tools / vagrant / ansible / roles / csit / tasks / main.yml
1 ---
2 # file: csit/tasks/main.yml
3
4 # CentOS 8 specific
5 - name: CentOS - Install epel repositories
6   dnf:
7     name:
8       - 'epel-release'
9   when:
10     - ansible_distribution|lower == 'centos'
11
12 - name: CentOS - Enable PowerTools
13   command: >
14       dnf config-manager
15       --set-enabled PowerTools
16   when:
17     - ansible_distribution|lower == 'centos'
18
19 # NOTE: containerd.io >1.2.0-3 requirement disabled by RH
20 #       Unable to install current docker version as of now
21 #       Using docker-ce-3:18.09.1-3.el7
22 - name: CentOS - Add docker-ce repo
23   command: >
24       dnf config-manager
25       --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
26   when:
27     - ansible_distribution|lower == 'centos'
28
29 - name: CentOS - Install docker-ce
30   dnf:
31     name:
32       - 'docker-ce-3:18.09.1-3.el7'
33   when:
34     - ansible_distribution|lower == 'centos'
35
36 # Ubuntu specific
37 - name: Ubuntu - Add docker-ce GPG key
38   apt_key:
39     url: 'https://download.docker.com/linux/ubuntu/gpg'
40   when:
41     - ansible_distribution|lower == 'ubuntu'
42
43 - name: Ubuntu - Add docker-ce repo
44   apt_repository:
45     repo: 'deb https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable'
46     filename: 'docker'
47     mode: 644
48   when:
49       - ansible_distribution|lower == 'ubuntu'
50
51 - name: Ubuntu - Install docker-ce
52   apt:
53     name:
54       - 'docker-ce'
55       - 'containerd.io'
56       - 'docker-ce-cli'
57   when:
58     - ansible_distribution|lower == 'ubuntu'
59
60 # General
61 - name: Install required system tools and packages
62   package:
63     name: "{{ csit_packages | join(',') }}"
64     state: 'latest'
65
66 - name: Adjust number of hugepages
67   sysctl:
68     name: 'vm.nr_hugepages'
69     value: '512'
70     state: 'present'
71     sysctl_file: '/etc/sysctl.d/90-csit.conf'
72     reload: 'yes'
73
74 - name: "Add user for running tests: {{ csit.test_user.name }}"
75   user:
76     name: '{{ csit.test_user.name }}'
77     password: '{{ csit.test_user.password }}'
78     home: '{{ csit.test_user.home }}'
79     shell: '{{ csit.test_user.shell }}'
80
81 - name: "Allow passwordless sudo for user: {{ csit.test_user.name }}"
82   lineinfile:
83     path: '/etc/sudoers.d/{{ csit.test_user.name }}'
84     line: '{{ csit.test_user.name }} ALL=(ALL) NOPASSWD:ALL'
85     create: 'yes'
86     mode: 660
87
88 - name: Add vagrant user to docker group
89   user:
90     name: 'vagrant'
91     groups:
92       - 'docker'
93
94 - name: Reload groups for current session
95   command: '/usr/bin/newgrp docker'
96
97 - name: Load required kernel modules
98   modprobe:
99     name: '{{ item }}'
100     state: 'present'
101   with_items:
102     - vfio-pci
103
104 - name: Enable required kernel modules on boot
105   lineinfile:
106     path: '/etc/modules'
107     line: '{{ item }}'
108     create: 'yes'
109     state: 'present'
110     insertafter: EOF
111   with_items:
112     - vfio-pci
113
114 - name: Clone CSIT repository
115   become_user: vagrant
116   git:
117     repo: '{{ csit.repository.url }}'
118     dest: '{{ csit.home }}'
119     accept_hostkey: yes
120     version: '{{ csit.repository.version }}'
121
122 - name: Prepare python virtual environmant for CSIT
123   become_user: vagrant
124   command: '/usr/bin/virtualenv --python=/usr/bin/python3 {{ csit.home }}/env'
125   args:
126     chdir: '{{ csit.home }}'
127     creates: '{{ csit.home }}/env/bin/activate'
128
129 - name: Install python dependencies (from {{ csit.home }}/requirements.txt)
130   become_user: vagrant
131   shell: |
132       source '{{ csit.home }}/env/bin/activate' &&
133       pip3 install --timeout 300 -r '{{ csit.home }}/requirements.txt'
134   args:
135     executable: '/bin/bash'
136
137 - name: Load csit docker image from local drive if it exists (/vagrant/csit-sut.tar)
138   shell: |
139     if [ -z "$(docker images -q `cat {{ csit.home }}/VPP_DEVICE_IMAGE`)" ] && [ -e /vagrant/csit-sut.tar ]; then
140       docker load -i /vagrant/csit-sut.tar;
141     fi;
142   ignore_errors: yes