aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYibo Cai <yibo.cai@linaro.org>2017-08-01 15:15:54 +0800
committerYibo Cai <yibo.cai@linaro.org>2017-08-01 15:50:59 +0800
commit6d8513303b671fe174eab8dbec8f822477fde5cf (patch)
tree0e314dce5e736125fd6083b50866f3cc333a7cef
parent285b154b0ba859a052f984934ca00a3aff57215b (diff)
Ansible: Create Swift partition
Create xfs partition for Swift. Fix bug #3143 and #3165 Change to absolute path for calling command "keystone-manage". Fix bug #3166. Change-Id: Ic9e6817db6da148350d86070a4775163c613ceeb
-rw-r--r--ansible/group_vars/all8
-rw-r--r--ansible/roles/ceph/tasks/rgw.yml2
-rw-r--r--ansible/roles/swift/tasks/main.yml20
-rw-r--r--ansible/roles/swift/tasks/part.yml13
4 files changed, 32 insertions, 11 deletions
diff --git a/ansible/group_vars/all b/ansible/group_vars/all
index d4b4f4a..0967801 100644
--- a/ansible/group_vars/all
+++ b/ansible/group_vars/all
@@ -50,8 +50,14 @@ mysql_host: "{{ hostvars[groups['mysql_servers'][0]]['ansible_fqdn'] }}"
rabbit_host: "{{ hostvars[groups['rabbit_servers'][0]]['ansible_fqdn'] }}"
rgw_host: "{{ hostvars[groups['rgw_servers'][0]]['ansible_fqdn'] }}"
swift_host: "{{ hostvars[groups['swift_servers'][0]]['ansible_fqdn'] }}"
+
+#WARNING: all existing data in swift partition will be destroyed!
swift_partition:
- - sdb
+ - sdb1
+
+swift_object_ring_uri: "z1-{{ansible_default_ipv4.address}}:6200"
+swift_container_ring_uri: "z1-{{ansible_default_ipv4.address}}:6201"
+swift_account_ring_uri: "z1-{{ansible_default_ipv4.address}}:6202"
openstack_debug_logging: "True"
keystone_debug_logging: "{{openstack_debug_logging}}"
diff --git a/ansible/roles/ceph/tasks/rgw.yml b/ansible/roles/ceph/tasks/rgw.yml
index 67fa3c7..601e31b 100644
--- a/ansible/roles/ceph/tasks/rgw.yml
+++ b/ansible/roles/ceph/tasks/rgw.yml
@@ -6,7 +6,7 @@
ignore_errors: False
- name: Generate Keystone SSL key
- shell: keystone-manage pki_setup --keystone-user keystone --keystone-group keystone
+ shell: /srv/keystone/bin/keystone-manage pki_setup --keystone-user keystone --keystone-group keystone
ignore_errors: False
- name: Create SSL key path in Ceph
diff --git a/ansible/roles/swift/tasks/main.yml b/ansible/roles/swift/tasks/main.yml
index 7a281d9..0cbc240 100644
--- a/ansible/roles/swift/tasks/main.yml
+++ b/ansible/roles/swift/tasks/main.yml
@@ -27,6 +27,8 @@
command: ln -s /srv/swift/bin/swift-ring-builder /usr/bin/swift-ring-builder
when: stat_result.stat.exists == false
+- {include: part.yml, with_items: "{{swift_partition}}"}
+
- name: Check swift exists
stat:
path: /usr/bin/swift
@@ -36,25 +38,25 @@
command: ln -s /srv/openstack-cli/bin/swift /usr/bin/swift
when: stat_result_swift.stat.exists == false
-- name: Create Swift storage mount point /srv/node/sdb1
+- name: Create Swift storage mount point /srv/node/sdb
with_items: "{{swift_partition}}"
file:
- path: /srv/{{item}}1
+ path: /srv/{{item}}
state: directory
- name: Mount Swift storage partition
with_items: "{{swift_partition}}"
mount:
- name: /srv/node/{{item}}1
- src: /dev/{{item}}1
+ name: /srv/node/{{item}}
+ src: /dev/{{item}}
fstype: xfs
opts: noatime,nodiratime,nobarrier,logbufs=8
state: mounted
-- name: Change ownship of /srv/node/sdb1
+- name: Change ownship of /srv/node/sdb
with_items: "{{swift_partition}}"
file:
- path: /srv/node/{{item}}1
+ path: /srv/node/{{item}}
owner: "{{swift_user}}"
group: "{{swift_user}}"
@@ -63,7 +65,7 @@
- name: Update Swift Account RING
with_items: "{{swift_partition}}"
- command: /usr/bin/swift-ring-builder /etc/swift/account.builder add z1-127.0.0.1:6202/{{item}}1 100
+ command: /usr/bin/swift-ring-builder /etc/swift/account.builder add {{swift_account_ring_uri}}/{{item}} 100
- name: Distribute Swift Account RING
command: /usr/bin/swift-ring-builder /etc/swift/account.builder rebalance
@@ -73,7 +75,7 @@
- name: Update Swift Container RING
with_items: "{{swift_partition}}"
- command: /usr/bin/swift-ring-builder /etc/swift/container.builder add z1-127.0.0.1:6201/{{item}}1 100
+ command: /usr/bin/swift-ring-builder /etc/swift/container.builder add {{swift_container_ring_uri}}/{{item}} 100
- name: Distribute Swift Container RING
command: /usr/bin/swift-ring-builder /etc/swift/container.builder rebalance
@@ -83,7 +85,7 @@
- name: Update Swift Object RING
with_items: "{{swift_partition}}"
- command: /usr/bin/swift-ring-builder /etc/swift/object.builder add z1-127.0.0.1:6200/{{item}}1 100
+ command: /usr/bin/swift-ring-builder /etc/swift/object.builder add {{swift_object_ring_uri}}/{{item}} 100
- name: Distribute Swift Object RING
command: /usr/bin/swift-ring-builder /etc/swift/object.builder rebalance
diff --git a/ansible/roles/swift/tasks/part.yml b/ansible/roles/swift/tasks/part.yml
new file mode 100644
index 0000000..73ee9c0
--- /dev/null
+++ b/ansible/roles/swift/tasks/part.yml
@@ -0,0 +1,13 @@
+- name: Check if swift partition is prepared
+ shell: /sbin/blkid /dev/{{item}} | grep 'TYPE="xfs"'
+ ignore_errors: true
+ changed_when: false
+ register: swift_part_prepared
+
+- name: Create XFS for swift partition
+ when: (swift_part_prepared.rc != 0) or swift_force_prepare
+ filesystem:
+ fstype: xfs
+ dev: /dev/{{item}}
+ force: yes
+ ignore_errors: true