558c48609fbb87b83d647bc91e1ab1c3c0e55be9
[yardstick.git] / ansible / install.yaml
1 # Copyright (c) 2018-2019 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
43       install_mode: "{{ installation_mode }}"
44
45
46   post_tasks:
47
48     - service:
49         name: nginx
50         state: restarted
51       when: installation_mode == inst_mode_baremetal
52
53     - shell: uwsgi -i /etc/yardstick/yardstick.ini
54       when: installation_mode == inst_mode_baremetal
55
56
57 - name: Prepare baremetal and standalone servers
58   hosts: yardstick-baremetal,yardstick-standalone
59   become: yes
60   vars_files:
61     - roles/download_dpdk/defaults/main.yml
62   environment: "{{ proxy_env }}"
63
64   roles:
65     - add_custom_repos
66     - role: set_package_installer_proxy
67       when: proxy_env is defined and proxy_env
68     # can't update grub in chroot/docker
69     - enable_hugepages_on_boot
70     - enable_iommu_on_boot
71     - enable_cpu_isolation_on_boot
72     # needed for collectd plugins
73     - increase_open_file_limits
74     - install_image_dependencies
75     - role: download_dpdk
76       dpdk_version: "{{ dpdk_version_for_PROX }}"
77     - role: install_dpdk
78       dpdk_version: "{{ dpdk_version_for_PROX }}"
79     - download_samplevnfs
80     - role: install_samplevnf
81       vnf_name: PROX
82     - download_dpdk
83     - install_dpdk
84     - download_trex
85     - install_trex
86     - download_civetweb
87     - install_civetweb
88     - role: install_samplevnf
89       vnf_name: UDP_Replay
90     - role: install_samplevnf
91       vnf_name: ACL
92     - role: install_samplevnf
93       vnf_name: FW
94     - role: install_samplevnf
95       vnf_name: CGNAPT
96     # build shared DPDK for collectd only, required DPDK downloaded already
97     - install_dpdk_shared
98     - install_rabbitmq
99     - download_intel_cmt_cat
100     - install_intel_cmt_cat
101     - download_pmu_tools
102     - install_pmu_tools
103     - download_collectd
104     - install_collectd
105     - docker
106     - barometer_collectd
107
108
109 - name: Prepare to build VM
110   hosts: jumphost
111   become: yes
112   vars:
113     img_prop_item: "{{ IMG_PROPERTY }}"
114     img_arch: "{{ YARD_IMG_ARCH }}"
115
116   tasks:
117     - name: Include pre-build
118       include_role:
119         name: build_yardstick_image
120         tasks_from: pre_build.yml
121       when:
122         - installation_mode != inst_mode_container
123         - IMG_PROPERTY == 'nsb' or IMG_PROPERTY == 'normal'
124
125
126 - name: Build VM in chroot
127   hosts: chroot_image
128   connection: chroot
129   become: yes
130   vars:
131     img_property: "{{ IMG_PROPERTY }}"
132   environment: "{{ proxy_env }}"
133
134   tasks:
135     - name: Include image build
136       include_role:
137         name: build_yardstick_image
138         tasks_from: "cloudimg_modify_{{ img_property }}.yml"
139       when:
140         - installation_mode != inst_mode_container
141         - IMG_PROPERTY == 'nsb' or IMG_PROPERTY == 'normal'
142
143
144 - name: Clear up after VM is built
145   hosts: jumphost
146   become: yes
147
148   tasks:
149     - name: Include post-build
150       include_role:
151         name: build_yardstick_image
152         tasks_from: post_build.yml
153       when:
154         - installation_mode != inst_mode_container
155         - IMG_PROPERTY == 'nsb' or IMG_PROPERTY == 'normal'
156
157
158 - name: Add OpenStack variables, image
159   hosts: jumphost
160   vars:
161     openrc_flag: false
162   vars_files:
163     - yardstick_config.yml
164
165   pre_tasks:
166     - name: Get information about external VM image
167       stat:
168         path: "{{ path_to_img }}"
169       register: image_file_stat
170       when:
171         - path_to_img is defined
172         - imgfile is not defined
173
174     - set_fact:
175         imgfile: "{{ path_to_img }}"
176       when:
177         - path_to_img is defined
178         - imgfile is not defined
179         - image_file_stat.stat.islnk is defined
180         - not image_file_stat.stat.islnk
181
182     - set_fact:
183         openrc_flag: true
184       when:
185         - openrc_file is defined
186         - imgfile is defined
187
188   roles:
189     - { role: convert_openrc, when: openrc_file is defined }
190     - { role: clean_images, when: openrc_flag }
191     - { role: clean_flavors, when: openrc_flag }
192     - { role: create_samplevnfs_image, when: openrc_flag }
193   environment:
194     "{{ openrc | default({}) }}"
195
196
197 - name: Start yardstick container on jumphost
198   hosts: jumphost
199
200   tasks:
201     - name: Install docker needed to pull Yardstick container
202       include_role:
203         name: docker
204       when: installation_mode == inst_mode_container_pull
205
206     - name: Start yardstick container
207       docker_container:
208         name: yardstick
209         pull: yes
210         recreate: yes
211         image: "{{ yardstick_docker_image|default('opnfv/yardstick:latest') }}"
212         state: started
213         restart_policy: always
214         privileged: yes
215         interactive: yes
216         volumes:
217           - "{{ openrc_file|default('/dev/null') }}:/etc/yardstick/openstack.creds:ro"
218           - /var/run/docker.sock:/var/run/docker.sock
219           - /opt:/opt
220           - /etc/localtime:/etc/localtime:ro
221       when: installation_mode == inst_mode_container_pull