Skip to content

Commit

Permalink
Test alternative configuration file creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakuje committed Sep 23, 2020
1 parent faef930 commit e5ad657
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,10 @@ script:
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)
# 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)
31 changes: 31 additions & 0 deletions tests/test_alternative_file.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
- hosts: all
become: true
tasks:
- name: Configure alternative sshd_config file
include_role:
name: ansible-sshd
vars:
# just anything -- will not get processed by sshd
sshd_config_file: /etc/ssh/sshd_config_custom
sshd_skip_defaults: true
sshd:
AcceptEnv: LANG
Banner: /etc/issue
Ciphers: [email protected]

- name: Verify the options are correctly set
block:
- meta: flush_handlers

- name: Print current configuration file
command: cat /etc/ssh/sshd_config_custom
register: config

- name: Check the options are in configuration file
assert:
that:
- "'AcceptEnv LANG' in config.stdout"
- "'Banner /etc/issue' in config.stdout"
- "'Ciphers [email protected]' in config.stdout"
tags: tests::verify

0 comments on commit e5ad657

Please sign in to comment.