2021-06-20 20:26:09 -05:00
|
|
|
image: ubuntu:focal
|
|
|
|
stages:
|
2021-07-31 20:03:38 -05:00
|
|
|
- lint
|
2021-06-20 20:26:09 -05:00
|
|
|
- test
|
|
|
|
- play
|
|
|
|
before_script:
|
|
|
|
# Get the packages we need
|
|
|
|
- apt-get update
|
2021-07-31 20:03:38 -05:00
|
|
|
- apt-get install openssh-client python3-docker python3-pip python-is-python3 -y
|
2021-06-20 20:26:09 -05:00
|
|
|
- pip install ansible ansible-lint
|
|
|
|
# Dump our key
|
|
|
|
- eval $(ssh-agent -s)
|
|
|
|
- echo "$ANSIBLE_SSH_KEY" | tr -d '\r' | ssh-add -
|
|
|
|
- mkdir -p ~/.ssh
|
|
|
|
- chmod -R 0700 ~/.ssh
|
|
|
|
# Dump the vault password
|
|
|
|
- touch /vaultpw
|
|
|
|
- chmod 0600 /vaultpw
|
|
|
|
- echo "$ANSIBLE_VAULT_PASSWORD" > /vaultpw
|
|
|
|
# Fix perms on the playbook root
|
|
|
|
- chmod -R 0750 .
|
|
|
|
# Get ready for execution
|
|
|
|
- ansible-galaxy install -r roles/requirements.yml -p roles
|
|
|
|
|
|
|
|
Lint:
|
|
|
|
allow_failure: yes
|
2021-07-31 20:03:38 -05:00
|
|
|
stage: lint
|
2021-06-20 20:26:09 -05:00
|
|
|
script:
|
|
|
|
- ansible-lint --version
|
|
|
|
- ansible-lint site.yml
|
|
|
|
|
|
|
|
Test:
|
|
|
|
allow_failure: yes
|
|
|
|
stage: test
|
|
|
|
script:
|
|
|
|
- ansible-playbook --skip-tags no-test -C site.yml --vault-password-file /vaultpw
|
|
|
|
|
2021-07-31 19:49:14 -05:00
|
|
|
Play_Against_Pis:
|
2021-06-20 20:26:09 -05:00
|
|
|
stage: play
|
|
|
|
script:
|
2021-07-31 19:49:14 -05:00
|
|
|
- ansible-playbook -l pis site.yml --vault-password-file /vaultpw
|
|
|
|
Play_Against_Desktops:
|
|
|
|
stage: play
|
|
|
|
script:
|
|
|
|
- ansible-playbook -l desktop site.yml --vault-password-file /vaultpw
|
|
|
|
Play_Against_Production:
|
|
|
|
stage: play
|
|
|
|
script:
|
|
|
|
- ansible-playbook -l prod site.yml --vault-password-file /vaultpw
|