aboutsummaryrefslogtreecommitdiff
path: root/ansible/post-deploy.yml
blob: af565e544d7f11049f55d2dc7adb9e0143ecd278 (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
---
- name: Determining whether we need become=true
  hosts: localhost
  gather_facts: false
  tasks:
    - name: Get stats of {{ node_config }}
      ansible.builtin.stat:
        path: "{{ node_config }}"
      register: st

    - name: Set become fact
      ansible.builtin.set_fact:
        needs_root: "{{ not (st.stat.writeable | bool) }}"

- name: Creating clouds.yaml file on the deploy node
  hosts: localhost
  tasks:
    - name: Template out clouds.yaml
      become: "{{ needs_root }}"
      ansible.builtin.template:
        src: "templates/clouds.yaml.j2"
        dest: "{{ node_config }}/clouds.yaml"
        owner: "{{ ansible_facts.user_uid }}"
        group: "{{ ansible_facts.user_gid }}"
        mode: "0600"

- name: Creating admin openrc file on the deploy node
  hosts: localhost
  tasks:
    - name: Template out admin-openrc.sh
      become: "{{ needs_root }}"
      ansible.builtin.template:
        src: "templates/admin-openrc.sh.j2"
        dest: "{{ node_config }}/admin-openrc.sh"
        owner: "{{ ansible_facts.user_uid }}"
        group: "{{ ansible_facts.user_gid }}"
        mode: "0600"

    - name: Template out admin-openrc-system.sh
      become: "{{ needs_root }}"
      ansible.builtin.template:
        src: "templates/admin-openrc-system.sh.j2"
        dest: "{{ node_config }}/admin-openrc-system.sh"
        owner: "{{ ansible_facts.user_uid }}"
        group: "{{ ansible_facts.user_gid }}"
        mode: "0600"

    - name: Template out public-openrc.sh
      become: "{{ needs_root }}"
      ansible.builtin.template:
        src: "templates/public-openrc.sh.j2"
        dest: "{{ node_config }}/public-openrc.sh"
        owner: "{{ ansible_facts.user_uid }}"
        group: "{{ ansible_facts.user_gid }}"
        mode: "0600"

    - name: Template out public-openrc-system.sh
      become: "{{ needs_root }}"
      ansible.builtin.template:
        src: "templates/public-openrc-system.sh.j2"
        dest: "{{ node_config }}/public-openrc-system.sh"
        owner: "{{ ansible_facts.user_uid }}"
        group: "{{ ansible_facts.user_gid }}"
        mode: "0600"

    - name: Template out octavia-openrc.sh
      ansible.builtin.import_role:
        name: octavia
        tasks_from: openrc.yml
      vars:
        octavia_openrc_become: "{{ needs_root }}"
      when: enable_octavia | bool