From aaec3576dbaff81b48c9404e653b7123142c79de Mon Sep 17 00:00:00 2001 From: austin Date: Wed, 4 Aug 2021 13:17:42 -0400 Subject: [PATCH] prepend local roles path to ANSIBLE_ROLES_PATH closes: https://github.com/operator-framework/operator-sdk/issues/4071 When running locally, we set the ANSIBLE_ROLES_PATH to include the local roles path, preventing users from needing to manually setting this environment variable for normal development. Signed-off-by: austin --- .../fragments/ansible-set-local-rolespath.yaml | 18 ++++++++++++++++++ .../scaffolds/internal/templates/makefile.go | 2 +- testdata/ansible/memcached-operator/Makefile | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 changelog/fragments/ansible-set-local-rolespath.yaml diff --git a/changelog/fragments/ansible-set-local-rolespath.yaml b/changelog/fragments/ansible-set-local-rolespath.yaml new file mode 100644 index 00000000000..ff4092328ab --- /dev/null +++ b/changelog/fragments/ansible-set-local-rolespath.yaml @@ -0,0 +1,18 @@ +# entries is a list of entries to include in +# release notes and/or the migration guide +entries: + - description: > + (ansible/v1) Previously, when scaffolding an Ansible-based operator with + both Roles and Playbooks, the roles imported by the playbook could not be + found when running locally (`make run`). This change prepends the + `ANSIBLE_ROLES_PATH` environment variable with the path to the local + roles directory. + kind: "bugfix" + breaking: false + migration: + header: (optional) Add local Ansible Roles path to Env in `make run` + body: > + If you would like to run your operator locally using `make run`, modify + the `run` target in the `Makefile` to: + `ANSIBLE_ROLES_PATH="$(ANSIBLE_ROLES_PATH):$(shell pwd)/roles" + $(ANSIBLE_OPERATOR) run` diff --git a/internal/plugins/ansible/v1/scaffolds/internal/templates/makefile.go b/internal/plugins/ansible/v1/scaffolds/internal/templates/makefile.go index f3f5d39476c..08d7ebcafb2 100644 --- a/internal/plugins/ansible/v1/scaffolds/internal/templates/makefile.go +++ b/internal/plugins/ansible/v1/scaffolds/internal/templates/makefile.go @@ -89,7 +89,7 @@ help: ## Display this help. ##@ Build run: ansible-operator ## Run against the configured Kubernetes cluster in ~/.kube/config - $(ANSIBLE_OPERATOR) run + ANSIBLE_ROLES_PATH="$(ANSIBLE_ROLES_PATH):$(shell pwd)/roles" $(ANSIBLE_OPERATOR) run docker-build: ## Build docker image with the manager. docker build -t ${IMG} . diff --git a/testdata/ansible/memcached-operator/Makefile b/testdata/ansible/memcached-operator/Makefile index 7c1ac731f63..b071b04cb5f 100644 --- a/testdata/ansible/memcached-operator/Makefile +++ b/testdata/ansible/memcached-operator/Makefile @@ -59,7 +59,7 @@ help: ## Display this help. ##@ Build run: ansible-operator ## Run against the configured Kubernetes cluster in ~/.kube/config - $(ANSIBLE_OPERATOR) run + ANSIBLE_ROLES_PATH="$(ANSIBLE_ROLES_PATH):$(shell pwd)/roles" $(ANSIBLE_OPERATOR) run docker-build: ## Build docker image with the manager. docker build -t ${IMG} .