ansible-sshd/.travis.yml

121 lines
5.5 KiB
YAML
Raw Normal View History

2015-01-12 22:01:08 +01:00
---
os: linux
dist: focal
language: python
addons:
apt_packages:
- yamllint
2015-01-12 22:01:08 +01:00
2016-02-18 14:42:50 +01:00
notifications:
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:
- sudo -H pip3 install ansible
2015-01-12 22:01:08 +01:00
install:
# Add ansible.cfg to pick up roles path.
- "{ 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:
# 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
# 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"
# 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
# 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
# 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"
# Test 2: Run the role/playbook again, checking to make sure it's idempotent (skipping backup)
2015-01-12 22:12:32 +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)
# 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
&& (echo 'Common variables test: pass' && exit 0)
|| (echo 'Common variables test: fail' && exit 1)
# 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
&& (echo 'Uncommon configuration test: pass' && exit 0)
|| (echo 'Uncommon configuration test: fail' && exit 1)
# Test 5a: Make sure we can modify other files, for example for inclusion
# 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
&& (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 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)
# Test 8a: Test hostkeys can be generated by this role
- >
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)
# 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)
# 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)
# 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)
# 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)
# 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)
# Test 13: Verify configuration namespace
- >
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_config_namespace.yml --connection=local --become -v
&& (echo 'Namespace test: pass' && exit 0)
|| (echo 'Namespace test: fail' && exit 1)