5a7267dec0cdf09a97ce2093a029efdc273e0ecc
[ta/caas-registry.git] / ansible / roles / swift / tasks / swift_main.yml
1 ---
2 # Copyright 2019 Nokia
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 - name: Get Swift pass from file
17   shell: 'grep "export SWIFT_PASS=" /etc/swift/usr/admin/env_file | awk -F"=" "{ print \$2 }"'
18   register: swift_password_for_template
19
20 - name: Get Swift pass from file
21   shell: 'grep "export SWIFT_USER=" /etc/swift/usr/admin/env_file | awk -F"=" "{ print \$2 }"'
22   register: swift_user_for_template
23
24 - name: Get Swift pass from file
25   shell: 'grep "export SWIFT_TENANT=" /etc/swift/usr/admin/env_file | awk -F"=" "{ print \$2 }"'
26   register: swift_tenant_for_template
27
28 - name: template config files
29   template:
30     src: "main/{{ item }}"
31     dest: "/etc/swift/main/{{ item }}"
32     owner: "{{ caas.uid.swift }}"
33     group: "{{ caas.uid.swift }}"
34     mode: 0640
35   with_items:
36     - account-server.conf
37     - container-server.conf
38     - object-server.conf
39     - proxy-server.conf
40     - swift.conf
41     - rsyncd.conf
42     - memcached
43     - nginx.conf
44   become_user: "root"
45
46 - name: Copy swift daemonset yaml
47   template:
48     src: main/swift_main.yml
49     dest: "{{ caas.manifests_directory }}/swift_main.yml"
50
51 - name:  Copy swift service yaml
52   template:
53     src: main/swift_service.yml
54     dest: "{{ caas.manifests_directory }}/swift_service.yml"
55
56 - name: create Swift daemonset object
57   kubectl:
58     manifest: "{{ caas.manifests_directory }}/swift_main.yml"
59     state: present
60   when: ( nodename | search("caas_master1") )
61
62 - name: Create Swift service
63   kubectl:
64     manifest: "{{ caas.manifests_directory }}/swift_service.yml"
65     state: present
66   when: ( nodename | search("caas_master1") )
67
68 - name: wait for swift service to start
69   wait_for:
70     host: "{{ caas.swift_url }}"
71     port: "{{ caas.swift_port }}"
72     state: started
73     timeout: 60