Migrate CoreOS to use coreos-cloudinit
http://coreos.com/docs/cluster-management/setup/cloudinit-cloud-config/ describes how to use coreos-cloudinit to configure a node. Migrate to using this instead of a single BASH script (which is deprecated). This also means we need the latest version of CoreOS, so I've updated coreos-oem-inject.py to pull from the most recent copies, and this includes moving to the amd64-usr builds. Change-Id: I620b8fec1bfc5d58b560434d17b4f617734fadb8
This commit is contained in:
parent
0eec6c3b22
commit
62027ae0bb
|
@ -8,9 +8,9 @@ import tempfile
|
|||
import shutil
|
||||
from plumbum import local, cmd
|
||||
|
||||
COREOS_VERSION="250.0.0"
|
||||
COREOS_VERSION="296.0.0"
|
||||
|
||||
COREOS_ARCH="amd64-generic"
|
||||
COREOS_ARCH="amd64-usr"
|
||||
COREOS_BASE_URL="http://storage.core-os.net/coreos/{}/{}".format(COREOS_ARCH, COREOS_VERSION)
|
||||
COREOS_PXE_DIGESTS="coreos_production_pxe_image.cpio.gz.DIGESTS.asc"
|
||||
COREOS_PXE_KERNEL="coreos_production_pxe.vmlinuz"
|
||||
|
@ -102,8 +102,8 @@ def main():
|
|||
print("Error: {} doesn't exist.".format(oem_dir))
|
||||
return
|
||||
|
||||
if not os.path.exists(os.path.join(oem_dir, 'run.sh')):
|
||||
print("Error: {} is missing oem.sh".format(oem_dir))
|
||||
if not os.path.exists(os.path.join(oem_dir, 'cloud-config.yml')):
|
||||
print("Error: {} is missing cloud-config.yml".format(oem_dir))
|
||||
return
|
||||
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
#cloud-config
|
||||
|
||||
coreos:
|
||||
units:
|
||||
- name: ironic-python-agent-embed-ssh-keys.service
|
||||
command: start
|
||||
content: |
|
||||
[Unit]
|
||||
Description=Migrate embedded SSH keys into core user
|
||||
ConditionFileNotEmpty=/usr/share/oem/authorized_keys
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/bin/update-ssh-keys -a oem /usr/share/oem/authorized_keys
|
||||
|
||||
- name: ironic-python-agent-container-creation.service
|
||||
command: start
|
||||
content: |
|
||||
[Unit]
|
||||
Description=Untar Provided IPA Container
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/bin/mkdir -p /opt/ironic-python-agent
|
||||
ExecStart=/usr/bin/tar -x \
|
||||
-C /opt/ironic-python-agent \
|
||||
-f /usr/share/oem/container.tar.gz
|
||||
|
||||
- name: ironic-python-agent.service
|
||||
command: start
|
||||
content: |
|
||||
[Unit]
|
||||
Description=Ironic Python Agent
|
||||
After=ironic-python-agent-container-creation.service
|
||||
Requires=ironic-python-agent-container-creation.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/systemd-nspawn -D /opt/ironic-python-agent \
|
||||
--share-system \
|
||||
--capability=all \
|
||||
--machine=ironic_python_agent \
|
||||
--bind=/dev:/dev \
|
||||
--bind=/dev/pts:/dev/pts \
|
||||
--bind=/usr/share/oem:/mnt \
|
||||
--user=root \
|
||||
--keep-unit \
|
||||
/usr/local/bin/ironic-python-agent
|
||||
Restart=always
|
||||
RestartSec=30s
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# CoreOS by default only has an OEM partition of 2GB. This isn't large enough
|
||||
# for some images. If you need something larger, uncomment the following line
|
||||
# to remount it with a larger size.
|
||||
# Note: When CoreOS changes to r/w /, instead of remounting here, rootflags=
|
||||
# in the kernelk command line will be used to set the size.
|
||||
#mount -o remount,size=20G /media/state
|
||||
|
||||
cd /usr/share/oem/
|
||||
|
||||
mkdir -pm 0700 /home/core/.ssh
|
||||
|
||||
# TODO: Use proper https://github.com/coreos/init/blob/master/bin/update-ssh-keys script
|
||||
if [[ -e authorized_keys ]]; then
|
||||
cat authorized_keys >> /home/core/.ssh/authorized_keys
|
||||
fi
|
||||
|
||||
chown -R core:core /home/core/.ssh/
|
||||
|
||||
mkdir -p /media/state/ironic-python-agent
|
||||
tar -x -C /media/state/ironic-python-agent -f container.tar.gz
|
||||
|
||||
systemctl enable --runtime /usr/share/oem/system/*
|
||||
systemctl start ironic-python-agent.service
|
|
@ -1,7 +0,0 @@
|
|||
[Service]
|
||||
ExecStart=/usr/bin/systemd-nspawn -D /media/state/ironic-python-agent --share-system --capability=all --machine=ironic_python_agent --bind=/dev:/dev --bind=/dev/pts:/dev/pts --bind=/usr/share/oem:/mnt --user=root --keep-unit /usr/local/bin/ironic-python-agent
|
||||
Restart=always
|
||||
RestartSec=30s
|
||||
|
||||
[Install]
|
||||
WantedBy=oem.target
|
Loading…
Reference in New Issue