-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.yml
124 lines (110 loc) · 4.37 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
---
- hosts: all
sudo: False
vars_files:
- defaults/main.yml
vars:
openstack_identity_demo_password: password
openstack_network_internal_name: demo-net
openstack_network_internal_subnet_name: demo-subnet
openstack_network_internal_subnet_cidr: 192.168.0.0/24
openstack_network_internal_subnet_dns_nameservers: 8.8.8.8
openstack_network_internal_subnet_gateway_ip: 192.168.0.1
openstack_router_name: demo-router
tasks:
- name: update admin.openrc from template
template:
src: templates/admin.openrc
dest: "{{ ansible_env.PWD }}/admin.openrc"
owner: "{{ ansible_ssh_user }}"
- name: create demo tenant
keystone_user:
endpoint: "{{ openstack_identity_admin_url }}"
token: "{{ openstack_identity_admin_token }}"
tenant: demo
tenant_description: "Demo Tenant"
- name: create demo user
keystone_user:
endpoint: "{{ openstack_identity_admin_url }}"
token: "{{ openstack_identity_admin_token }}"
tenant: demo
user: demo
password: "{{ openstack_identity_demo_password }}"
- name: associate _member_ role with demo user
keystone_user:
endpoint: "{{ openstack_identity_admin_url }}"
token: "{{ openstack_identity_admin_token }}"
tenant: demo
user: demo
role: _member_
- name: update demo.openrc from template
template:
src: templates/demo.openrc
dest: "{{ ansible_env.PWD }}/demo.openrc"
owner: "{{ ansible_ssh_user }}"
# Ansible neutron modules lists all tenants to get ids, but this is not
# permitted for non-admin users. Need to fix neutron_* modules as non-admin
# *should* be able to create networks, associate floating ips, etc.
- name: ensure demo user has admin role
keystone_user:
endpoint: "{{ openstack_identity_admin_url }}"
token: "{{ openstack_identity_admin_token }}"
tenant: demo
user: demo
role: admin
- name: ensure internal network is registered
neutron_network:
auth_url: "{{ openstack_identity_public_url }}"
login_tenant_name: demo
login_username: demo
login_password: "{{ openstack_identity_demo_password }}"
tenant_name: demo
name: "{{ openstack_network_internal_name }}"
state: present
register: openstack_network_internal
- name: ensure subnet internal network is registered
neutron_subnet:
auth_url: "{{ openstack_identity_public_url }}"
login_tenant_name: demo
login_username: demo
login_password: "{{ openstack_identity_demo_password }}"
tenant_name: demo
name: "{{ openstack_network_internal_subnet_name }}"
network_name: "{{ openstack_network_internal_name }}"
cidr: "{{ openstack_network_internal_subnet_cidr }}"
enable_dhcp: true
gateway_ip: "{{ openstack_network_internal_subnet_gateway_ip }}"
dns_nameservers: >
{{ openstack_network_internal_subnet_dns_nameservers }}
state: present
- name: ensure router exists
neutron_router:
auth_url: "{{ openstack_identity_public_url }}"
login_tenant_name: demo
login_username: demo
login_password: "{{ openstack_identity_demo_password }}"
tenant_name: demo
name: "{{ openstack_router_name }}"
state: present
- name: ensure router has interface connected to internal network
neutron_router_interface:
auth_url: "{{ openstack_identity_public_url }}"
login_tenant_name: demo
login_username: demo
login_password: "{{ openstack_identity_demo_password }}"
tenant_name: demo
router_name: "{{ openstack_router_name }}"
subnet_name: "{{ openstack_network_internal_subnet_name }}"
state: present
- name: ensure router has external network gateway
neutron_router_gateway:
auth_url: "{{ openstack_identity_public_url }}"
login_tenant_name: demo
login_username: demo
login_password: "{{ openstack_identity_demo_password }}"
router_name: "{{ openstack_router_name }}"
network_name: "{{ openstack_network_external_name }}"
state: present
- name: ping router external interface to verify connectivity
command: ping -c 4 {{ openstack_network_external_allocation_pool_start }}
changed_when: false