From nobody Tue Sep 03 07:08:16 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WycCh4NzBz5W57x; Tue, 03 Sep 2024 07:08:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WycCh3tKTz4TPj; Tue, 3 Sep 2024 07:08:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725347296; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Y5N+ls3lw6OpjtZ8nRtmADSLsgBjBo6/cI+loYyYN58=; b=nVSNfm1MnE2YTlurSzbFaT5h+9Zo7xnsImXGvF4soJVY6UTSmtX4gvwISRySRr+gg6cti0 k2dAqo/2YvfIJycJDD/dk5cLwig5bxwCekzgLFuR9h8jdHk5GJsQTrkPP0YHIXR8dKrICn VPw6Id0teufl/NbWklbgZwj0fPpITFXMcPnDPMbOTttVy5i7gPECDzb2Sk5SymvjSWMgY5 4DlVfGpVzH31zIPeUGrfoD3mspyvtjJ8/rez1anE8BC0IPmjX5s3b5ZuHqOmsZa4dkIHsV BtnUSfJO+pu9ic2dHpCbRNibmg0w8quZWAHn6pTw+8wI1KHHlfNmmp8Ud4s7ng== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725347296; a=rsa-sha256; cv=none; b=Mq9HOdfU/mCdStr+uNWsf77MiAHNYvB/ZrU1XcxX+JVeZ9ZRiXEu6CkC0+bAPBLhugvHtp yv8Ki6q7O4ZT79DDfm1M0SLWbYU05P0VbM/+g6iAhP7BAJfBtlru9BHNYA3e6EKR4Vut/M Po9p0CnRb9ZffD7FC3+C1H2HfFcRHFy+k/M9EgvjiK0JSpOJtzIGr6fU3oHG+Z6gZ6UcUx Rlwt0vQWzBzXydlJ5S7wg3mk4QAnNJ8CLN5G5Ixkh8dvPEULx+0bVvAXINYGVUlHaYvCrM VHyu7h9uRfddu9kKKWTR27UdNMNSOwcWSLSJpCRtWooP3/uGF/GuodtY8cSRqg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725347296; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Y5N+ls3lw6OpjtZ8nRtmADSLsgBjBo6/cI+loYyYN58=; b=oOECLwEF8ym8gzYBUduqepUnM8tZNtBDuDs/5+SLCCcNd0rC4hY+03rRA/ARQNRFkoI+2A 1ruBeruGXWODs7xZDiS9zCF+v/Papvt3k1ZUqLr1jxzHMe+k45D3o/N5w7VcI24H7Xt0rB fLugG8imW2AS841VCsKvyU/n1DEmwY/fbq8g0tpKgofAO4GNvfDEfMPIEhhpcL3gu+nNm8 PxYm6uuRVLArWCr4vCAPHzkP1+ClS8D+C7Ov5mdRo2CdaVJ7jxXZ8icTkP1GlV1lbUdY27 9guxn866LS3w4QdSwmk4Ig9u52mMy0ftglzPt9WYLxHgHn8YjDJyLjsf9fFYgg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WycCh3VD7zWNC; Tue, 3 Sep 2024 07:08:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48378GA7068977; Tue, 3 Sep 2024 07:08:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48378GoU068974; Tue, 3 Sep 2024 07:08:16 GMT (envelope-from git) Date: Tue, 3 Sep 2024 07:08:16 GMT Message-Id: <202409030708.48378GoU068974@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Baptiste Daroussin Subject: git: 28094582f0a5 - stable/14 - nuageinit: check for both user_data and user-data List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 28094582f0a5b1e6cbded199a96dd4ad2773f989 Auto-Submitted: auto-generated The branch stable/14 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=28094582f0a5b1e6cbded199a96dd4ad2773f989 commit 28094582f0a5b1e6cbded199a96dd4ad2773f989 Author: Baptiste Daroussin AuthorDate: 2024-06-27 08:30:07 +0000 Commit: Baptiste Daroussin CommitDate: 2024-09-03 07:05:24 +0000 nuageinit: check for both user_data and user-data openstack, ec2 and other implementation of cloudinit disagrees on the name of the file "user-data" or "user_data", test both and use the first found PR: 279876 (cherry picked from commit cde6642431bb0ca21aeebc7c521e99c681d31ffb) --- libexec/nuageinit/nuageinit | 17 ++++++++++---- libexec/nuageinit/tests/nuageinit.sh | 44 ++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/libexec/nuageinit/nuageinit b/libexec/nuageinit/nuageinit index df637bbc5064..f268f9b0f52c 100755 --- a/libexec/nuageinit/nuageinit +++ b/libexec/nuageinit/nuageinit @@ -190,18 +190,27 @@ else end -- deal with user-data -local f = io.open(path..'/user-data', "r") +local ud = nil +local f = nil +userdatas = { "user-data", "user_data" } +for _,v in pairs(userdatas) do + f = io.open(path..'/' .. v, "r") + if f then + ud = v + break + end +end if not f then os.exit(0) end local line = f:read('*l') f:close() if line == "#cloud-config" then - f = io.open(path.."/user-data") + f = io.open(path.."/" .. ud) local obj = yaml.eval(f:read("*a")) f:close() if not obj then - nuage.err("nuageinit: error parsing cloud-config file: user-data") + nuage.err("nuageinit: error parsing cloud-config file: " .. ud) end if obj.groups then for n,g in pairs(obj.groups) do @@ -298,7 +307,7 @@ if line == "#cloud-config" then routing:close() end else - local res,err = os.execute(path..'/user-data') + local res,err = os.execute(path..'/' .. ud) if not res then nuage.err("nuageinit: error executing user-data script: ".. err) end diff --git a/libexec/nuageinit/tests/nuageinit.sh b/libexec/nuageinit/tests/nuageinit.sh index 42c95e1b2abd..54c88ceb539a 100644 --- a/libexec/nuageinit/tests/nuageinit.sh +++ b/libexec/nuageinit/tests/nuageinit.sh @@ -1,11 +1,13 @@ atf_test_case args atf_test_case nocloud atf_test_case nocloud_userdata_script +atf_test_case nocloud_user_data_script atf_test_case nocloud_userdata_cloudconfig atf_test_case nocloud_userdata_cloudconfig_users atf_test_case nocloud_network atf_test_case config2 atf_test_case config2_pubkeys +atf_test_case config2_pubkeys_user_data atf_test_case config2_network atf_test_case config2_network_static_v4 @@ -45,6 +47,16 @@ nocloud_userdata_script_body() atf_check -s exit:0 -o inline:"yeah\n" /usr/libexec/nuageinit ${here}/media/nuageinit nocloud } +nocloud_user_data_script_body() +{ + here=$(pwd) + mkdir -p media/nuageinit + printf "instance-id: iid-local01\n" > ${here}/media/nuageinit/meta-data + printf "#!/bin/sh\necho "yeah"\n" > ${here}/media/nuageinit/user_data + chmod 755 ${here}/media/nuageinit/user_data + atf_check -s exit:0 -o inline:"yeah\n" /usr/libexec/nuageinit ${here}/media/nuageinit nocloud +} + nocloud_userdata_cloudconfig_users_body() { here=$(pwd) @@ -199,6 +211,36 @@ EOF atf_check -o inline:"ssh-rsa AAAAB3NzaC1y...== Generated by Nova\n" cat home/freebsd/.ssh/authorized_keys } + +config2_pubkeys_user_data_body() +{ + here=$(pwd) + export NUAGE_FAKE_ROOTDIR=$(pwd) + if [ $(id -u) -ne 0 ]; then + atf_skip "root required" + fi + mkdir -p media/nuageinit + touch media/nuageinit/meta_data.json + cat > media/nuageinit/user_data << EOF +#cloud-config + +ssh_authorized_keys: + - "ssh-rsa AAAAB3NzaC1y...== Generated by Nova" +EOF + mkdir -p etc + cat > etc/master.passwd < etc/group <