From 689b17c4b7d5708319b154725ec22c8c2c4be532 Mon Sep 17 00:00:00 2001 From: Richard Ipsum Date: Fri, 6 Mar 2015 15:15:01 +0000 Subject: swift-controller.yml: Only create rings when they're not already there This whole thing should be encapsulated somehow so we're not repating the conditional, but I don't know how to do that with ansible at the moment. --- openstack/usr/share/openstack/swift-controller.yml | 24 ++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/openstack/usr/share/openstack/swift-controller.yml b/openstack/usr/share/openstack/swift-controller.yml index 7f180534..5114de5c 100644 --- a/openstack/usr/share/openstack/swift-controller.yml +++ b/openstack/usr/share/openstack/swift-controller.yml @@ -32,22 +32,30 @@ region='RegionOne' token={{ KEYSTONE_TEMPORARY_ADMIN_TOKEN }} + - shell: test -f /etc/swift/{{ item }}.ring.gz + with_items: rings + register: rings-exist + - name: Create ring - shell: swift-ring-builder {{ item }}.builder create {{ SWIFT_PART_POWER }} + shell: swift-ring-builder {{ item.item }}.builder create {{ SWIFT_PART_POWER }} {{ SWIFT_REPLICAS }} {{ SWIFT_MIN_PART_HOURS }} - with_items: rings + when: item.rc != 0 + with_items: rings-exist.results - name: Add each storage node to the ring - shell: swift-ring-builder {{ item[0] }}.builder + shell: swift-ring-builder {{ item[0].item }}.builder add r1z1-{{ item[1].ip }}:6002/{{ item[1].device }} {{ item[1].weight }} + when: item[0].rc != 0 with_nested: - - rings + - rings-exist.results - SWIFT_STORAGE_DEVICES - name: Rebalance the ring - shell: swift-ring-builder {{ item }}.builder rebalance - with_items: rings + shell: swift-ring-builder {{ item.item }}.builder rebalance + when: item.rc != 0 + with_items: rings-exist.results - name: Distribute ring configuration files - shell: cp {{ item }}.ring.gz /etc/swift - with_items: rings + shell: cp {{ item.item }}.ring.gz /etc/swift + when: item.rc != 0 + with_items: rings-exist.results -- cgit v1.2.1