Allow disabling ipxe for provisioning
[apex.git] / lib / ansible / playbooks / configure_undercloud.yml
1 ---
2 - hosts: all
3   tasks:
4     - name: Generate SSH key for stack if missing
5       shell: test -e ~/.ssh/id_rsa || ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
6     - name: Fix ssh key for stack
7       shell: restorecon -r /home/stack
8       become: yes
9     - file:
10         path: /home/stack/nics
11         state: directory
12         owner: stack
13         group: stack
14         mode: 0775
15     - copy:
16         src: /root/.ssh/id_rsa.pub
17         dest: /home/stack/jumphost_id_rsa.pub
18         owner: stack
19         group: stack
20         mode: 0644
21     - copy:
22         src: "{{ apex_temp_dir }}/{{ item }}.yaml"
23         dest: "/home/stack/nics/{{ item }}.yaml"
24         owner: stack
25         group: stack
26         mode: 0644
27       with_items:
28         - controller
29         - compute
30     - lineinfile:
31         path: /etc/sudoers
32         regexp: 'Defaults\s*requiretty'
33         state: absent
34       become: yes
35     - name: openstack-configs undercloud
36       shell: openstack-config --set undercloud.conf DEFAULT {{ item }}
37       with_items: "{{ undercloud_config }}"
38     - name: openstack-configs ironic
39       shell: openstack-config --set /etc/ironic/ironic.conf {{ item }}
40       become: yes
41       with_items: "{{ ironic_config }}"
42     - lineinfile:
43         path: /usr/lib/python2.7/site-packages/ironic/common/pxe_utils.py
44         regexp: '_link_ip_address_pxe_configs'
45         line: '        _link_mac_pxe_configs(task)'
46       when: aarch64
47     - block:
48         - name: undercloud install
49           shell: openstack undercloud install &> apex-undercloud-install.log
50           become: yes
51           become_user: stack
52       rescue:
53         - name: undercloud install retry
54           shell: openstack undercloud install >> apex-undercloud-install.log 2>&1
55           become: yes
56           become_user: stack
57       always:
58         - name: fetch undercloud log
59           fetch:
60             src: /home/stack/apex-undercloud-install.log
61             dest: "{{ apex_temp_dir }}/"
62             flat: yes
63     - name: openstack-configs nova
64       shell: openstack-config --set /etc/nova/nova.conf DEFAULT {{ item }}
65       become: yes
66       with_items: "{{ nova_config }}"
67     - name: restart nova services
68       service:
69         name: "{{ item }}"
70         state: restarted
71         enabled: yes
72       with_items:
73         - openstack-nova-conductor
74         - openstack-nova-compute
75         - openstack-nova-api
76         - openstack-nova-scheduler
77     - name: openstack-configs neutron
78       shell: openstack-config --set /etc/neutron/neutron.conf DEFAULT {{ item }}
79       become: yes
80       with_items: "{{ neutron_config }}"
81     - name: restart neutron services
82       service:
83         name: "{{ item }}"
84         state: restarted
85         enabled: yes
86       with_items:
87         - neutron-server
88         - neutron-dhcp-agent
89     - name: configure external network vlan ifcfg
90       template:
91         src: external_vlan_ifcfg.yml.j2
92         dest: "/etc/sysconfig/network-scripts/ifcfg-vlan{{ external_network.vlan }}"
93         owner: root
94         group: root
95         mode: 0644
96       become: yes
97       when:
98         - external_network.vlan != "native"
99         - external_network.enabled
100     - name: bring up vlan ifcfg
101       shell: "ifup vlan{{ external_network.vlan }}"
102       become: yes
103       when:
104         - external_network.vlan != "native"
105         - external_network.enabled
106     - name: assign IP to native eth2
107       shell: ip a a {{ external_network.ip }}/{{ external_network.prefix }} dev eth2
108       become: yes
109       when:
110         - external_network.vlan == "native"
111         - external_network.enabled
112         - not aarch64
113     - name: bring up eth2
114       shell: ip link set up dev eth2
115       when:
116         - external_network.vlan == "native"
117         - external_network.enabled
118         - not aarch64
119       become: yes
120     - name: assign IP to native eth0 if aarch64
121       shell: ip a a {{ external_network.ip }}/{{ external_network.prefix }} dev eth0
122       become: yes
123       when:
124         - external_network.vlan == "native"
125         - external_network.enabled
126         - aarch64
127     - name: bring up eth0 if aarch64
128       shell: ip link set up dev eth0
129       when:
130         - external_network.vlan == "native"
131         - external_network.enabled
132         - aarch64
133       become: yes
134     - name: fetch storage environment file
135       fetch:
136         src: /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml
137         dest: "{{ apex_temp_dir }}/"
138         flat: yes
139
140 - include: undercloud_aarch64.yml
141   when: aarch64