mirror of
https://github.com/willshersystems/ansible-sshd
synced 2024-11-26 21:10:18 +01:00
120 lines
5.5 KiB
YAML
120 lines
5.5 KiB
YAML
---
|
|
os: linux
|
|
dist: focal
|
|
language: python
|
|
addons:
|
|
apt_packages:
|
|
- yamllint
|
|
|
|
notifications:
|
|
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
|
|
|
before_install:
|
|
- sudo -H pip3 install ansible
|
|
|
|
install:
|
|
# Add ansible.cfg to pick up roles path.
|
|
- "{ echo '[defaults]'; echo 'roles_path = ../'; echo 'deprecation_warnings=False'; } >> ansible.cfg"
|
|
|
|
script:
|
|
# Test 0a: Check the roles syntax.
|
|
- "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_default.yml --syntax-check"
|
|
|
|
# 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
|
|
- "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_default.yml --connection=local --become -v"
|
|
|
|
# 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)
|
|
- >
|
|
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'
|
|
&& (echo 'Idempotence test: pass' && exit 0)
|
|
|| (echo 'Idempotence test: fail' && exit 1)
|
|
|
|
# Test 3: Check we can set arbitrary configuration options
|
|
- >
|
|
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
|
|
- >
|
|
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
|
|
- >
|
|
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)
|
|
|
|
# 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)
|
|
|
|
# Test 6: Test match blocks generators
|
|
- >
|
|
ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/tests_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/tests_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)
|
|
|
|
# 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 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)
|