From 42f766d5f49d420c98b89aeb47ffc06c4eb63450 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 2 Dec 2021 11:38:18 -0500 Subject: [PATCH] Fix osdeploy initialize when only ssh or tls is done ssh is technically opt-in, though strongly recommended, so osdeploy should cope with that. TLS is pretty much required, but perhaps not done immediately, so it gets similar treatmennt. --- confluent_server/bin/osdeploy | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/confluent_server/bin/osdeploy b/confluent_server/bin/osdeploy index 424c7d89..42d4ddd1 100644 --- a/confluent_server/bin/osdeploy +++ b/confluent_server/bin/osdeploy @@ -278,14 +278,19 @@ def initialize(cmdset): topack = [] opath = os.getcwd() os.chdir('/var/lib/confluent/public/site') - topack.append('ssh/') - for currd, _, files in os.walk('ssh'): - for fname in files: - topack.append(os.path.join(currd, fname)) - topack.append('tls/') - for currd, _, files in os.walk('tls'): - for fname in files: - topack.append(os.path.join(currd, fname)) + totar = [] + if os.path.exists('ssh'): + totar.append('ssh') + topack.append('ssh/') + for currd, _, files in os.walk('ssh'): + for fname in files: + topack.append(os.path.join(currd, fname)) + if os.path.exists('tls'): + totar.append('tls') + topack.append('tls/') + for currd, _, files in os.walk('tls'): + for fname in files: + topack.append(os.path.join(currd, fname)) with open(tmpname, 'wb') as initramfs: packit = subprocess.Popen(['cpio', '-H', 'newc', '-o'], stdout=initramfs, stdin=subprocess.PIPE) @@ -302,11 +307,12 @@ def initialize(cmdset): os.rename(tmpname, '/var/lib/confluent/public/site/initramfs.cpio') if cmdset.g: updateboot('genesis-x86_64') - tmptarname = tmpname.replace('cpio', 'tgz') - tarcmd = ['tar', '-czf', tmptarname, 'ssh', 'tls'] - subprocess.check_call(tarcmd) + if totar: + tmptarname = tmpname.replace('cpio', 'tgz') + tarcmd = ['tar', '-czf', tmptarname] + totar + subprocess.check_call(tarcmd) + os.rename(tmptarname, '/var/lib/confluent/public/site/initramfs.tgz') os.chdir(opath) - os.rename(tmptarname, '/var/lib/confluent/public/site/initramfs.tgz') print('Site initramfs content packed successfully') if not os.path.exists('/etc/confluent/srvcert.pem'):