Sync up 'install.yaml' with 'nsb_setup.yml'
[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   environment: "{{ proxy_env }}"
60
61   roles:
62     - add_custom_repos
63     - role: set_package_installer_proxy
64       when: proxy_env is defined and proxy_env
65     # can't update grub in chroot/docker
66     - enable_hugepages_on_boot
67     - enable_iommu_on_boot
68     # needed for collectd plugins
69     - increase_open_file_limits
70     - install_image_dependencies
71     - role: download_dpdk
72     # dpdk_version: "17.02"
73     - install_dpdk
74     - download_trex
75     - install_trex
76     - download_civetweb
77     - install_civetweb
78     - download_samplevnfs
79     - role: install_samplevnf
80       vnf_name: PROX
81     - role: install_samplevnf
82       vnf_name: UDP_Replay
83     - role: install_samplevnf
84       vnf_name: ACL
85     - role: install_samplevnf
86       vnf_name: FW
87     - role: install_samplevnf
88       vnf_name: CGNAPT
89     # build shared DPDK for collectd only, required DPDK downloaded already
90     - install_dpdk_shared
91     - install_rabbitmq
92     - download_intel_cmt_cat
93     - install_intel_cmt_cat
94     - download_pmu_tools
95     - install_pmu_tools
96     - download_collectd
97     - install_collectd
98     - docker
99     - barometer_collectd
100
101
102 - name: Prepare to build VM
103   hosts: jumphost
104   become: yes
105   vars:
106     img_prop_item: "{{ IMG_PROPERTY }}"
107     img_arch: "{{ YARD_IMG_ARCH }}"
108
109   tasks:
110     - name: Include pre-build
111       include_role:
112         name: build_yardstick_image
113         tasks_from: pre_build.yml
114       when: installation_mode != inst_mode_container
115
116
117 - name: Build VM in chroot
118   hosts: chroot_image
119   connection: chroot
120   become: yes
121   vars:
122     img_property: "{{ IMG_PROPERTY }}"
123   environment: "{{ proxy_env }}"
124
125   tasks:
126     - name: Include image build
127       include_role:
128         name: build_yardstick_image
129         tasks_from: "cloudimg_modify_{{ img_property }}.yml"
130       when: installation_mode != inst_mode_container
131
132
133 - name: Clear up after VM is built
134   hosts: jumphost
135   become: yes
136
137   tasks:
138     - name: Include post-build
139       include_role:
140         name: build_yardstick_image
141         tasks_from: post_build.yml
142       when: installation_mode != inst_mode_container
143
144
145 - hosts: jumphost
146   vars_files:
147     - yardstick_config.yml
148
149   roles:
150     - { role: convert_openrc, when: openrc_file is defined }
151
152
153 - name: Add OpenStack variables, image
154   hosts: jumphost
155   vars_files:
156     - yardstick_config.yml
157   environment:
158     "{{ openrc }}"
159
160   roles:
161     - { role: clean_images, when: openrc_file is defined }
162     - { role: clean_flavors, when: openrc_file is defined }
163     - { role: create_samplevnfs_image, when: openrc_file is defined }
164
165
166 - name: Start yardstick container on jumphost
167   hosts: jumphost
168
169   tasks:
170     - name: Install docker needed to pull Yardstick container
171       include_role:
172         name: docker
173       when: installation_mode == inst_mode_container_pull
174
175     - name: Start yardstick container
176       docker_container:
177         name: yardstick
178         pull: yes
179         recreate: yes
180         image: "{{ yardstick_docker_image|default('opnfv/yardstick:latest') }}"
181         state: started
182         restart_policy: always
183         privileged: yes
184         interactive: yes
185         volumes:
186           - "{{ openrc_file|default('/dev/null') }}:/etc/yardstick/openstack.creds:ro"
187           - /var/run/docker.sock:/var/run/docker.sock
188           - /opt:/opt
189           - /etc/localtime:/etc/localtime:ro
190       when: installation_mode == inst_mode_container_pull