Infrastructure-as-Code/debian/Makefile

48 lines
1.6 KiB
Makefile

env: ## Init environment
terraform init
ansible-galaxy install -r ./ansible/requirements.yml
virtualenv vent
. ./venv/bin/activate && pip install -r requirements.txt
default:
terraform plan --out=plan
terraform apply plan
inventory: ## Deploy server
terraform plan --out=plan
terraform apply plan
configure: ## Configure server
ansible-playbook -i ./ansible/inventory/hosts.ini -f 10 ./ansible/playbook.yml
ansible-playbook -i ./ansible/inventory/hosts.ini -f 10 ./ansible/install-librepages.yml
ansible-playbook -i ./ansible/inventory/hosts.ini -f 10 ./ansible/install-librepages-forms.yml
ansible-playbook -i ./ansible/inventory/hosts.ini -f 10 ./ansible/install-librepages-conductor.yml
# ansible-playbook -i ./ansible/inventory/hosts.ini -f 10 ./ansible/linux-baseline.yml
ansible-check: ## Check Ansible playbooks
ansible-playbook --check ./ansible/playbook.yml
lint: ## Lint source code
terraform fmt
ansible-lint --write ./ansible/playbook.yml
ansible-lint --write ./ansible/shutdown.yml
. ./venv/bin/activate && black tests/
on: ## Power on VMs
./scripts/on.sh
virsh list
shutdown: ## Shut down vms
ansible-playbook -i ./ansible/inventory/hosts.ini -f 10 ./ansible/shutdown.yml
test: ## Test VM configuration
. ./venv/bin/activate && \
cd tests/ && \
py.test --hosts='ansible://all' \
-n 10 \
--verbose \
--ansible-inventory='../ansible/inventory/hosts.ini'
help: ## Prints help for targets with comments
@cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'