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} .