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