2015-01-12 22:01:08 +01:00
|
|
|
---
|
2020-09-18 12:19:01 +02:00
|
|
|
os: linux
|
2020-09-18 21:48:56 +02:00
|
|
|
dist: focal
|
2020-09-18 12:19:01 +02:00
|
|
|
language: python
|
2015-01-12 22:01:08 +01:00
|
|
|
|
2016-02-18 14:42:50 +01:00
|
|
|
notifications:
|
2020-09-18 21:48:56 +02:00
|
|
|
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
2016-02-18 14:42:50 +01:00
|
|
|
|
2015-01-12 22:01:08 +01:00
|
|
|
before_install:
|
2020-09-18 21:48:56 +02:00
|
|
|
- sudo -H pip3 install ansible
|
2015-01-12 22:01:08 +01:00
|
|
|
|
|
|
|
install:
|
|
|
|
# Add ansible.cfg to pick up roles path.
|
2020-09-18 21:48:56 +02:00
|
|
|
- "{ echo '[defaults]'; echo 'roles_path = ../'; echo 'deprecation_warnings=False'; } >> ansible.cfg"
|
2015-01-12 22:12:32 +01:00
|
|
|
|
2015-01-12 22:01:08 +01:00
|
|
|
script:
|
2020-09-17 16:06:04 +02:00
|
|
|
# Test 0: Check the roles syntax.
|
2020-09-17 14:48:41 +02:00
|
|
|
- "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_default.yml --syntax-check"
|
2015-01-12 22:01:08 +01:00
|
|
|
|
2020-09-17 17:26:09 +02:00
|
|
|
# Test 1a: Run the role
|
2020-09-17 14:48:41 +02:00
|
|
|
- "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_default.yml --connection=local --become -v"
|
2015-01-12 22:01:08 +01:00
|
|
|
|
2020-09-17 17:26:09 +02:00
|
|
|
# Test 1b: Run the role through include
|
|
|
|
- "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_default_include.yml --connection=local --become -v"
|
|
|
|
|
2020-09-17 16:06:04 +02:00
|
|
|
# Test 2: Run the role/playbook again, checking to make sure it's idempotent.
|
2015-01-12 22:12:32 +01:00
|
|
|
- >
|
2020-09-17 14:48:41 +02:00
|
|
|
ansible-playbook -i tests/inventory tests/test_default.yml --connection=local --become | grep -q 'changed=0.*failed=0'
|
2015-01-12 22:12:32 +01:00
|
|
|
&& (echo 'Idempotence test: pass' && exit 0)
|
|
|
|
|| (echo 'Idempotence test: fail' && exit 1)
|
2020-09-17 16:06:04 +02:00
|
|
|
|
|
|
|
# Test 3: Check we can set arbitrary configuration options
|
|
|
|
- >
|
|
|
|
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_set_common.yml --connection=local --become -v
|
|
|
|
&& (echo 'Common variables test: pass' && exit 0)
|
|
|
|
|| (echo 'Common variables test: fail' && exit 1)
|
2020-09-17 17:22:52 +02:00
|
|
|
|
|
|
|
# Test 4: Check if we set uncommon or unsupported configuration option, it will not fail hard
|
|
|
|
- >
|
|
|
|
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_set_uncommon.yml --connection=local --become -v
|
|
|
|
&& (echo 'Uncommon configuration test: pass' && exit 0)
|
|
|
|
|| (echo 'Uncommon configuration test: fail' && exit 1)
|
2020-09-18 14:12:16 +02:00
|
|
|
|
|
|
|
# Test 5: Make sure we can modify other files, for example for inclusion
|
|
|
|
# in the main sshd_config or second sshd service
|
|
|
|
- >
|
|
|
|
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_alternative_file.yml --connection=local --become -v
|
|
|
|
&& (echo 'Alternative configuration file test: pass' && exit 0)
|
|
|
|
|| (echo 'Alternative configuration file test: fail' && exit 1)
|
2020-10-08 18:10:05 +02:00
|
|
|
|
|
|
|
# Test 6: Test match blocks generators
|
|
|
|
- >
|
|
|
|
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_match.yml --connection=local --become -v
|
|
|
|
&& (echo 'Match blocks test: pass' && exit 0)
|
|
|
|
|| (echo 'Match blocks test: fail' && exit 1)
|
|
|
|
|
|
|
|
# Test 7: Test match blocks generators with iteration
|
|
|
|
- >
|
|
|
|
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_match_iterate.yml --connection=local --become -v
|
|
|
|
&& (echo 'Match blocks with iteration test: pass' && exit 0)
|
|
|
|
|| (echo 'Match blocks with iteration test: fail' && exit 1)
|