From nobody Thu Jun 27 08:33:39 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 4W8sKb4MjTz5PCk7; Thu, 27 Jun 2024 08:33:39 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4W8sKb3bHlz4RZr; Thu, 27 Jun 2024 08:33:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1719477219; 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=+h7KAm1YZwDSYRf4QWurpb664xDMvBObQzxGdri/OWE=; b=km6aaxC7Czpax5D7oQ8TE35JNOkRcgXm3y83ir2Ghgg7Ch9Ne5jM3zVqnu2etNeTI0uxjf TQ5tkj6HuRIfxxjzxtBDe6+i/ybMQofXeWZcLE37RBtDdjBgTLAffnDDJpO3sa7Eucq7d2 U5ETOwahhrkOXR9LKeIenKIxr7YlyfrED7zRnHw9iGJwMAJBcOh294rZf797yBGtrv/D4w OppG7Hrh3r48EuKAPWfJVsmEQehJ8XQt0Kf4hWwUtI//hmLPWQa243cR+tBKTbSQb6PEZ2 9e8iCx5NkqWNAGoNdnk4VVNVry2+W0cdiicBs64Mjmv1wSBm1LsCfViuSZYfSA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1719477219; a=rsa-sha256; cv=none; b=JkRTdE0oXZs+pJfJgHFhazvAQdM7+Gvhi1iSvY4BJEsowOKsgXNbXRndZlQP92ogE2QaYN u9YbKWjAKoVDZenOK2aPEcVzYWuUxlbvGfIUI1vxn+PlhCquq4LkB7YNbBPvJIYDV3zEj4 gBXqZjZEimr83M7sgx8EQJ1eW4pmplnyPm7/alFqjQUqD43VcKj1EeYA+FC2GncOQZ5ZP8 K3KORGxoLZ5q2zZf4+zjhP9PY9AyjJCapDJnqNTAQt2XsHif2qX2KI2uo+p94yOZozhUDl 3r1xd0f++K/tAeXU4vIvnbj081FNDxwu1Z7FZ+3Pk1B8N7qYAjsECCTaImfkZQ== 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=1719477219; 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=+h7KAm1YZwDSYRf4QWurpb664xDMvBObQzxGdri/OWE=; b=j6ZQwF/ain0trwV53qkv0aOnYaViXalCcVaj+RxW+qN/sg5MwlvRwrrq06KiKpVobTxZLZ W6iEaTVi0oPFBMdcSDhKLbdKNQ266PN7+iy8QEi6+Kbh7EWD4AOvLhBYtAzvS7KCDtYAjF IxfwFFvKdDYq/csGRoScbgZWpqFeXohIRVd6sF1xlLD1IHlPvTJzt+ZQVIHGXmiZatlrGH C8WQjx3aOyCW6RTrlK46FKErclf27R65+UPIyCvZcjt+TQkdDaQWzjoHaCf0Eoen1Pis0G EUHF39dt1rgaRiPBHIJjfybeqkOrOafpgC55FUjR7/MzGNfGuXs+tU9tBSnXqA== 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 4W8sKb38FSz1Kqx; Thu, 27 Jun 2024 08:33:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 45R8XdOP076094; Thu, 27 Jun 2024 08:33:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45R8Xdi0076091; Thu, 27 Jun 2024 08:33:39 GMT (envelope-from git) Date: Thu, 27 Jun 2024 08:33:39 GMT Message-Id: <202406270833.45R8Xdi0076091@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: cde6642431bb - main - 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/main X-Git-Reftype: branch X-Git-Commit: cde6642431bb0ca21aeebc7c521e99c681d31ffb Auto-Submitted: auto-generated The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=cde6642431bb0ca21aeebc7c521e99c681d31ffb commit cde6642431bb0ca21aeebc7c521e99c681d31ffb Author: Baptiste Daroussin AuthorDate: 2024-06-27 08:30:07 +0000 Commit: Baptiste Daroussin CommitDate: 2024-06-27 08:32:14 +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 --- 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 <