-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from Jakuje/tests
Implement more sanity tests
- Loading branch information
Showing
8 changed files
with
193 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
- hosts: all | ||
become: true | ||
tasks: | ||
- name: "Configure sshd" | ||
include_role: | ||
name: ansible-sshd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
- hosts: all | ||
become: true | ||
tasks: | ||
- name: Configure sshd | ||
include_role: | ||
name: ansible-sshd | ||
vars: | ||
sshd: | ||
AcceptEnv: LANG | ||
Banner: /etc/issue | ||
Ciphers: [email protected] | ||
Subsystem: "sftp internal-sftp" | ||
|
||
- name: Verify the options are correctly set | ||
block: | ||
- meta: flush_handlers | ||
|
||
- name: List effective configuration using sshd -T | ||
command: sshd -T | ||
register: runtime | ||
|
||
- name: Print current configuration file | ||
command: cat /etc/ssh/sshd_config | ||
register: config | ||
|
||
- name: Check the options are effective | ||
# note, the options are in lower-case here | ||
assert: | ||
that: | ||
- "'acceptenv LANG' in runtime.stdout" | ||
- "'banner /etc/issue' in runtime.stdout" | ||
- "'ciphers [email protected]' in runtime.stdout" | ||
- "'subsystem sftp internal-sftp' in runtime.stdout" | ||
|
||
- 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" | ||
- "'Subsystem sftp internal-sftp' in config.stdout" | ||
tags: tests::verify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
- hosts: all | ||
become: true | ||
tasks: | ||
- name: Configure sshd with uncommon options, making sure it keeps running | ||
block: | ||
- name: Configure ssh with unsupported options | ||
include_role: | ||
name: ansible-sshd | ||
vars: | ||
sshd: | ||
# Unsupported in new versions, but ignored ? | ||
Protocol: 1 | ||
UsePrivilegeSeparation: no | ||
UseLogin: yes | ||
# Debian only | ||
DebianBanner: /etc/motd | ||
# Used in FreeBSD ? | ||
VersionAddendum: FreeBSD-20180909 | ||
# HPN only | ||
HPNDisabled: yes | ||
HPNBufferSize: 2MB | ||
TcpRcvBufPoll: yes | ||
NoneEnabled: yes | ||
# some builds might be without kerberos/GSSAPI | ||
KerberosAuthentication: yes | ||
GSSAPIStoreCredentialsOnRekey: yes | ||
# SSHv1 options | ||
KeyRegenerationInterval: 1h | ||
ServerKeyBits: 1024 | ||
# This one is pretty new, but works on OpenBSD only | ||
RDomain: 2 | ||
register: role_result | ||
|
||
- name: unreachable task | ||
fail: | ||
msg: UNREACH | ||
rescue: | ||
- name: Check that we failed in the role | ||
assert: | ||
that: | ||
- ansible_failed_result.msg != 'UNREACH' | ||
- not role_result.changed | ||
msg: "Role has not failed when it should have" | ||
|
||
- name: Make sure service is still running | ||
service: | ||
name: sshd | ||
state: started | ||
register: result | ||
failed_when: result.changed |