-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller-cinder.yml
166 lines (131 loc) · 5.4 KB
/
controller-cinder.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
#---
# - name: "Install and Configure OpenStack block stortage(cinder)"
# hosts: openstack
# remote_user: root
# gather_facts: yes
#
# tasks:
- name: "add cinder user (set in service project)"
shell: source ~/keystonerc && openstack user create --domain default --project service --password servicepassword cinder
args:
executable: /bin/bash
register: cinder_user
- debug: var=cinder_user.stdout_lines
- name: "add cinder user in admin role"
shell: source ~/keystonerc && openstack role add --project service --user cinder admin
args:
executable: /bin/bash
- name: "add service entry for cinder"
shell: source ~/keystonerc && ""openstack service create --name cinder --description "OpenStack Block Storage" volume""
args:
executable: /bin/bash
register: add_service
- debug: var=add_service.stdout_lines
- name: "add service entry for cinder2"
shell: source ~/keystonerc && ""openstack service create --name cinder2 --description "OpenStack Block Storage" volumev2""
args:
executable: /bin/bash
register: add_service
- debug: var=add_service.stdout_lines
- name: "add endpoint for nova (public,internal,admin)"
shell: source ~/keystonerc && ""openstack endpoint create --region RegionOne volume {{ item }} http://{{ ansible_host }}:8776/v1/%\(tenant_id\)s""
args:
executable: /bin/bash
register: result_end
with_items:
- public
- internal
- admin
- debug: var=result_end
- name: "add endpoint for nova (public,internal,admin)"
shell: source ~/keystonerc && ""openstack endpoint create --region RegionOne volumev2 {{ item }} http://{{ ansible_host }}:8776/v2/%\(tenant_id\)s""
args:
executable: /bin/bash
register: volume_endpoint
with_items:
- admin
- public
- internal
- debug: var=volume_endpoint
tags: volumev2
- name: "create cinder database"
mysql_db: name=cinder state=present
- name: "create cinder user"
mysql_user: name=cinder password=cinder123 priv='cinder.*:ALL,GRANT' host={{ item }}
with_items:
- localhost
- '%'
- xopenstack
- name: "Install cinder"
yum: name=openstack-cinder enablerepo=centos-openstack-ocata,epel state=present
- name: "Backup Original cinder configuation"
copy: remote_src=True src=/etc/cinder/cinder.conf dest=/etc/cinder/cinder.conf.org
- name: "copy cinder configuation"
copy: src=cinder.conf dest=/etc/cinder/cinder.conf mode=640 owner=root group=cinder
- name: "replace ansible_host in cinder conf"
replace: dest=/etc/cinder/cinder.conf regexp='10.0.0.30' replace={{ ansible_host }} backup=yes
- name: "cinder db sync"
raw: su -s /bin/bash cinder -c "cinder-manage db sync"
- name: "start and enable cinder services"
service: name={{ item }} state=started enabled=yes
with_items:
- openstack-cinder-api
- openstack-cinder-scheduler
tags: cinder_service
- name: "openstack cinder service"
shell: source ~/keystonerc && openstack volume service list
register: status_services
- debug: var=status_sevices.stdout_lines
- name: "Install openstack-cinder packages"
yum: name={{ item }} enablerepo=centos-openstack-ocata,epel state=present
with_items:
- openstack-cinder
- python2-crypto
- targetcli
- name: "Add Glance-api server into cinder conf "
lineinfile: dest=/etc/cinder/cinder.conf
line={{ item.line }}
insertafter={{ item.insertafter }}
with_items:
- { line: "glance_api_servers = http://{{ ansible_host }}:9292", insertafter: "transport_url= " }
- { line: "# Glance connection info", insertafter: "transport_url= " }
- name: "start and enable cinder-volume"
service: name=openstack-cinder-volume state=started enabled=yes
- name: "create volume for cinder storage"
raw: pvcreate /dev/vdb
- name: "Create volume group"
lvg:
vg: vg_volume01
pvs: /dev/vdb
pesize: 32
- name: "storage conf on cinder.conf"
lineinfile:
dest: /etc/cinder/cinder.conf
insertafter: EOF
create: true
state: present
line: |
[lvm]
iscsi_helper = lioadm
volume_group = vg_volume01
iscsi_ip_address = {{ ansible_host }}
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volumes_dir = $state_path/volumes
iscsi_protocol = iscsi
- name: "restart opestack-cinder"
service: name=openstack-cinder-volume state=restarted
- name: "add region in nova.conf"
lineinfile:
dest: /etc/nova/nova.conf
insertafter: EOF
create: true
state: present
line: |
[cinder]
os_region_name = RegionOne
- name: "restart openstack-nova compute"
service: name=openstack-nova-compute state=restarted
- name: "append volume_api_version to keystonrc"
raw: echo "export OS_VOLUME_API_VERSION=2" >> keystonerc
- name: "copy modified keystonerc to server"
copy: src=keystonerc dest=~/keystonerc mode=600