aarch64: Add kpti=off similar to x86_64 nopti
[fuel.git] / mcp / patches / salt-formula-maas / 0006-curtin-Add-Bionic-support.patch
1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2019 Mirantis Inc., Enea AB and others.
3 :
4 : All rights reserved. This program and the accompanying materials
5 : are made available under the terms of the Apache License, Version 2.0
6 : which accompanies this distribution, and is available at
7 : http://www.apache.org/licenses/LICENSE-2.0
8 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
9 From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
10 Date: Wed, 16 Oct 2019 15:02:39 +0200
11 Subject: [PATCH] curtin: Add Bionic support
12
13 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
14 ---
15  .../curtin_userdata_amd64_generic_bionic      | 84 +++++++++++++++++++
16  .../curtin_userdata_arm64_generic_bionic      | 79 +++++++++++++++++
17  maas/region.sls                               | 24 ++++++
18  3 files changed, 187 insertions(+)
19  create mode 100644 maas/files/curtin_userdata_amd64_generic_bionic
20  create mode 100644 maas/files/curtin_userdata_arm64_generic_bionic
21
22 diff --git a/maas/files/curtin_userdata_amd64_generic_bionic b/maas/files/curtin_userdata_amd64_generic_bionic
23 new file mode 100644
24 index 0000000..11af3cf
25 --- /dev/null
26 +++ b/maas/files/curtin_userdata_amd64_generic_bionic
27 @@ -0,0 +1,84 @@
28 +{%- from "maas/map.jinja" import cluster with context %}
29 +{%- raw %}
30 +#cloud-config
31 +debconf_selections:
32 + maas: |
33 +  {{for line in str(curtin_preseed).splitlines()}}
34 +  {{line}}
35 +  {{endfor}}
36 +early_commands:
37 +  thin_tools_install: ["sh", "-c", "apt-get update --quiet && apt-get --assume-yes install thin-provisioning-tools"]
38 +{{if third_party_drivers and driver}}
39 +  {{py: key_string = ''.join(['\\x%x' % x for x in map(ord, driver['key_binary'])])}}
40 +  driver_00_get_key: /bin/echo -en '{{key_string}}' > /tmp/maas-{{driver['package']}}.gpg
41 +  driver_01_add_key: ["apt-key", "add", "/tmp/maas-{{driver['package']}}.gpg"]
42 +  driver_02_add: ["add-apt-repository", "-y", "deb {{driver['repository']}} {{node.get_distro_series()}} main"]
43 +  driver_03_update_install: ["sh", "-c", "apt-get update --quiet && apt-get --assume-yes install {{driver['package']}}"]
44 +  driver_04_load: ["sh", "-c", "depmod && modprobe {{driver['module']}}"]
45 +{{endif}}
46 +late_commands:
47 +  maas: [wget, '--no-proxy', {{node_disable_pxe_url|escape.json}}, '--post-data', {{node_disable_pxe_data|escape.json}}, '-O', '/dev/null']
48 +{% endraw %}
49 +
50 +{%- if cluster.get('saltstack_repo_key', False) %}
51 +  {% set salt_repo_key = salt['hashutil.base64_b64encode'](cluster.saltstack_repo_key) %}
52 +  apt_00_set_gpg: ["curtin", "in-target", "--", "sh", "-c", "echo '{{salt_repo_key}}' | base64 -d | apt-key add -"]
53 +{%- endif %}
54 +{% if cluster.saltstack_repo_bionic.startswith('deb') %}
55 +  {%- set saltstack_repo = cluster.saltstack_repo_bionic -%}
56 +{%- else %}
57 +  {%- set saltstack_repo = 'deb [arch=amd64] ' + cluster.saltstack_repo_bionic -%}
58 +{%- endif %}
59 +
60 +  apt_01_set_repo: ["curtin", "in-target", "--", "sh", "-c", "echo '{{ saltstack_repo }}' >> /etc/apt/sources.list.d/mcp_saltstack.list"]
61 +  apt_03_update: ["curtin", "in-target", "--", "apt-get", "update"]
62 +{%- if salt['pillar.get']('maas:cluster:curtin_vars:amd64:bionic:extra_pkgs:enabled')|default(false) %}
63 +  {% for pkg in pillar.maas.cluster.curtin_vars.amd64.bionic.extra_pkgs.pkgs -%}
64 +  apt_04_install_pkgs_{{ loop.index }}: ["curtin", "in-target", "--", "apt-get", "-y", "install", "{{ pkg }}"]
65 +  {% endfor %}
66 +{%- endif %}
67 +{%- if salt['pillar.get']('maas:cluster:curtin_vars:amd64:bionic:kernel_package:enabled')|default(false)  %}
68 +  apt_05_kernel_old_absent: ["curtin", "in-target", "--", "sh", "-c", "dpkg -l '*linux-generic-*[0-9]*' '*linux-image-*[0-9]*' '*linux-headers-*[0-9]*' '*linux-image-extra-*[0-9]*' '*linux-modules-extra-*[0-9]*' 'linux-generic' 'linux-image-generic' 'linux-headers-generic' 2>/dev/null | grep -E '^ii' | awk '{print $2}' | grep -v '{{ pillar.maas.cluster.curtin_vars.amd64.bionic.kernel_package.value.split('-')[2:-1] | join('-') }}' | xargs dpkg --purge --force-depends"]
69 +{%- endif %}
70 +  salt_01_install: ["curtin", "in-target", "--", "apt-get", "-y", "install", "salt-minion", "ifupdown", "cloud-init", "dnsmasq"]
71 +  salt_02_hostname_set: ["curtin", "in-target", "--", "echo", "{% raw %}{{node.hostname}}{% endraw %}.{{pillar.linux.system.domain}}"]
72 +  salt_03_hostname_get: ["curtin", "in-target", "--", "sh", "-c", "echo 'id: {% raw %}{{node.hostname}}{% endraw %}.{{pillar.linux.system.domain}}' >> /etc/salt/minion.d/minion.conf"]
73 +  salt_04_master: ["curtin", "in-target", "--", "sh", "-c", "echo 'master: {{ salt_master_ip }}' >> /etc/salt/minion.d/minion.conf"]
74 +  salt_05_max_event_size: ["curtin", "in-target", "--", "sh", "-c", "echo 'max_event_size: 100000000' >> /etc/salt/minion.d/minion.conf"]
75 +  salt_06_acceptance_wait_time_max: ["curtin", "in-target", "--", "sh", "-c", "echo 'acceptance_wait_time_max: 60' >> /etc/salt/minion.d/minion.conf"]
76 +  salt_07_acceptance_wait_time: ["curtin", "in-target", "--", "sh", "-c", "echo 'acceptance_wait_time: 10' >> /etc/salt/minion.d/minion.conf"]
77 +  salt_08_random_reauth_delay: ["curtin", "in-target", "--", "sh", "-c", "echo 'random_reauth_delay: 270' >> /etc/salt/minion.d/minion.conf"]
78 +  salt_09_recon_default: ["curtin", "in-target", "--", "sh", "-c", "echo 'recon_default: 1000' >> /etc/salt/minion.d/minion.conf"]
79 +  salt_10_recon_max: ["curtin", "in-target", "--", "sh", "-c", "echo 'recon_max: 60000' >> /etc/salt/minion.d/minion.conf"]
80 +  salt_11_recon_randomize: ["curtin", "in-target", "--", "sh", "-c", "echo 'recon_randomize: True' >> /etc/salt/minion.d/minion.conf"]
81 +  salt_12_auth_timeout: ["curtin", "in-target", "--", "sh", "-c", "echo 'auth_timeout: 60' >> /etc/salt/minion.d/minion.conf"]
82 +
83 +  salt_20_bionic_nplan_stop: ["curtin", "in-target", "--", "systemctl", "stop", "systemd-networkd.socket", "systemd-networkd", "networkd-dispatcher", "systemd-networkd-wait-online", "systemd-resolved"]
84 +  salt_21_bionic_nplan_disable: ["curtin", "in-target", "--", "systemctl", "disable", "systemd-networkd.socket", "systemd-networkd", "networkd-dispatcher", "systemd-networkd-wait-online", "systemd-resolved"]
85 +  salt_22_bionic_nplan_mask: ["curtin", "in-target", "--", "systemctl", "mask", "systemd-networkd.socket", "systemd-networkd", "networkd-dispatcher", "systemd-networkd-wait-online", "systemd-resolved"]
86 +  salt_23_bionic_nplan_purge: ["curtin", "in-target", "--", "apt", "--assume-yes", "purge", "nplan", "netplan.io"]
87 +  salt_24_bionic_interfaces: ["curtin", "in-target", "--", "sh", "-c", "echo 'source /etc/network/interfaces.d/*' >> /etc/network/interfaces"]
88 +  salt_25_bionic_networking_unmask: ["curtin", "in-target", "--", "systemctl", "unmask", "networking.service"]
89 +  salt_26_bionic_networking_enable: ["curtin", "in-target", "--", "systemctl", "enable", "networking.service"]
90 +  salt_27_bionic_networking_start: ["curtin", "in-target", "--", "systemctl", "start", "networking.service"]
91 +
92 +{%- if salt['pillar.get']('maas:cluster:curtin_vars:amd64:bionic:kernel_package:enabled')|default(false)  %}
93 +kernel:
94 +  package: {{ pillar.maas.cluster.curtin_vars.amd64.bionic.kernel_package.value }}
95 +{%- endif %}
96 +
97 +{% raw %}
98 +{{if third_party_drivers and driver}}
99 +  driver_00_key_get: curtin in-target -- sh -c "/bin/echo -en '{{key_string}}' > /tmp/maas-{{driver['package']}}.gpg"
100 +  driver_02_key_add: ["curtin", "in-target", "--", "apt-key", "add", "/tmp/maas-{{driver['package']}}.gpg"]
101 +  driver_03_add: ["curtin", "in-target", "--", "add-apt-repository", "-y", "deb {{driver['repository']}} {{node.get_distro_series()}} main"]
102 +  driver_04_update_install: ["curtin", "in-target", "--", "apt-get", "update", "--quiet"]
103 +  driver_05_install: ["curtin", "in-target", "--", "apt-get", "-y", "install", "{{driver['package']}}"]
104 +  driver_06_depmod: ["curtin", "in-target", "--", "depmod"]
105 +  driver_07_update_initramfs: ["curtin", "in-target", "--", "update-initramfs", "-u"]
106 +{{endif}}
107 +{% endraw %}
108 +
109 +{#
110 +# vim: ft=jinja
111 +#}
112 diff --git a/maas/files/curtin_userdata_arm64_generic_bionic b/maas/files/curtin_userdata_arm64_generic_bionic
113 new file mode 100644
114 index 0000000..006d8c2
115 --- /dev/null
116 +++ b/maas/files/curtin_userdata_arm64_generic_bionic
117 @@ -0,0 +1,79 @@
118 +{%- from "maas/map.jinja" import cluster with context %}
119 +{% raw %}
120 +#cloud-config
121 +debconf_selections:
122 + maas: |
123 +  {{for line in str(curtin_preseed).splitlines()}}
124 +  {{line}}
125 +  {{endfor}}
126 +early_commands:
127 +  thin_tools_install: ["sh", "-c", "apt-get update --quiet && apt-get --assume-yes install thin-provisioning-tools"]
128 +{{if third_party_drivers and driver}}
129 +  {{py: key_string = ''.join(['\\x%x' % x for x in map(ord, driver['key_binary'])])}}
130 +  driver_00_get_key: /bin/echo -en '{{key_string}}' > /tmp/maas-{{driver['package']}}.gpg
131 +  driver_01_add_key: ["apt-key", "add", "/tmp/maas-{{driver['package']}}.gpg"]
132 +  driver_02_add: ["add-apt-repository", "-y", "deb {{driver['repository']}} {{node.get_distro_series()}} main"]
133 +  driver_03_update_install: ["sh", "-c", "apt-get update --quiet && apt-get --assume-yes install {{driver['package']}}"]
134 +  driver_04_load: ["sh", "-c", "depmod && modprobe {{driver['module']}}"]
135 +{{endif}}
136 +late_commands:
137 +  maas: [wget, '--no-proxy', {{node_disable_pxe_url|escape.json}}, '--post-data', {{node_disable_pxe_data|escape.json}}, '-O', '/dev/null']
138 +{% endraw %}
139 +{%- if cluster.get('saltstack_repo_key', False) %}
140 +  {% set salt_repo_key = salt['hashutil.base64_b64encode'](cluster.saltstack_repo_key) %}
141 +  apt_00_set_gpg: ["curtin", "in-target", "--", "sh", "-c", "echo '{{salt_repo_key}}' | base64 -d | apt-key add -"]
142 +{%- endif %}
143 +{% if cluster.saltstack_repo_bionic.startswith('deb') %}
144 +  {%- set saltstack_repo = cluster.saltstack_repo_bionic -%}
145 +{%- else %}
146 +  {%- set saltstack_repo = 'deb [arch=amd64] ' + cluster.saltstack_repo_bionic -%}
147 +{%- endif %}
148 +{#- NOTE: Re-use amd64 repos on arm64 since most packages are arch independent #}
149 +  apt_01_set_repo: ["curtin", "in-target", "--", "sh", "-c", "echo '{{ saltstack_repo }}' >> /etc/apt/sources.list.d/mcp_saltstack.list"]
150 +  apt_03_update: ["curtin", "in-target", "--", "apt-get", "update"]
151 +{%- if salt['pillar.get']('maas:cluster:curtin_vars:arm64:bionic:extra_pkgs:enabled')|default(false) %}
152 +  {% for pkg in pillar.maas.cluster.curtin_vars.arm64.bionic.extra_pkgs.pkgs -%}
153 +  apt_04_install_pkgs_{{ loop.index }}: ["curtin", "in-target", "--", "apt-get", "-y", "install", "{{ pkg }}"]
154 +  {% endfor %}
155 +{%- endif %}
156 +{%- if salt['pillar.get']('maas:cluster:curtin_vars:arm64:bionic:kernel_package:enabled')|default(false)  %}
157 +  apt_05_kernel_old_absent: ["curtin", "in-target", "--", "sh", "-c", "dpkg -l '*linux-generic-*[0-9]*' '*linux-image-*[0-9]*' '*linux-headers-*[0-9]*' '*linux-image-extra-*[0-9]*' '*linux-modules-extra-*[0-9]*' 'linux-generic' 'linux-image-generic' 'linux-headers-generic' 2>/dev/null | grep -E '^ii' | awk '{print $2}' | grep -v '{{ pillar.maas.cluster.curtin_vars.arm64.bionic.kernel_package.value.split('-')[2:-1] | join('-') }}' | xargs dpkg --purge --force-depends"]
158 +{%- endif %}
159 +  salt_01_install: ["curtin", "in-target", "--", "apt-get", "-y", "install", "salt-minion", "python-futures", "ifupdown", "cloud-init", "dnsmasq"]
160 +  salt_02_hostname_set: ["curtin", "in-target", "--", "echo", "{% raw %}{{node.hostname}}{% endraw %}.{{pillar.linux.system.domain}}"]
161 +  salt_03_hostname_get: ["curtin", "in-target", "--", "sh", "-c", "echo 'id: {% raw %}{{node.hostname}}{% endraw %}.{{pillar.linux.system.domain}}' >> /etc/salt/minion.d/minion.conf"]
162 +  salt_04_master: ["curtin", "in-target", "--", "sh", "-c", "echo 'master: {{ salt_master_ip }}' >> /etc/salt/minion.d/minion.conf"]
163 +  salt_05_max_event_size: ["curtin", "in-target", "--", "sh", "-c", "echo 'max_event_size: 100000000' >> /etc/salt/minion.d/minion.conf"]
164 +  salt_06_acceptance_wait_time_max: ["curtin", "in-target", "--", "sh", "-c", "echo 'acceptance_wait_time_max: 60' >> /etc/salt/minion.d/minion.conf"]
165 +  salt_07_acceptance_wait_time: ["curtin", "in-target", "--", "sh", "-c", "echo 'acceptance_wait_time: 10' >> /etc/salt/minion.d/minion.conf"]
166 +  salt_08_random_reauth_delay: ["curtin", "in-target", "--", "sh", "-c", "echo 'random_reauth_delay: 270' >> /etc/salt/minion.d/minion.conf"]
167 +  salt_09_recon_default: ["curtin", "in-target", "--", "sh", "-c", "echo 'recon_default: 1000' >> /etc/salt/minion.d/minion.conf"]
168 +  salt_10_recon_max: ["curtin", "in-target", "--", "sh", "-c", "echo 'recon_max: 60000' >> /etc/salt/minion.d/minion.conf"]
169 +  salt_11_recon_randomize: ["curtin", "in-target", "--", "sh", "-c", "echo 'recon_randomize: True' >> /etc/salt/minion.d/minion.conf"]
170 +  salt_12_auth_timeout: ["curtin", "in-target", "--", "sh", "-c", "echo 'auth_timeout: 60' >> /etc/salt/minion.d/minion.conf"]
171 +
172 +  salt_20_bionic_nplan_stop: ["curtin", "in-target", "--", "systemctl", "stop", "systemd-networkd.socket", "systemd-networkd", "networkd-dispatcher", "systemd-networkd-wait-online", "systemd-resolved"]
173 +  salt_21_bionic_nplan_disable: ["curtin", "in-target", "--", "systemctl", "disable", "systemd-networkd.socket", "systemd-networkd", "networkd-dispatcher", "systemd-networkd-wait-online", "systemd-resolved"]
174 +  salt_22_bionic_nplan_mask: ["curtin", "in-target", "--", "systemctl", "mask", "systemd-networkd.socket", "systemd-networkd", "networkd-dispatcher", "systemd-networkd-wait-online", "systemd-resolved"]
175 +  salt_23_bionic_nplan_purge: ["curtin", "in-target", "--", "apt", "--assume-yes", "purge", "nplan", "netplan.io"]
176 +  salt_24_bionic_interfaces: ["curtin", "in-target", "--", "sh", "-c", "echo 'source /etc/network/interfaces.d/*' >> /etc/network/interfaces"]
177 +  salt_25_bionic_networking_unmask: ["curtin", "in-target", "--", "systemctl", "unmask", "networking.service"]
178 +  salt_26_bionic_networking_enable: ["curtin", "in-target", "--", "systemctl", "enable", "networking.service"]
179 +  salt_27_bionic_networking_start: ["curtin", "in-target", "--", "systemctl", "start", "networking.service"]
180 +
181 +{%- if salt['pillar.get']('maas:cluster:curtin_vars:arm64:bionic:kernel_package:enabled')|default(false)  %}
182 +kernel:
183 +  package: {{ pillar.maas.cluster.curtin_vars.arm64.bionic.kernel_package.value }}
184 +{%- endif %}
185 +
186 +{% raw %}
187 +{{if third_party_drivers and driver}}
188 +  driver_00_key_get: curtin in-target -- sh -c "/bin/echo -en '{{key_string}}' > /tmp/maas-{{driver['package']}}.gpg"
189 +  driver_02_key_add: ["curtin", "in-target", "--", "apt-key", "add", "/tmp/maas-{{driver['package']}}.gpg"]
190 +  driver_03_add: ["curtin", "in-target", "--", "add-apt-repository", "-y", "deb {{driver['repository']}} {{node.get_distro_series()}} main"]
191 +  driver_04_update_install: ["curtin", "in-target", "--", "apt-get", "update", "--quiet"]
192 +  driver_05_install: ["curtin", "in-target", "--", "apt-get", "-y", "install", "{{driver['package']}}"]
193 +  driver_06_depmod: ["curtin", "in-target", "--", "depmod"]
194 +  driver_07_update_initramfs: ["curtin", "in-target", "--", "update-initramfs", "-u"]
195 +{{endif}}
196 +{% endraw %}
197 diff --git a/maas/region.sls b/maas/region.sls
198 index 52fb952..ca876ee 100644
199 --- a/maas/region.sls
200 +++ b/maas/region.sls
201 @@ -138,6 +138,30 @@ maas_apache_headers:
202    - require:
203      - pkg: maas_region_packages
204
205 +/etc/maas/preseeds/curtin_userdata_amd64_generic_bionic:
206 +  file.managed:
207 +  - source: salt://maas/files/curtin_userdata_amd64_generic_bionic
208 +  - template: jinja
209 +  - user: root
210 +  - group: root
211 +  - mode: 644
212 +  - context:
213 +      salt_master_ip: {{ region.salt_master_ip }}
214 +  - require:
215 +    - pkg: maas_region_packages
216 +
217 +/etc/maas/preseeds/curtin_userdata_arm64_generic_bionic:
218 +  file.managed:
219 +  - source: salt://maas/files/curtin_userdata_arm64_generic_bionic
220 +  - template: jinja
221 +  - user: root
222 +  - group: root
223 +  - mode: 644
224 +  - context:
225 +      salt_master_ip: {{ region.salt_master_ip }}
226 +  - require:
227 +    - pkg: maas_region_packages
228 +
229  Configure /root/.pgpass for MAAS:
230    file.managed:
231    - name: /root/.pgpass