feat-test-playbooks #5

Merged
realaravinth merged 19 commits from feat-test-playbooks into master 2023-12-13 00:49:03 +05:30
2 changed files with 24 additions and 23 deletions
Showing only changes of commit 713ec1dd18 - Show all commits

View file

@ -1,33 +1,22 @@
steps: steps:
backend: backend:
image: python:3-bookworm image: python:3-bookworm
environment:
- ANSIBLE_HOST_KEY_CHECKING=False
commands: commands:
- apt-get update - export PATH=$PATH:/root/.local/bin
- apt-get install -y ca-certificates curl gnupg tar wget libssl-dev python3-pip cython3 pipx apt-transport-https coreutils iputils-ping openssh-client libvirt-clients genisoimage
- make ci.init
- cat /tmp/ci-ssh-id
- eval "$(ssh-agent -s)" - eval "$(ssh-agent -s)"
- ssh-add /tmp/ci-ssh-id - make ci.init
- ssh -o StrictHostKeyChecking=accept-new mcaptcha-ci@192.168.0.102 "echo f"
- install -m 0755 -d /etc/apt/keyrings
- curl -fsSL https://packages.opentofu.org/opentofu/tofu/gpgkey | gpg --no-tty --batch --dearmor -o /etc/apt/keyrings/opentofu.gpg
- chmod a+r /etc/apt/keyrings/opentofu.gpg
- echo "deb [signed-by=/etc/apt/keyrings/opentofu.gpg] https://packages.opentofu.org/opentofu/tofu/any/ any main" > /etc/apt/sources.list.d/opentofu.list
echo "deb-src [signed-by=/etc/apt/keyrings/opentofu.gpg] https://packages.opentofu.org/opentofu/tofu/any/ any main" >> /etc/apt/sources.list.d/opentofu.list
- apt-get update
- apt-get install -y tofu
- tofu -chdir=terraform/mcaptcha/ init - tofu -chdir=terraform/mcaptcha/ init
- tofu -chdir=terraform/mcaptcha/ plan -var-file="ci.tfvars" -out="mcaptcha" - tofu -chdir=terraform/mcaptcha/ plan -var-file="ci.tfvars" -out="mcaptcha"
- tofu -chdir=terraform/mcaptcha/ apply "mcaptcha" - tofu -chdir=terraform/mcaptcha/ apply "mcaptcha"
- cd ../../ - pip install virtualenv && virtualenv venv
- pipx install --include-deps ansible - . venv/bin/activate && pip install ansible pytest-testinfra requests
- pipx ensurepath && echo $SHELL - . venv/bin/activate && ansible-galaxy install -r ./ansible/requirements.yml
- /root/.local/bin/ansible-galaxy install -r ./ansible/requirements.yml - . venv/bin/activate && ansible-playbook --become -i terraform/mcaptcha/hosts.ini ./ansible/mcaptcha.yml
- /root/.local/bin/ansible-playbook --become --connection=local -i localhost, --limit 127.0.0.1 ./ansible/mcaptcha.yml - cat terraform/mcaptcha/hosts.ini
- pipx install --include-deps pytest-testinfra - export ANSIBLE_REMOTE_USER=root
- cd tests/cache/ && py.test --verbose base.py - . venv/bin/activate && py.test --hosts="ansible://mcaptcha_hosts" --ansible-inventory=terraform/mcaptcha/hosts.ini --verbose tests/cache/base.py
- cd tests/mcaptcha/ && py.test --verbose base.py - . venv/bin/activate && py.test --hosts="ansible://mcaptcha_hosts" --ansible-inventory=terraform/mcaptcha/hosts.ini --verbose tests/mcaptcha/base.py
- echo yes | tofu destroy \
-var-file="ci.tfvars"
- make ci.clean - make ci.clean
secrets: [TEST_NODE_SSH_KEY] secrets: [TEST_NODE_SSH_KEY]

View file

@ -135,9 +135,21 @@ test.mcaptcha: ## Test mcaptcha configuration
$(call test_mcaptcha) $(call test_mcaptcha)
ci.init: ci.init:
apt-get update
apt-get install -y ca-certificates curl gnupg tar wget libssl-dev python3-pip cython3 pipx apt-transport-https coreutils iputils-ping openssh-client libvirt-clients genisoimage
./scripts/ci.sh --init "$$TEST_NODE_SSH_KEY" ./scripts/ci.sh --init "$$TEST_NODE_SSH_KEY"
ssh-add /tmp/ci-ssh-id
ssh -o StrictHostKeyChecking=accept-new mcaptcha-ci@192.168.0.102 "echo f"
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://packages.opentofu.org/opentofu/tofu/gpgkey | gpg --no-tty --batch --dearmor -o /etc/apt/keyrings/opentofu.gpg
chmod a+r /etc/apt/keyrings/opentofu.gpg
echo "deb [signed-by=/etc/apt/keyrings/opentofu.gpg] https://packages.opentofu.org/opentofu/tofu/any/ any main" > /etc/apt/sources.list.d/opentofu.list
echo "deb-src [signed-by=/etc/apt/keyrings/opentofu.gpg] https://packages.opentofu.org/opentofu/tofu/any/ any main" >> /etc/apt/sources.list.d/opentofu.list
apt-get update
apt-get install -y tofu
ci.clean: ci.clean:
echo yes | tofu destroy -var-file="ci.tfvars"
./scripts/ci.sh --clean ./scripts/ci.sh --clean
help: ## Prints help for targets with comments help: ## Prints help for targets with comments