summaryrefslogtreecommitdiff
path: root/openstack/usr/share/openstack/swift-controller.yml
blob: e368a0c663449e480a312a177bba8730992dd0d5 (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
---
- hosts: localhost
  vars_files:
    - swift-vars.yml
  vars:
    - ring_names: ['account', 'container', 'object']
  remote_user: root
  tasks:
    - user: name=swift comment="Swift user"
    - file: path=/etc/swift owner=swift group=swift

    - keystone_user: >
        user=swift
        password={{ SWIFT_ADMIN_PASSWORD }}
        tenant=service
        token={{ KEYSTONE_TEMPORARY_ADMIN_TOKEN }}

    - keystone_user: >
        role=admin
        user=swift
        tenant=service
        token={{ KEYSTONE_TEMPORARY_ADMIN_TOKEN }}

    - keystone_service: >
        name=swift
        type=object-store
        description="OpenStack Object Storage"
        publicurl={{ SWIFT_PUBLIC_URL }}
        internalurl={{ SWIFT_INTERNAL_URL 
            | default('http://127.0.0.1:8080/v1/AUTH_%(tenant_id)s') }}
        adminurl={{ SWIFT_ADMIN_URL }}
        region='RegionOne'
        token={{ KEYSTONE_TEMPORARY_ADMIN_TOKEN }}

    - shell: test -f /etc/swift/{{ item }}.ring.gz
      ignore_errors: True
      with_items: ring_names
      register: rings

    - name: Create ring
      shell: swift-ring-builder {{ item.item }}.builder create {{ SWIFT_PART_POWER }}
         {{ SWIFT_REPLICAS }}  {{ SWIFT_MIN_PART_HOURS }}
      when: item.rc != 0        # if not already present
      with_items: rings.results

    - name: Add each storage node to the ring
      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.results
        - SWIFT_STORAGE_DEVICES

    - name: Rebalance the ring
      shell: swift-ring-builder {{ item.item }}.builder rebalance
      when: item.rc != 0
      with_items: rings.results

    - name: Distribute ring configuration files
      shell: cp {{ item.item }}.ring.gz /etc/swift
      when: item.rc != 0
      with_items: rings.results