Skip to content

Commit

Permalink
Fix prepare target in Makefile (#1797)
Browse files Browse the repository at this point in the history
Closes osism/issues#715

Signed-off-by: Christian Berendt <[email protected]>
  • Loading branch information
berendt authored Oct 13, 2023
1 parent ef58988 commit 75eed19
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ VERSION_OPENSTACK ?= 2023.1
TERRAFORM ?= terraform
TERRAFORM_BLUEPRINT ?= testbed-default

ANSIBLE_COLLECTION_COMMONS_PATH := $(shell yq '.repositories.ansible-collection-commons.path' playbooks/vars/repositories.yml)
ANSIBLE_COLLECTION_COMMONS_REPO := $(shell yq '.repositories.ansible-collection-commons.repo' playbooks/vars/repositories.yml)
ANSIBLE_COLLECTION_SERVICES_PATH := $(shell yq '.repositories.ansible-collection-services.path' playbooks/vars/repositories.yml)
ANSIBLE_COLLECTION_SERVICES_REPO := $(shell yq '.repositories.ansible-collection-services.repo' playbooks/vars/repositories.yml)
REPOSITORY_SERVER := $(shell yq '.repository_server' playbooks/vars/repositories.yml)
TERRAFORM_BASE_PATH := $(shell yq '.repositories.terraform-base.path' playbooks/vars/repositories.yml)
TERRAFORM_BASE_REPO := $(shell yq '.repositories.terraform-base.repo' playbooks/vars/repositories.yml)
TESTBED_PATH := $(shell yq '.repositories.testbed.path' playbooks/vars/repositories.yml)
TESTBED_REPO := $(shell yq '.repositories.testbed.repo' playbooks/vars/repositories.yml)

help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

Expand All @@ -33,7 +43,6 @@ login: ## Log in on the manager.
login

bootstrap: create ## Bootstrap everything.
REPOSITORY_SERVER=$$(yq '.repository_server' playbooks/vars/repositories.yml)
ansible-playbook playbooks/deploy.yml \
-i ansible/localhost_inventory.yaml \
-e ansible_galaxy=ansible-galaxy \
Expand Down Expand Up @@ -81,26 +90,14 @@ deploy: bootstrap ## Deploy everything and then check it.
prepare: ## Run local preparations.
ansible-playbook -i localhost, ansible/check-local-versions.yml

REPOSITORY_SERVER=$$(yq '.repository_server' playbooks/vars/repositories.yml)

TESTBED_PATH=$$(yq '.repositories.testbed.path' playbooks/vars/repositories.yml)
TESTBED_REPO=$$(yq '.repositories.testbed.repo' playbooks/vars/repositories.yml)
mkdir -p $$(dirname $(ANSIBLE_COLLECTION_COMMONS_PATH))
mkdir -p $$(dirname $(ANSIBLE_COLLECTION_SERVICES_PATH))
mkdir -p $$(dirname $(TERRAFORM_BASE_PATH))
mkdir -p $$(dirname $(TESTBED_PATH))
if [ ! -e .src/$(TESTBED_PATH) ]; then git clone $(TESTBED_REPO) .src/$(TESTBED_PATH); else git -C .src/$(TESTBED_PATH) pull; fi

TERRAFORM_BASE_PATH=$$(yq '.repositories.terraform-base.path' playbooks/vars/repositories.yml)
TERRAFORM_BASE_REPO=$$(yq '.repositories.terraform-base.repo' playbooks/vars/repositories.yml)
mkdir -p $$(dirname $(TERRAFORM_BASE_PATH))
if [ ! -e .src/$(TESTBED_PATH) ]; then git clone $(TESTBED_REPO) .src/$(TESTBED_PATH); else git -C .src/$(TESTBED_PATH) pull; fi
if [ ! -e .src/$(TERRAFORM_BASE_PATH) ]; then git clone $(TERRAFORM_BASE_REPO) .src/$(TERRAFORM_BASE_PATH); else git -C .src/$(TERRAFORM_BASE_PATH) pull; fi

ANSIBLE_COLLECTION_COMMONS_PATH=$$(yq '.repositories.ansible-collection-commons.path' playbooks/vars/repositories.yml)
ANSIBLE_COLLECTION_COMMONS_REPO=$$(yq '.repositories.ansible-collection-commons.repo' playbooks/vars/repositories.yml)
mkdir -p $$(dirname $(ANSIBLE_COLLECTION_COMMONS_PATH))
if [ ! -e .src/$(ANSIBLE_COLLECTION_COMMONS_PATH) ]; then git clone $(ANSIBLE_COLLECTION_COMMONS_REPO) .src/$(ANSIBLE_COLLECTION_COMMONS_PATH); else git -C .src/$(ANSIBLE_COLLECTION_COMMONS_PATH) pull; fi

ANSIBLE_COLLECTION_SERVICES_PATH=$$(yq '.repositories.ansible-collection-services.path' playbooks/vars/repositories.yml)
ANSIBLE_COLLECTION_SERVICES_REPO=$$(yq '.repositories.ansible-collection-services.repo' playbooks/vars/repositories.yml)
mkdir -p $$(dirname $(ANSIBLE_COLLECTION_SERVICES_PATH))
if [ ! -e .src/$(ANSIBLE_COLLECTION_SERVICES_PATH) ]; then git clone $(ANSIBLE_COLLECTION_SERVICES_REPO) .src/$(ANSIBLE_COLLECTION_SERVICES_PATH); else git -C .src/$(ANSIBLE_COLLECTION_SERVICES_PATH) pull; fi

rsync -avz .src/$(TERRAFORM_BASE_PATH)/$(TERRAFORM_BLUEPRINT)/ terraform
Expand Down

0 comments on commit 75eed19

Please sign in to comment.