Merge "Modify install.yaml to support Ubuntu 18"
[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_container_pull }
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
99
100 - hosts: jumphost
101   become: yes
102   vars:
103     img_prop_item: "{{ IMG_PROPERTY }}"
104     img_arch: "{{ YARD_IMG_ARCH }}"
105
106   tasks:
107     - name: Include pre-build
108       include_role:
109         name: build_yardstick_image
110         tasks_from: pre_build.yml
111       when: installation_mode != inst_mode_container
112
113
114 - hosts: chroot_image
115   connection: chroot
116   become: yes
117   vars:
118     img_property: "{{ IMG_PROPERTY }}"
119   environment: "{{ proxy_env }}"
120
121   tasks:
122     - name: Include image build
123       include_role:
124         name: build_yardstick_image
125         tasks_from: "cloudimg_modify_{{ img_property }}.yml"
126       when: installation_mode != inst_mode_container
127
128
129 - hosts: jumphost
130   become: yes
131
132   tasks:
133     - name: Include post-build
134       include_role:
135         name: build_yardstick_image
136         tasks_from: post_build.yml
137       when: installation_mode != inst_mode_container
138
139
140 - name: start yardstick container on jumphost
141   hosts: jumphost
142
143   tasks:
144     - include_role:
145         name: docker
146       when: installation_mode == inst_mode_container_pull
147
148     - name: Start yardstick container
149       docker_container:
150         name: yardstick
151         pull: yes
152         recreate: yes
153         image: "{{ yardstick_docker_image|default('opnfv/yardstick:latest') }}"
154         state: started
155         restart_policy: always
156         privileged: yes
157         interactive: yes
158         volumes:
159           - "{{ openrc_file|default('/dev/null') }}:/etc/yardstick/openstack.creds:ro"
160           - /var/run/docker.sock:/var/run/docker.sock
161           - /opt:/opt
162           - /etc/localtime:/etc/localtime:ro
163       when: installation_mode == inst_mode_container_pull