From bb8857ccfbaa1a61e1c3554f56a4506202512aea Mon Sep 17 00:00:00 2001 From: Blai Peidro Date: Mon, 30 Nov 2026 01:01:36 +0100 Subject: [PATCH] fix: a form without an inventory gives ansible none --- CHANGELOG.md | 1 + internal/ansible/prepare.go | 6 +++++- internal/ansible/prepare_test.go | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96fe382..a68226f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ The changes made to the Runner between two releases wait under Unreleased and go - **Outbound by default:** a Runner started without `RTE_MODE` dials the controller, as the README shows - **Restricted namespaces:** the jobs' pods meet the restricted Pod Security Standard +- **No inventory:** a form without one no longer has ansible read every file of the playbook's folder as one ## 7.8.0 diff --git a/internal/ansible/prepare.go b/internal/ansible/prepare.go index 743c976..93a93b9 100644 --- a/internal/ansible/prepare.go +++ b/internal/ansible/prepare.go @@ -396,13 +396,17 @@ func Args(extravars map[string]any, f Files) []string { if f.Vault { args = append(args, "--vault-password-file=/bin/cat") } + // none when the form names none (inventory: ""), as the controller's own Runner does : an + // empty -i would make ansible read every file of the playbook's folder as an inventory var inventories []any switch inv := extravars["__inventory__"].(type) { case nil: case []any: inventories = inv default: - inventories = []any{inv} + if truthy(inv) { + inventories = []any{inv} + } } for _, i := range inventories { if s, ok := i.(string); ok { diff --git a/internal/ansible/prepare_test.go b/internal/ansible/prepare_test.go index 4a7cd26..6586adf 100644 --- a/internal/ansible/prepare_test.go +++ b/internal/ansible/prepare_test.go @@ -113,6 +113,10 @@ func TestArgs(t *testing.T) { if got := strings.Join(Args(map[string]any{"__verbosity__": 9.0}, Files{Extravars: "e", Hidden: "h"}), " "); got != "-e @e -e @h -vvvvv " { t.Errorf("args %q", got) } + // a form without an inventory (inventory: "") : no -i at all + if got := strings.Join(Args(map[string]any{"__inventory__": "", "__playbook__": "p"}, Files{Extravars: "e", Hidden: "h"}), " "); got != "-e @e -e @h p" { + t.Errorf("no inventory %q", got) + } } // TestPlaybookEnv checks the application's and the Runner's variables never reach a playbook.