Skip to content

Commit

Permalink
fixes broken "make run" for ansible operators
Browse files Browse the repository at this point in the history
Previously, an ansible operator would be scaffolded with a Makefile
whose "run" target had incorrect syntax. It would run this command:

`ANSIBLE_ROLES_PATH="$(ANSIBLE_ROLES_PATH):$(shell pwd)/roles" $(ANSIBLE_OPERATOR) run`

That command failed to set the `ANSIBLE_ROLES_PATH` variable correctly
because it was using Makefile syntax in a target's recipe, which gets
interpreted as shell script.

This commit moves the variable setting statement, which uses Makefile
syntax, out of the recipe. It also uses the standard `?=` operator to
only set the variable if it is unset.

Signed-off-by: Michael Hrivnak <mhrivnak@hrivnak.org>
  • Loading branch information
mhrivnak committed Oct 24, 2022
1 parent 67b8a1d commit 30512ce
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
40 changes: 40 additions & 0 deletions changelog/fragments/01-ansible-fix-make-run.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# entries is a list of entries to include in
# release notes and/or the migration guide
entries:
- description: 'ansible: fixed "make run" so it finds local roles'

# kind is one of:
# - addition
# - change
# - deprecation
# - removal
# - bugfix
kind: "bugfix"

# Is this a breaking change?
breaking: false

# NOTE: ONLY USE `pull_request_override` WHEN ADDING THIS
# FILE FOR A PREVIOUSLY MERGED PULL_REQUEST!
#
# The generator auto-detects the PR number from the commit
# message in which this file was originally added.
#
# What is the pull request number (without the "#")?
# pull_request_override: 0


# Migration can be defined to automatically add a section to
# the migration guide. This is required for breaking changes.
migration:
header: update ansible operator Makefile's run target
body: |
For an ansible operator, update the Makefile's run target to the
following to fix a bug in its implementation.
```
.PHONY: run
ANSIBLE_ROLES_PATH?="$(shell pwd)/roles"
run: ansible-operator ## Run against the configured Kubernetes cluster in ~/.kube/config
$(ANSIBLE_OPERATOR) run
```
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ help: ## Display this help.
##@ Build
.PHONY: run
ANSIBLE_ROLES_PATH?="$(shell pwd)/roles"
run: ansible-operator ## Run against the configured Kubernetes cluster in ~/.kube/config
ANSIBLE_ROLES_PATH="$(ANSIBLE_ROLES_PATH):$(shell pwd)/roles" $(ANSIBLE_OPERATOR) run
$(ANSIBLE_OPERATOR) run
.PHONY: docker-build
docker-build: ## Build docker image with the manager.
Expand Down

0 comments on commit 30512ce

Please sign in to comment.