Skip to content

Commit

Permalink
Update ansible.mk
Browse files Browse the repository at this point in the history
  • Loading branch information
back-2-95 committed Apr 8, 2024
1 parent 951f3c8 commit 27ed701
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
11 changes: 4 additions & 7 deletions make/ansible.mk
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
ANSIBLE_INVENTORY_PATH ?= ansible/inventory
ANSIBLE_ROLES_PATH ?= ansible/roles
ANSIBLE_CHECK_ROLE ?= geerlingguy.docker
ANSIBLE_PLAYBOOK ?= ansible-playbook
ANSIBLE_PROVISION ?= ansible/provision.yml
ANSIBLE_REQUIREMENTS ?= ansible/requirements.yml
ANSIBLE_FLAGS ?=

PHONY += provision
provision: INVENTORY ?= production
provision: $(ANSIBLE_ROLES_PATH)/$(ANSIBLE_CHECK_ROLE) ## Make provisioning
$(call step,Ansible: Make dry run on provisioning...\n)
@$(ANSIBLE_PLAYBOOK) -i $(ANSIBLE_INVENTORY_PATH)/$(INVENTORY) $(ANSIBLE_PROVISION)
@$(ANSIBLE_PLAYBOOK) $(ANSIBLE_PROVISION) $(ANSIBLE_FLAGS)

PHONY += provision-%
provision-%: INVENTORY ?= production
provision-%: $(ANSIBLE_ROLES_PATH)/$(ANSIBLE_CHECK_ROLE) ## Make provisioning by tag
$(call step,Ansible: Make provisioning by tag "$*"...\n)
@$(ANSIBLE_PLAYBOOK) -i $(ANSIBLE_INVENTORY_PATH)/$(INVENTORY) $(ANSIBLE_PROVISION) --tags="$*"
@$(ANSIBLE_PLAYBOOK) $(ANSIBLE_PROVISION) --tags="$*" $(ANSIBLE_FLAGS)

PHONY += provision-dry-run
provision-dry-run: INVENTORY ?= production
provision-dry-run: $(ANSIBLE_ROLES_PATH)/$(ANSIBLE_CHECK_ROLE) ## Make dry run on provisioning
$(call step,Ansible: Make dry run on provisioning...\n)
@$(ANSIBLE_PLAYBOOK) -i $(ANSIBLE_INVENTORY_PATH)/$(INVENTORY) $(ANSIBLE_PROVISION) --check
@$(ANSIBLE_PLAYBOOK) $(ANSIBLE_PROVISION) $(ANSIBLE_FLAGS) --check

PHONY += ansible-install-roles
ansible-install-roles: ## Install Ansible roles
Expand Down
2 changes: 1 addition & 1 deletion tests/outputs/ansible-provision-tag.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ __MAKE__ ansible-install-roles
printf "\n⭐ \033[0;33mAnsible: Install Ansible roles...\n\033[0m\n"
ansible-galaxy install -r ansible/requirements.yml -p ansible/roles
printf "\n⭐ \033[0;33mAnsible: Make provisioning by tag "foobar"...\n\033[0m\n"
ansible-playbook -i ansible/inventory/production ansible/provision.yml --tags="foobar"
ansible-playbook ansible/provision.yml --tags="foobar"
2 changes: 1 addition & 1 deletion tests/outputs/ansible-provision.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ __MAKE__ ansible-install-roles
printf "\n⭐ \033[0;33mAnsible: Install Ansible roles...\n\033[0m\n"
ansible-galaxy install -r ansible/requirements.yml -p ansible/roles
printf "\n⭐ \033[0;33mAnsible: Make dry run on provisioning...\n\033[0m\n"
ansible-playbook -i ansible/inventory/production ansible/provision.yml
ansible-playbook ansible/provision.yml

0 comments on commit 27ed701

Please sign in to comment.