-
Notifications
You must be signed in to change notification settings - Fork 0
/
neutron.yml
181 lines (152 loc) · 7.2 KB
/
neutron.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#---
# - name: "Openstack nwtworking playbook"
# hosts: openstack
# remote_user: root
# gather_facts: yes
#
# tasks:
- name: "add neutron user"
shell: source ~/keystonerc && openstack user create --domain default --project service --password servicepassword neutron
args:
executable: /bin/bash
register: neutron_user
- debug: var=neutron_user.stdout_lines
- name: "add neutron user in admin role"
shell: source ~/keystonerc && openstack role add --project service --user neutron admin
args:
executable: /bin/bash
register: neutron_admin
- debug: var=neutron_admin.stdout_lines
- name: "add service entry for neutron"
shell: source ~/keystonerc && openstack service create --name neutron --description "OpenStack Networking service" network
args:
executable: /bin/bash
- name: "add endpoints for neutron"
shell: source ~/keystonerc && openstack endpoint create --region RegionOne network {{ item }} http://{{ ansible_host }}:9696
args:
executable: /bin/bash
with_items:
- public
- internal
- admin
- name: "create nutron_ml2 db"
mysql_db: name=neutron_ml2 state=present
tags: db
- name: "create user with grant privileges"
mysql_user: name=neutron password=neutron123 priv='neutron_ml2.*:ALL,GRANT' host={{ item }}
with_items:
- localhost
- '%'
- xopenstack
tags: privilege
- name: "Install neutron openstack packages"
yum: name={{ item }} enablerepo=centos-openstack-ocata,epel state=present
with_items:
- openstack-neutron
- openstack-neutron-ml2
- openstack-neutron-openvswitch
- name: "Backup neutron original configuration"
copy: remote_src=True src=/etc/neutron/neutron.conf dest=/etc/neutron/neutron.conf.org
- name: "neutron configuration"
copy: src=neutron.conf dest=/etc/neutron/neutron.conf mode=640 owner=root group=neutron
- name: "replace ansible_host in nova conf"
replace: dest=/etc/neutron/neutron.conf regexp='192.168.122.185' replace={{ ansible_host }} backup=yes
tags: neutron
- name: "nuetron l3 agent configuration"
lineinfile: dest=/etc/neutron/l3_agent.ini
line={{ item.line }}
insertafter={{ item.insertafter }}
with_items:
- { line: "interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver", insertafter: "^#?interface_driver = <None>" }
- { line: "external_network_bridge = ", insertafter: "^#?external_network_bridge =" }
- name: "nuetron dhcp agent configuration"
lineinfile: dest=/etc/neutron/dhcp_agent.ini
line={{ item.line }}
insertafter={{ item.insertafter }}
with_items:
- { line: "interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver", insertafter: "^#?interface_driver = <None>" }
- { line: "dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq", insertafter: "^#?dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq" }
- { line: "enable_isolated_metadata = True", insertafter: "^#?enable_isolated_metadata = false" }
- name: "nuetron metadata agent configuation"
lineinfile: dest=/etc/neutron/metadata_agent.ini
line={{ item.line }}
insertafter={{ item.insertafter }}
with_items:
- { line: "nova_metadata_ip = {{ ansible_host }} ", insertafter: "^#?nova_metadata_ip = 127.0.0.1" }
- { line: "metadata_proxy_shared_secret = metadata_secret", insertafter: "^#?metadata_proxy_shared_secret =" }
tags: ip
- name: "nuetron ml2 agent configuration"
lineinfile: dest=/etc/neutron/plugins/ml2/ml2_conf.ini
line={{ item.line }}
insertafter={{ item.insertafter }}
with_items:
- { line: "extension_drivers = port_security", insertafter: '^\[ml2\]' }
- { line: "mechanism_drivers = openvswitch,l2population", insertafter: '^\[ml2\]' }
- { line: "tenant_network_types =", insertafter: '^\[ml2\]' }
- { line: "type_drivers = flat,vlan,gre,vxlan", insertafter: '^\[ml2\]' }
- { line: "enable_security_group = True", insertafter: '^#?enable_security_group = true' }
- { line: "firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver", insertafter: '^#?firewall_driver = <None>' }
- { line: "enable_ipset = True", insertafter: '^#?enable_ipset = True' }
- name: "Add nova configuration default section"
lineinfile: dest=/etc/nova/nova.conf
line={{ item.line }}
insertafter={{ item.insertafter }}
with_items:
- { line: "vif_plugging_timeout = 300", insertafter: '^transport_url = ' }
- { line: "vif_plugging_is_fatal = True", insertafter: '^transport_url = ' }
- { line: "firewall_driver = nova.virt.firewall.NoopFirewallDriver", insertafter: '^transport_url = ' }
- { line: "linuxnet_interface_driver = nova.network.linux_net.LinuxOVSInterfaceDriver", insertafter: '^transport_url = ' }
- { line: "use_neutron = True", insertafter: '^transport_url = ' }
- name: "neutron auth info"
lineinfile:
dest: /etc/nova/nova.conf
insertafter: EOF
create: true
state: present
line: |
[neutron]
url = http://{{ ansible_host }}:9696
auth_url = http://{{ ansible_host }}:35357
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = neutron
password = servicepassword
service_metadata_proxy = True
metadata_proxy_shared_secret = metadata_secret
tags: nova test
- name: "start and enable openvswitch"
service: name=openvswitch state=started enabled=yes
- name: "add ovs bridge"
shell: ovs-vsctl add-br br-int
args:
executable: /bin/bash
- name: "ml2.conf symlink to plugin"
shell: ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
args:
executable: /bin/bash
- name: "nuetron Db_sync"
shell: neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head
become: true
become_method: su
become_user: neutron
become_flags: '-s /bin/bash'
tags: neutron
- name: "start and enable neutron services"
service: name={{ item }} state=started enabled=yes
with_items:
- neutron-dhcp-agent
- neutron-l3-agent
- neutron-metadata-agent
- neutron-openvswitch-agent
- name: "restart nova services"
service: name={{ item }} state=restarted
with_items:
- openstack-nova-api
- openstack-nova-compute
- name: "start and enable neutron-server"
service: name=neutron-server state=started enabled=yes
- name: "network agent list"
shell: source ~/keystonerc && openstack network agent list