From 7d31e22447cf17c3a298e70c8847fca84fa41d10 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 21 Jul 2021 12:28:03 -0400 Subject: [PATCH] Add post/firstboot to os cloning --- .../profiles/default/scripts/firstboot.custom | 4 +++ .../default/scripts/firstboot.d/.gitignore | 0 .../default/scripts/firstboot.service | 11 ++++++ .../profiles/default/scripts/firstboot.sh | 36 +++++++++++++++++++ .../default/scripts/onboot.d/.gitignore | 0 .../default/scripts/post.d/.gitignore | 0 6 files changed, 51 insertions(+) create mode 100644 confluent_osdeploy/el8-diskless/profiles/default/scripts/firstboot.custom create mode 100644 confluent_osdeploy/el8-diskless/profiles/default/scripts/firstboot.d/.gitignore create mode 100644 confluent_osdeploy/el8-diskless/profiles/default/scripts/firstboot.service create mode 100644 confluent_osdeploy/el8-diskless/profiles/default/scripts/firstboot.sh create mode 100644 confluent_osdeploy/el8-diskless/profiles/default/scripts/onboot.d/.gitignore create mode 100644 confluent_osdeploy/el8-diskless/profiles/default/scripts/post.d/.gitignore diff --git a/confluent_osdeploy/el8-diskless/profiles/default/scripts/firstboot.custom b/confluent_osdeploy/el8-diskless/profiles/default/scripts/firstboot.custom new file mode 100644 index 00000000..eea34051 --- /dev/null +++ b/confluent_osdeploy/el8-diskless/profiles/default/scripts/firstboot.custom @@ -0,0 +1,4 @@ +. /etc/confluent/functions +# This is a convenient place to keep customizations separate from modifying the stock scripts +# While modification of the stock scripts is fine, it may be easier to rebase to a newer +# stock profile if the '.custom' files are used. diff --git a/confluent_osdeploy/el8-diskless/profiles/default/scripts/firstboot.d/.gitignore b/confluent_osdeploy/el8-diskless/profiles/default/scripts/firstboot.d/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/confluent_osdeploy/el8-diskless/profiles/default/scripts/firstboot.service b/confluent_osdeploy/el8-diskless/profiles/default/scripts/firstboot.service new file mode 100644 index 00000000..209a95e6 --- /dev/null +++ b/confluent_osdeploy/el8-diskless/profiles/default/scripts/firstboot.service @@ -0,0 +1,11 @@ +[Unit] +Description=First Boot Process +Requires=network-online.target +After=network-online.target + +[Service] +ExecStart=/opt/confluent/bin/firstboot.sh + +[Install] +WantedBy=multi-user.target + diff --git a/confluent_osdeploy/el8-diskless/profiles/default/scripts/firstboot.sh b/confluent_osdeploy/el8-diskless/profiles/default/scripts/firstboot.sh new file mode 100644 index 00000000..73d10d98 --- /dev/null +++ b/confluent_osdeploy/el8-diskless/profiles/default/scripts/firstboot.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +# This script is executed on the first boot after install has +# completed. It is best to edit the middle of the file as +# noted below so custom commands are executed before +# the script notifies confluent that install is fully complete. + +nodename=$(grep ^NODENAME /etc/confluent/confluent.info|awk '{print $2}') +confluent_apikey=$(cat /etc/confluent/confluent.apikey) +confluent_mgr=$(grep deploy_server /etc/confluent/confluent.deploycfg|awk '{print $2}') +confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg|awk '{print $2}') +export nodename confluent_mgr confluent_profile +. /etc/confluent/functions +exec >> /var/log/confluent/confluent-firstboot.log +exec 2>> /var/log/confluent/confluent-firstboot.log +tail -f /var/log/confluent/confluent-firstboot.log > /dev/console & +logshowpid=$! + +if [ ! -f /etc/confluent/firstboot.ran ]; then + touch /etc/confluent/firstboot.ran + + cat /etc/confluent/tls/*.pem >> /etc/pki/tls/certs/ca-bundle.crt + + run_remote firstboot.custom + # Firstboot scripts may be placed into firstboot.d, e.g. firstboot.d/01-firstaction.sh, firstboot.d/02-secondaction.sh + run_remote_parts firstboot.d + + # Induce execution of remote configuration, e.g. ansible plays in ansible/firstboot.d/ + run_remote_config firstboot.d +fi + +curl -X POST -d 'status: complete' -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $confluent_apikey" https://$confluent_mgr/confluent-api/self/updatestatus +systemctl disable firstboot +rm /etc/systemd/system/firstboot.service +rm /etc/confluent/firstboot.ran +kill $logshowpid diff --git a/confluent_osdeploy/el8-diskless/profiles/default/scripts/onboot.d/.gitignore b/confluent_osdeploy/el8-diskless/profiles/default/scripts/onboot.d/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/confluent_osdeploy/el8-diskless/profiles/default/scripts/post.d/.gitignore b/confluent_osdeploy/el8-diskless/profiles/default/scripts/post.d/.gitignore new file mode 100644 index 00000000..e69de29b