2023-07-16 17:28:34 +05:30
|
|
|
# SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
|
|
|
|
|
|
|
define configure_ping
|
|
|
|
ansible-playbook -i ./ansible/inventory/hosts.ini -f 10 ./ansible/ping.yml
|
|
|
|
endef
|
|
|
|
|
|
|
|
define configure_base
|
|
|
|
ansible-playbook -i ./ansible/inventory/hosts.ini -f 10 ./ansible/playbook.yml
|
2023-07-20 13:43:44 +05:30
|
|
|
ansible-playbook -i ./ansible/inventory/hosts.ini -f 10 ./ansible/harden.yml
|
2023-07-16 17:28:34 +05:30
|
|
|
endef
|
|
|
|
|
|
|
|
define configure_loadbalance
|
|
|
|
ansible-playbook -i ./ansible/inventory/hosts.ini -f 10 ./ansible/loadbalance.yml
|
|
|
|
endef
|
|
|
|
|
|
|
|
define configure_libreddit
|
|
|
|
ansible-playbook -i ./ansible/inventory/hosts.ini -f 10 ./ansible/libreddit.yml
|
|
|
|
endef
|
|
|
|
|
|
|
|
define test_base
|
|
|
|
. ./venv/bin/activate && \
|
|
|
|
cd tests/ && \
|
|
|
|
py.test --hosts='ansible://all' \
|
|
|
|
-n 10 \
|
|
|
|
--verbose \
|
|
|
|
--ansible-inventory='../ansible/inventory/hosts.ini' \
|
|
|
|
test_basic.py
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
define test_libreddit
|
|
|
|
. ./venv/bin/activate && \
|
|
|
|
cd tests/ && \
|
|
|
|
py.test --hosts='ansible://bullseye_libreddit' \
|
|
|
|
-n 10 \
|
|
|
|
--verbose \
|
|
|
|
--ansible-inventory='../ansible/inventory/hosts.ini' \
|
|
|
|
test_libreddit.py
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
define test_loadbalance
|
|
|
|
. ./venv/bin/activate && \
|
|
|
|
cd tests/ && \
|
|
|
|
py.test --hosts='ansible://bullseye_loadbalance' \
|
|
|
|
-n 10 \
|
|
|
|
--verbose \
|
|
|
|
--ansible-inventory='../ansible/inventory/hosts.ini' \
|
|
|
|
test_loadbalance.py
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
2023-07-16 19:53:39 +05:30
|
|
|
configure: ## Configure whole deployment
|
2023-07-16 17:28:34 +05:30
|
|
|
$(call configure_ping)
|
|
|
|
$(call configure_base)
|
|
|
|
$(call configure_libreddit)
|
|
|
|
$(call configure_loadbalance)
|
|
|
|
|
2023-07-16 19:53:39 +05:30
|
|
|
configure.ping: ## Ping all VMs
|
2023-07-16 17:28:34 +05:30
|
|
|
$(call configure_ping)
|
|
|
|
|
2023-07-16 19:53:39 +05:30
|
|
|
configure.base: ## Configure all VMs to base production configuration
|
2023-07-16 17:28:34 +05:30
|
|
|
$(call configure_ping)
|
|
|
|
$(call configure_base)
|
|
|
|
|
2023-07-16 19:53:39 +05:30
|
|
|
configure.libreddit: ## Configure libreddit
|
2023-07-16 17:28:34 +05:30
|
|
|
$(call configure_ping)
|
|
|
|
$(call configure_libreddit)
|
|
|
|
|
2023-07-16 19:53:39 +05:30
|
|
|
configure.loadbalance: ## Configure loadbalancer
|
2023-07-16 17:28:34 +05:30
|
|
|
$(call configure_ping)
|
|
|
|
$(call configure_loadbalance)
|
|
|
|
|
|
|
|
|
2023-07-16 19:53:39 +05:30
|
|
|
lint: ## Lint source code
|
2023-07-16 17:28:34 +05:30
|
|
|
terraform fmt
|
|
|
|
ansible-lint --write ./ansible/playbook.yml
|
|
|
|
ansible-lint --write ./ansible/shutdown.yml
|
|
|
|
ansible-lint --write ./ansible/loadbalance.yml
|
|
|
|
ansible-lint --write ./ansible/libreddit.yml
|
|
|
|
. ./venv/bin/activate && black tests/
|
|
|
|
|
2023-07-16 19:53:39 +05:30
|
|
|
on: ## Boot VMs
|
2023-07-16 17:28:34 +05:30
|
|
|
./scripts/on.sh
|
|
|
|
virsh list
|
|
|
|
|
2023-07-16 19:53:39 +05:30
|
|
|
shutdown: ## Shutdown VMs
|
2023-07-16 17:28:34 +05:30
|
|
|
ansible-playbook -i ./ansible/inventory/hosts.ini -f 10 ./ansible/shutdown.yml
|
|
|
|
|
2023-07-16 19:53:39 +05:30
|
|
|
test: ## Run all tests
|
2023-07-16 17:28:34 +05:30
|
|
|
$(call test_base)
|
|
|
|
$(call test_loadbalance)
|
|
|
|
$(call test_libreddit)
|
|
|
|
|
2023-07-16 19:53:39 +05:30
|
|
|
test.base: ## Test base configuration on all VMs
|
2023-07-16 17:28:34 +05:30
|
|
|
$(call test_base)
|
|
|
|
|
2023-07-16 19:53:39 +05:30
|
|
|
test.loadbalance: ## Test loadbalancer installation
|
2023-07-16 17:28:34 +05:30
|
|
|
$(call test_loadbalance)
|
|
|
|
|
2023-07-16 19:53:39 +05:30
|
|
|
test.libreddit: ## Test libreddit installation
|
2023-07-16 17:28:34 +05:30
|
|
|
$(call test_libreddit)
|
2023-07-16 19:53:39 +05:30
|
|
|
|
|
|
|
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}'
|