summaryrefslogtreecommitdiffstats
path: root/lib/ansible/playbooks/deploy_overcloud.yml
blob: 9a405814f1ced993a842e3f73f700fb1afbb6fb8 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
---
- hosts: all
  tasks:
    - name: Copy all files to undercloud
      copy:
        src: "{{ apex_temp_dir }}/{{ item }}"
        dest: "/home/stack/{{ item }}"
        owner: stack
        group: stack
        mode: 0644
      with_items:
        - network-environment.yaml
        - instackenv.json
        - overcloud-full.qcow2
        - overcloud-full.vmlinuz
        - overcloud-full.initrd
        - ironic-python-agent.initramfs
        - ironic-python-agent.kernel
        - deploy_command
        - virtual-environment.yaml
        - baremetal-environment.yaml
        - kubernetes-environment.yaml
        - "{{ apex_env_file }}"
    - name: Copy ansible.cfg data to undercloud in aarch64
      copy:
        src: "{{ apex_temp_dir }}/ansible.cfg"
        dest: "/home/stack/ansible.cfg"
        owner: stack
        group: stack
        mode: 0644
      when: aarch64
    - name: Copy network data to undercloud
      copy:
        src: "{{ apex_temp_dir }}/network_data.yaml"
        dest: "/home/stack/network_data.yaml"
        owner: stack
        group: stack
        mode: 0644
      when: os_version != 'ocata'
    - copy:
        src: "{{ apex_temp_dir }}/storage-environment.yaml"
        dest: /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml
        owner: root
        group: root
        mode: 0664
    - copy:
        src: "{{ apex_temp_dir }}/neutron-opendaylight-sriov.yaml"
        dest: /usr/share/openstack-tripleo-heat-templates/environments/services/neutron-opendaylight-sriov.yaml
        owner: root
        group: root
        mode: 0664
    - name: Remove Ceph OSD from ceph storage role
      lineinfile:
        path: /usr/share/openstack-tripleo-heat-templates/roles_data.yaml
        line: '    - OS::TripleO::Services::CephOSD'
        owner: root
        group: root
        state: absent
      become: yes
    - name: Insert Ceph OSDs into Compute role
      lineinfile:
        path: /usr/share/openstack-tripleo-heat-templates/roles_data.yaml
        insertbefore:  '^\s*-\sOS::TripleO::Services::NovaCompute$'
        line: '    - OS::TripleO::Services::CephOSD'
        owner: root
        group: root
      become: yes
    - name: Insert Ceph OSDs into Controller role
      lineinfile:
        path: /usr/share/openstack-tripleo-heat-templates/roles_data.yaml
        insertbefore:  '^\s*-\sOS::TripleO::Services::CephRbdMirror$'
        line: '    - OS::TripleO::Services::CephOSD'
        owner: root
        group: root
      become: yes
    - name: Insert External network into Compute role
      shell: |
        ruby -e '
        require "yaml"
        data = YAML.load(File.read("/usr/share/openstack-tripleo-heat-templates/roles_data.yaml"))
        if data[1]["networks"].is_a?(Array)
          data[1]["networks"].push("External")
        elsif data[1]["networks"].is_a?(Hash)
          data[1]["networks"].merge!("External"=> { "subnet" => "external_subnet" })
        else
          raise "Unable to determine data to modify in roles_data.yaml"
        end
        data[1]["default_route_networks"] = Array.new(["External"])
        File.open("/usr/share/openstack-tripleo-heat-templates/roles_data.yaml", "w") { |f| f.write(data.to_yaml) }
        '
      become: yes
    - name: Upload glance images
      shell: "{{ stackrc }} && openstack overcloud image upload"
      become: yes
      become_user: stack
    - name: Import inventory (baremetal)
      shell: "{{ stackrc }} && openstack overcloud node import instackenv.json"
      when: introspect
    - name: Introspect inventory (baremetal)
      shell: "{{ stackrc }} && openstack overcloud node introspect --all-manageable --provide"
      when: introspect
    - name: Import inventory (virtual)
      shell: "{{ stackrc }} && openstack overcloud node import --provide instackenv.json"
      when: not introspect
    - name: Set flavors
      shell: '{{ stackrc }} && openstack flavor set --property "cpu_arch"="{{ ansible_architecture }}" {{ item }}'
      with_items:
        - baremetal
        - control
        - compute
    - name: Re-enable ceph config for aarch64
      replace:
        path: "/usr/share/ceph-ansible/roles/ceph-client/tasks/create_users_keys.yml"
        regexp: "x86_64"
        replace: "aarch64"
        backup: yes
      when: aarch64
    - name: Configure DNS server for ctlplane network
      shell: "{{ stackrc }} && openstack subnet set ctlplane-subnet {{ dns_server_args }}"
    - name: Update NIC templates before deployment
      shell: >
        /usr/share/openstack-tripleo-heat-templates/tools/merge-new-params-nic-config-script.py
        -n /home/stack/network_data.yaml -t /home/stack/nics/{{ item }}.yaml --discard-comments True
        --role-name Controller
      become: yes
      become_user: stack
      with_items:
        - controller
        - compute
    - block:
        - name: Execute Overcloud Deployment
          shell: "{{ stackrc }} && bash deploy_command"
          become: yes
          become_user: stack
      rescue:
        - name: Show overcloud failures
          shell: "{{ stackrc }} && openstack stack failures list overcloud --long"
          become: yes
          become_user: stack
      always:
        - name: Archive Mistral logs
          archive:
            path:
             - /var/lib/mistral
             - /var/log/mistral
            dest: /root/mistral_logs.tar.gz
          become: yes
        - name: Fetch mistral logs
          fetch:
            src: /root/mistral_logs.tar.gz
            dest: "{{ apex_temp_dir }}/"
            flat: yes
          become: yes
    - name: Show Keystone output
      shell: "{{ overcloudrc }} && {{ item }}"
      when: debug and vim == 'openstack'
      with_items:
        - openstack endpoint list
        - openstack service list
    - name: Get overcloud nodes and IPs
      shell: "{{ stackrc }} && openstack server list -f json"
      register: nova_list
    - name: Write nova list output to file
      local_action: copy content="{{ nova_list.stdout }}" dest="{{ apex_temp_dir }}/nova_output"
    - name: Fetch overcloudrc
      fetch:
        src: /home/stack/overcloudrc
        dest: "{{ apex_temp_dir }}/"
        flat: yes