-
Notifications
You must be signed in to change notification settings - Fork 0
/
nova.yml
215 lines (174 loc) · 7.35 KB
/
nova.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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#---
# - name: "Install and Configure OpenStack Compute Service (Nova)"
# hosts: openstack
# remote_user: root
# gather_facts: yes
#
# tasks:
- name: "add nova user (set in service project)"
shell: source ~/keystonerc && openstack user create --domain default --project service --password servicepassword nova
args:
executable: /bin/bash
register: nova_user
- debug: var=nova_user.stdout_lines
- name: "add nova user in admin role"
shell: source ~/keystonerc && openstack role add --project service --user nova admin
args:
executable: /bin/bash
- name: "add placement user (set in service project)"
shell: source ~/keystonerc && openstack user create --domain default --project service --password servicepassword placement
args:
executable: /bin/bash
register: placement_user
- debug: var=placement_user.stdout_lines
- name: "add placement user in admin role"
shell: source ~/keystonerc && openstack role add --project service --user placement admin
args:
executable: /bin/bash
- name: "add service entry for nova"
shell: source ~/keystonerc && ""openstack service create --name nova --description "OpenStack Compute service" compute""
args:
executable: /bin/bash
register: add_service
- debug: var=add_service.stdout_lines
- name: "add service entry for placement"
shell: source ~/keystonerc && ""openstack service create --name placement --description "OpenStack Compute Placement service" placement""
args:
executable: /bin/bash
register: service_placement
- debug: var=service_placement.stdout_lines
- name: "add endpoint for nova (public,internal,admin)"
shell: source ~/keystonerc && ""openstack endpoint create --region RegionOne compute {{ item }} http://{{ ansible_host }}:8774/v2.1/%\(tenant_id\)s""
args:
executable: /bin/bash
register: result
with_items:
- public
- internal
- admin
- debug: var=result
- name: "add endpoint for nova placement (public,internal,admin)"
shell: source ~/keystonerc && ""openstack endpoint create --region RegionOne placement {{ item }} http://{{ ansible_host }}:8778""
args:
executable: /bin/bash
# register: placement
with_items:
- public
- internal
- admin
# - debug: var=placement
tags: placement
- name: "create Nova database"
mysql_db: name={{ item }} state=present
with_items:
- nova
- nova_api
- nova_placement
- nova_cell0
tags: db
- name: "create nova user"
mysql_user: name=nova password=nova123 priv='nova.*:ALL,GRANT/nova_cell0.*:ALL,GRANT/nova_api.*:ALL,GRANT/nova_placement.*:ALL,GRANT' host={{ item }}
with_items:
- localhost
- '%'
- xopenstack
- name: "Install nova"
yum: name=openstack-nova enablerepo=centos-openstack-ocata,epel state=present
- name: "Backup Original nova configuation"
copy: remote_src=True src=/etc/nova/nova.conf dest=/etc/nova/nova.conf.org
- name: "copy nova configuation"
copy: src=nova.conf dest=/etc/nova/nova.conf mode=640 owner=root group=nova
- name: "replace ansible_host in nova conf"
replace: dest=/etc/nova/nova.conf regexp='192.168.122.185' replace={{ ansible_host }} backup=yes
- name: "nova-placement-api configuration"
lineinfile: dest=/etc/httpd/conf.d/00-nova-placement-api.conf
line={{ item.line }}
insertbefore={{ item.insertbefore }}
with_items:
- { line: " </Directory>", insertbefore: "</VirtualHost>" }
- { line: " Require all granted", insertbefore: "</Directory>" }
- { line: " <Directory /usr/bin>", insertbefore: "Require all granted" }
- name: "Nova DB-Sync"
shell: "{{ item }}"
with_items:
- nova-manage api_db sync
- nova-manage cell_v2 map_cell0 --database_connection mysql+pymysql://nova:nova123@{{ ansible_host }}/nova_cell0
- nova-manage db sync
- nova-manage cell_v2 create_cell --name cell1 --database_connection mysql+pymysql://nova:nova123@{{ ansible_host }}/nova --transport-url rabbit://openstack:password@{{ ansible_host }}:5672
become: true
become_method: su
become_user: nova
become_flags: '-s /bin/bash'
tags: nova_sync
- name: "restart httpd"
service: name=httpd state=restarted
tags: httpd
- name: "chnage ownership to nova logs*"
shell: chown nova. /var/log/nova/nova-placement-api.log
args:
executable: /bin/bash
tags: chown
- name: "start and enable nova services"
service: name={{ item }} state=started enabled=yes
with_items:
- openstack-nova-api
- openstack-nova-cert
- openstack-nova-consoleauth
- openstack-nova-conductor
- openstack-nova-scheduler
- openstack-nova-novncproxy
tags: nova_service
- name: "openstack compute status"
shell: source ~/keystonerc && openstack compute service list
register: status
- debug: var=status.stdout_lines
# tags: nova_compute_status
- name: "Install KVM Hypervisor"
yum: name={{ item }} state=present
with_items:
- qemu-kvm
- libvirt
- virt-install
- bridge-utils
- name: "start and enable libvirtd"
service: name=libvirtd state=started enabled=yes
- name: "Copy ifcfg-br0 conf file"
copy: src=ifcfg-br0 dest=/etc/sysconfig/network-scripts/ifcfg-br0 mode=644 owner=root group=root
- name: "Copy ifcfg-br0 conf file"
copy: src=ifcfg-eth0.206 dest=/etc/sysconfig/network-scripts/ifcfg-eth0.206 mode=644 owner=root group=root
- name: "Reboot"
command: /sbin/shutdown -r +1
async: 0
poll: 0
ignore_errors: true
- name: Waiting for shutdown
local_action: wait_for host={{ ansible_host }} port=22 state=stopped
- name: Waiting for restart
local_action: wait_for host={{ ansible_host }} port=22 state=started
- name: "Install Openstack nova compute package"
yum: name=openstack-nova-compute enablerepo=centos-openstack-ocata,epel state=present
- name: "enable VNC"
lineinfile:
dest: /etc/nova/nova.conf
line: "{{ item }}"
insertbefore: EOF
with_items:
- "[vnc]"
- "enabled = True"
- "vncserver_listen = 0.0.0.0"
- "vncserver_proxyclient_address = {{ ansible_host }}"
- "novncproxy_base_url = http://{{ ansible_host }}:6080/vnc_auto.html"
- name: "start and enble nova compute service"
service: name=openstack-nova-compute state=started enabled=yes
- name: "discover compute node"
shell: nova-manage cell_v2 discover_hosts
become: true
become_method: su
become_user: nova
become_flags: '-s /bin/bash'
- name: "compute service list"
shell: source ~/keystonerc && openstack compute service list
register: compute
- debug: var=compute
- name: "stop and disable firewall"
service: name=firewalld state=stopped enabled=no