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
|
2020-10-21 18:32:06 +02:00
|
|
|
addons:
|
|
|
|
apt_packages:
|
|
|
|
- yamllint
|
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-10-21 18:32:06 +02:00
|
|
|
# Test 0a: Check the roles syntax.
|
2020-10-21 17:21:05 +02:00
|
|
|
- "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_default.yml --syntax-check"
|
2015-01-12 22:01:08 +01:00
|
|
|
|
2020-10-21 18:32:06 +02:00
|
|
|
# Test 0b: Run yamllint with galaxy configuration to avoid quality score penalty
|
|
|
|
- wget https://raw.githubusercontent.com/ansible/galaxy/devel/galaxy/importer/linters/yamllint.yaml
|
|
|
|
- "yamllint -c yamllint.yaml **/*.yml"
|
|
|
|
|
2020-11-20 23:12:48 +01:00
|
|
|
# Test 0.5: OS defaults: Travis images have heavily updated (even with invalid configuration options)
|
|
|
|
# sshd_config so it does not make sense to test OS defaults here
|
|
|
|
|
2020-09-17 17:26:09 +02:00
|
|
|
# Test 1a: Run the role
|
2020-10-21 17:21:05 +02:00
|
|
|
- "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_default.yml --connection=local --become -v"
|
2015-01-12 22:01:08 +01:00
|
|
|
|
2020-11-20 23:12:04 +01:00
|
|
|
# Test 1b: Run the role through include (skipping backup)
|
|
|
|
- "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_default_include.yml -e sshd_test_backup_skip=yes --connection=local --become -v"
|
2020-09-17 17:26:09 +02:00
|
|
|
|
2020-11-20 23:12:04 +01:00
|
|
|
# Test 2: Run the role/playbook again, checking to make sure it's idempotent (skipping backup)
|
2015-01-12 22:12:32 +01:00
|
|
|
- >
|
2020-11-20 23:12:04 +01:00
|
|
|
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_default.yml --connection=local -e sshd_test_backup_skip=yes --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
|
|
|
|
- >
|
2020-10-21 17:21:05 +02:00
|
|
|
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_set_common.yml --connection=local --become -v
|
2020-09-17 16:06:04 +02:00
|
|
|
&& (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
|
|
|
|
- >
|
2020-10-21 17:21:05 +02:00
|
|
|
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_set_uncommon.yml --connection=local --become -v
|
2020-09-17 17:22:52 +02:00
|
|
|
&& (echo 'Uncommon configuration test: pass' && exit 0)
|
|
|
|
|| (echo 'Uncommon configuration test: fail' && exit 1)
|
2020-09-18 14:12:16 +02:00
|
|
|
|
2021-06-02 12:05:51 +02:00
|
|
|
# Test 5a: Make sure we can modify other files, for example for inclusion
|
2020-09-18 14:12:16 +02:00
|
|
|
# in the main sshd_config or second sshd service
|
|
|
|
- >
|
2020-10-21 17:21:05 +02:00
|
|
|
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_alternative_file.yml --connection=local --become -v
|
2020-09-18 14:12:16 +02:00
|
|
|
&& (echo 'Alternative configuration file test: pass' && exit 0)
|
|
|
|
|| (echo 'Alternative configuration file test: fail' && exit 1)
|
2020-10-08 18:10:05 +02:00
|
|
|
|
2021-06-02 12:05:51 +02:00
|
|
|
# Test 5b: Make sure we can modify other files, for example for inclusion
|
|
|
|
# in the main sshd_config or second sshd service using the old invocation
|
|
|
|
- >
|
|
|
|
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_alternative_file_role.yml --connection=local --become -v
|
|
|
|
&& (echo 'Alternative configuration file role test: pass' && exit 0)
|
|
|
|
|| (echo 'Alternative configuration file role test: fail' && exit 1)
|
|
|
|
|
2020-10-08 18:10:05 +02:00
|
|
|
# Test 6: Test match blocks generators
|
|
|
|
- >
|
2020-10-21 17:21:05 +02:00
|
|
|
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_match.yml --connection=local --become -v
|
2020-10-08 18:10:05 +02:00
|
|
|
&& (echo 'Match blocks test: pass' && exit 0)
|
|
|
|
|| (echo 'Match blocks test: fail' && exit 1)
|
|
|
|
|
|
|
|
# Test 7: Test match blocks generators with iteration
|
|
|
|
- >
|
2020-10-21 17:21:05 +02:00
|
|
|
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_match_iterate.yml --connection=local --become -v
|
2020-10-08 18:10:05 +02:00
|
|
|
&& (echo 'Match blocks with iteration test: pass' && exit 0)
|
|
|
|
|| (echo 'Match blocks with iteration test: fail' && exit 1)
|
2020-11-06 17:51:11 +01:00
|
|
|
|
2021-06-02 11:12:26 +02:00
|
|
|
# Test 8a: Test hostkeys can be generated by this role
|
2020-11-06 17:51:11 +01:00
|
|
|
- >
|
|
|
|
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_hostkeys.yml --connection=local --become -v
|
|
|
|
&& (echo 'Hostkeys test: pass' && exit 0)
|
|
|
|
|| (echo 'Hostkeys test: fail' && exit 1)
|
|
|
|
|
2021-06-02 11:12:26 +02:00
|
|
|
# Test 8b: Test hostkeys can be generated by this role using old invocation
|
|
|
|
- >
|
|
|
|
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_hostkeys_role.yml --connection=local --become -v
|
|
|
|
&& (echo 'Hostkeys role test: pass' && exit 0)
|
|
|
|
|| (echo 'Hostkeys role test: fail' && exit 1)
|
|
|
|
|
2020-11-06 17:51:11 +01:00
|
|
|
# Test 9: Test missing hostkeys
|
|
|
|
- >
|
|
|
|
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_hostkeys_missing.yml --connection=local --become -v
|
|
|
|
&& (echo 'Missing hostkeys test: pass' && exit 0)
|
|
|
|
|| (echo 'Missing hostkeys test: fail' && exit 1)
|
2020-11-20 23:38:38 +01:00
|
|
|
|
|
|
|
# Test 10: Test sshd_enable has effect
|
|
|
|
- >
|
|
|
|
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_sshd_enable.yml --connection=local --become -v
|
|
|
|
&& (echo 'Test sshd_enable: pass' && exit 0)
|
|
|
|
|| (echo 'Test sshd_enable: fail' && exit 1)
|
2020-11-21 00:24:32 +01:00
|
|
|
|
|
|
|
# Test 11: Test variable precedence
|
|
|
|
- >
|
|
|
|
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_precedence.yml --connection=local --become -v
|
|
|
|
&& (echo 'Variable precedence test: pass' && exit 0)
|
|
|
|
|| (echo 'Variable precedence test: fail' && exit 1)
|
2020-11-24 09:48:43 +01:00
|
|
|
|
|
|
|
# Test 12: Verify backups are created
|
|
|
|
- >
|
|
|
|
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_backup.yml --connection=local --become -v
|
|
|
|
&& (echo 'Backup test: pass' && exit 0)
|
|
|
|
|| (echo 'Backup test: fail' && exit 1)
|
2021-05-20 16:52:29 +02:00
|
|
|
|
|
|
|
# Test 13: Verify configuration append
|
|
|
|
- >
|
|
|
|
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_namespace_append.yml --connection=local --become -v
|
|
|
|
&& (echo 'Append test: pass' && exit 0)
|
|
|
|
|| (echo 'Append test: fail' && exit 1)
|