Add CPU isolation support for Yardstick NSB setup
[yardstick.git] / ansible / install.yaml
1 # Copyright (c) 2018 Intel Corporation.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 ---
15 - hosts: jumphost
16   become: yes
17   vars:
18     yardstick_dir: "{{ YARDSTICK_DIR | default('/home/opnfv/repos/yardstick') }}"
19     virtual_environment: "{{ VIRTUAL_ENVIRONMENT | default(False) }}"
20     nsb_dir: "{{ NSB_DIR | default('/opt/nsb_bin/') }}"
21
22   pre_tasks:
23
24     - name: Create NSB binaries directory, accessible to any user
25       file:
26         path: "{{ nsb_dir }}"
27         state: directory
28         owner: root
29         mode: 0777
30       when:
31         - installation_mode != inst_mode_container_pull
32
33   roles:
34     - add_repos_jumphost
35     - install_dependencies_jumphost
36     - { role: install_yardstick, when: installation_mode != inst_mode_container_pull }
37     - { role: configure_uwsgi, when: installation_mode != inst_mode_container_pull }
38     - { role: configure_nginx, when: installation_mode != inst_mode_container_pull }
39     - { role: configure_gui, when: installation_mode != inst_mode_container_pull }
40     - { role: download_trex, when: installation_mode != inst_mode_container_pull }
41     - { role: install_trex, when: installation_mode != inst_mode_container_pull }
42     - { role: configure_rabbitmq, when: installation_mode == inst_mode_baremetal }
43
44
45   post_tasks:
46
47     - service:
48         name: nginx
49         state: restarted
50       when: installation_mode == inst_mode_baremetal
51
52     - shell: uwsgi -i /etc/yardstick/yardstick.ini
53       when: installation_mode == inst_mode_baremetal
54
55
56 - name: Prepare baremetal and standalone servers
57   hosts: yardstick-baremetal,yardstick-standalone
58   become: yes
59   vars_files:
60     - roles/download_dpdk/defaults/main.yml
61   environment: "{{ proxy_env }}"
62
63   roles:
64     - add_custom_repos
65     - role: set_package_installer_proxy
66       when: proxy_env is defined and proxy_env
67     # can't update grub in chroot/docker
68     - enable_hugepages_on_boot
69     - enable_iommu_on_boot
70     - enable_cpu_isolation_on_boot
71     # needed for collectd plugins
72     - increase_open_file_limits
73     - install_image_dependencies
74     - role: download_dpdk
75       dpdk_version: "{{ dpdk_version_for_PROX }}"
76     - role: install_dpdk
77       dpdk_version: "{{ dpdk_version_for_PROX }}"
78     - download_samplevnfs
79     - role: install_samplevnf
80       vnf_name: PROX
81     - download_dpdk
82     - install_dpdk
83     - download_trex
84     - install_trex
85     - download_civetweb
86     - install_civetweb
87     - role: install_samplevnf
88       vnf_name: UDP_Replay
89     - role: install_samplevnf
90       vnf_name: ACL
91     - role: install_samplevnf
92       vnf_name: FW
93     - role: install_samplevnf
94       vnf_name: CGNAPT
95     # build shared DPDK for collectd only, required DPDK downloaded already
96     - install_dpdk_shared
97     - install_rabbitmq
98     - download_intel_cmt_cat
99     - install_intel_cmt_cat
100     - download_pmu_tools
101     - install_pmu_tools
102     - download_collectd
103     - install_collectd
104     - docker
105     - barometer_collectd
106
107
108 - name: Prepare to build VM
109   hosts: jumphost
110   become: yes
111   vars:
112     img_prop_item: "{{ IMG_PROPERTY }}"
113     img_arch: "{{ YARD_IMG_ARCH }}"
114
115   tasks:
116     - name: Include pre-build
117       include_role:
118         name: build_yardstick_image
119         tasks_from: pre_build.yml
120       when:
121         - installation_mode != inst_mode_container
122         - IMG_PROPERTY == 'nsb' or IMG_PROPERTY == 'normal'
123
124
125 - name: Build VM in chroot
126   hosts: chroot_image
127   connection: chroot
128   become: yes
129   vars:
130     img_property: "{{ IMG_PROPERTY }}"
131   environment: "{{ proxy_env }}"
132
133   tasks:
134     - name: Include image build
135       include_role:
136         name: build_yardstick_image
137         tasks_from: "cloudimg_modify_{{ img_property }}.yml"
138       when:
139         - installation_mode != inst_mode_container
140         - IMG_PROPERTY == 'nsb' or IMG_PROPERTY == 'normal'
141
142
143 - name: Clear up after VM is built
144   hosts: jumphost
145   become: yes
146
147   tasks:
148     - name: Include post-build
149       include_role:
150         name: build_yardstick_image
151         tasks_from: post_build.yml
152       when:
153         - installation_mode != inst_mode_container
154         - IMG_PROPERTY == 'nsb' or IMG_PROPERTY == 'normal'
155
156
157 - name: Add OpenStack variables, image
158   hosts: jumphost
159   vars:
160     openrc_flag: false
161   vars_files:
162     - yardstick_config.yml
163
164   pre_tasks:
165     - name: Get information about external VM image
166       stat:
167         path: "{{ path_to_img }}"
168       register: image_file_stat
169       when:
170         - path_to_img is defined
171         - imgfile is not defined
172
173     - set_fact:
174         imgfile: "{{ path_to_img }}"
175       when:
176         - path_to_img is defined
177         - imgfile is not defined
178         - image_file_stat.stat.islnk is defined
179         - not image_file_stat.stat.islnk
180
181     - set_fact:
182         openrc_flag: true
183       when:
184         - openrc_file is defined
185         - imgfile is defined
186
187   roles:
188     - { role: convert_openrc, when: openrc_file is defined }
189     - { role: clean_images, when: openrc_flag }
190     - { role: clean_flavors, when: openrc_flag }
191     - { role: create_samplevnfs_image, when: openrc_flag }
192   environment:
193     "{{ openrc | default({}) }}"
194
195
196 - name: Start yardstick container on jumphost
197   hosts: jumphost
198
199   tasks:
200     - name: Install docker needed to pull Yardstick container
201       include_role:
202         name: docker
203       when: installation_mode == inst_mode_container_pull
204
205     - name: Start yardstick container
206       docker_container:
207         name: yardstick
208         pull: yes
209         recreate: yes
210         image: "{{ yardstick_docker_image|default('opnfv/yardstick:latest') }}"
211         state: started
212         restart_policy: always
213         privileged: yes
214         interactive: yes
215         volumes:
216           - "{{ openrc_file|default('/dev/null') }}:/etc/yardstick/openstack.creds:ro"
217           - /var/run/docker.sock:/var/run/docker.sock
218           - /opt:/opt
219           - /etc/localtime:/etc/localtime:ro
220       when: installation_mode == inst_mode_container_pull