blob: 2bbb5ed1258ab0831ceb7ebeeaff4818a05f442f (
plain)
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
|
---
- hosts: localhost
vars_files:
- "/etc/openstack/cinder.conf"
tasks:
- name: Check that CINDER_DEVICE exists
stat:
path: /dev/{{ CINDER_DEVICE }}
register: cinder_device_stats
failed_when: cinder_device_stats.stat.exists == false
- name: Configure LVM group for cinder
lvg:
vg: cinder-volumes
pvs: /dev/{{ CINDER_DEVICE }}
- lineinfile:
dest: /etc/lvm/lvm.conf
regexp: '# filter = \[ \"a\/\.\*/\" \]'
line: ' filter = [ "a/{{ CINDER_DEVICE }}/", "r/.*/" ]'
backrefs: yes
- name: generate InitiatorName for iscsi
shell: iscsi-iname
register: initiator_name
- lineinfile:
dest: /etc/iscsi/initiatorname.iscsi
regexp: '^InitiatorName=$'
line: 'InitiatorName={{ initiator_name.stdout }}'
backrefs: yes
- name: Update kernel module dependencies
command: depmod -a
- name: Enable and start iscsid and target services
service:
name: "{{ item }}"
enabled: yes
state: started
with_items:
- lvm2-lvmetad
- target
- iscsid
- name: Create the cinder user.
user:
name: cinder
comment: Openstack Cinder Daemons
shell: /sbin/nologin
home: /var/lib/cinder
- name: Create the /var folders for cinder
file:
path: "{{ item }}"
state: directory
owner: cinder
group: cinder
with_items:
- /var/run/cinder
- /var/lock/cinder
- /var/log/cinder
- /var/lib/cinder
- /var/lib/cinder/volumer
- name: Create /etc/cinder directory
file:
path: /etc/cinder
state: directory
- name: Add the configuration needed for cinder in /etc/cinder using templates
template:
src: /usr/share/openstack/cinder/{{ item }}
dest: /etc/cinder/{{ item }}
with_lines:
- cd /usr/share/openstack/cinder && find -type f
- name: Create cinder service user in service tenant
keystone_user:
user: "{{ CINDER_USER }}"
password: "{{ CINDER_PASSWORD }}"
tenant: service
token: "{{ KEYSTONE_TEMPORARY_ADMIN_TOKEN }}"
- name: Assign admin role to cinder service user in the service tenant
keystone_user:
role: admin
user: "{{ CINDER_USER }}"
tenant: service
token: "{{ KEYSTONE_TEMPORARY_ADMIN_TOKEN }}"
- name: Add cinder endpoint
keystone_service:
name: cinder
type: volume
description: Openstack Block Storage
publicurl: 'http://{{ CONTROLLER_HOST_ADDRESS }}:8776/v1/%(tenant_id)s'
internalurl: 'http://{{ CONTROLLER_HOST_ADDRESS }}:8776/v1/%(tenant_id)s'
adminurl: 'http://{{ CONTROLLER_HOST_ADDRESS }}:8776/v1/%(tenant_id)s'
region: regionOne
token: "{{ KEYSTONE_TEMPORARY_ADMIN_TOKEN }}"
- name: Add cinderv2 endpoint
keystone_service:
name: cinderv2
type: volumev2
description: Openstack Block Storage
publicurl: 'http://{{ CONTROLLER_HOST_ADDRESS }}:8776/v2/%(tenant_id)s'
internalurl: 'http://{{ CONTROLLER_HOST_ADDRESS }}:8776/v2/%(tenant_id)s'
adminurl: 'http://{{ CONTROLLER_HOST_ADDRESS }}:8776/v2/%(tenant_id)s'
region: regionOne
token: "{{ KEYSTONE_TEMPORARY_ADMIN_TOKEN }}"
- name: Create postgresql user for cinder
postgresql_user:
name: "{{ CINDER_DB_USER }}"
sudo: yes
sudo_user: cinder
- name: Create database for cinder services
postgresql_db:
name: cinder
owner: "{{ CINDER_DB_USER }}"
sudo: yes
sudo_user: cinder
- name: Initiate cinder database
cinder_manage:
action: dbsync
sudo: yes
sudo_user: cinder
- name: Enable and start openstack-cinder services
service:
name: "{{ item }}"
enabled: yes
state: started
with_items:
- openstack-cinder-api
- openstack-cinder-scheduler
- openstack-cinder-volume
- openstack-cinder-backup
|