Add PROX TC into OPNFV test cases
[yardstick.git] / ansible / roles / infra_deploy_openstack / tasks / main.yml
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 # This script is based on https://docs.openstack.org/kolla-ansible/pike/user/quickstart.html
16 - name: Include variables
17   include_vars:
18     file: "{{ rs_file }}"
19     name: infra_deploy_vars
20
21 - set_fact:
22     traffic_ip: "{{ item.interfaces[1].ip }}"
23   when: item.hostname == ansible_host
24   with_items: "{{ infra_deploy_vars.nodes }}"
25
26 - name: Get neutron iface
27   set_fact:
28     neutron_iface: "{{ item }}"
29   when:
30     - hostvars[ansible_host]['ansible_' + item.replace('-', '_')].ipv4 is defined
31     - hostvars[ansible_host]['ansible_' + item.replace('-', '_')].ipv4.address is defined
32     - hostvars[ansible_host]['ansible_' + item.replace('-', '_')].ipv4.address == traffic_ip
33   with_items: "{{ hostvars[ansible_host].ansible_interfaces }}"
34
35 - name: Create a registry container
36   docker_container:
37     name: registry
38     image: registry:2
39     restart_policy: always
40     ports:
41     - "4000:5000"
42
43 - name: Download and install Kolla
44   include_tasks: install_kolla.yml
45
46 - name: Configure Kolla
47   include_tasks: configure_kolla.yml
48
49 - name: Configure Open Stack
50   include_tasks: configure_openstack.yml
51
52 - name: Ramp up Open Stack
53   include_tasks: rampup_openstack.yml
54
55 - name: Update admin-openrc.sh
56   lineinfile:
57     path: /etc/kolla/admin-openrc.sh
58     regexp: "{{ item.find }}"
59     line: "{{ item.add }}"
60   with_items:
61    - { find: 'EXTERNAL_NETWORK', add: 'export EXTERNAL_NETWORK=public' }
62    - { find: 'OS_AUTH_TYPE', add: 'export OS_AUTH_TYPE=password' }
63
64 - name: Copy env file
65   shell: cp /etc/kolla/admin-openrc.sh /tmp/admin-openrc.yaml
66
67 - name: Rework as env vars
68   replace:
69     path: /tmp/admin-openrc.yaml
70     regexp: 'export\s+(.*)=(.*)'
71     replace: '\1: \2'
72
73 - name: Download OpenStack env file
74   fetch:
75     src: /tmp/admin-openrc.yaml
76     dest: /tmp/
77     flat: yes
78
79 - include_vars:
80     file: /tmp/admin-openrc.yaml
81     name: ostack_env
82
83 - name: Re-assign IP address
84   shell: ip address show {{ neutron_iface }} | awk '/inet/ {print $2}'
85   when: neutron_iface is defined
86   register: ip_netmask
87
88 - shell: >
89     ip addr del dev {{ neutron_iface }} {{ ip_netmask.stdout }} &&
90     ip addr add dev br-ex {{ infra_deploy_vars.networks[1].host_ip }}/{{ ip_netmask.stdout_lines[0].split('/')[1] }}
91   when:
92     - neutron_iface is defined
93     - ip_netmask.stdout | length > 0
94
95 - name: Create external network
96   os_network:
97     name: public
98     external: yes
99     provider_physical_network: physnet1
100     provider_network_type: flat
101   environment:
102     - no_proxy: "{{ lookup('env', 'no_proxy') + ',' + ansible_host + ',' + hostvars[ansible_host].ansible_default_ipv4.address }}"
103     - "{{ ostack_env }}"
104
105 - name: Create sub-network
106   os_subnet:
107     name: public-subnet
108     network_name: public
109     cidr: "{{ ip_netmask.stdout }}"
110     allocation_pool_start: "{{ infra_deploy_vars.networks[1].dhcp_ip_start }}"
111     allocation_pool_end: "{{ infra_deploy_vars.networks[1].dhcp_ip_stop }}"
112     gateway_ip: "{{ infra_deploy_vars.networks[1].host_ip }}"
113     enable_dhcp: no
114   environment:
115     - no_proxy: "{{ lookup('env', 'no_proxy') + ',' + ansible_host + ',' + hostvars[ansible_host].ansible_default_ipv4.address }}"
116     - "{{ ostack_env }}"
117
118 - name: Upload OpenStack env file to Yardstick VM
119   copy:
120     src: /etc/kolla/admin-openrc.sh
121     dest: '/tmp/admin-openrc.sh'
122     delegate_to: "{{ item }}"
123   when: "groups['yardstickG'] is defined"
124   with_items:
125     - "{{ groups['yardstickG'] }}"