mirror of
https://github.com/willshersystems/ansible-sshd
synced 2024-11-10 05:33:29 +01:00
Document and test alternative invocation of role through include_role
This commit is contained in:
parent
1266519c23
commit
2744b2e225
3 changed files with 39 additions and 1 deletions
|
@ -17,9 +17,12 @@ script:
|
||||||
# Test 0: Check the roles syntax.
|
# Test 0: Check the roles syntax.
|
||||||
- "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_default.yml --syntax-check"
|
- "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_default.yml --syntax-check"
|
||||||
|
|
||||||
# Test 1: Run the role
|
# Test 1a: Run the role
|
||||||
- "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_default.yml --connection=local --become -v"
|
- "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_default.yml --connection=local --become -v"
|
||||||
|
|
||||||
|
# Test 1b: Run the role through include
|
||||||
|
- "ANSIBLE_FORCE_COLOR=1 ansible-playbook -i tests/inventory tests/test_default_include.yml --connection=local --become -v"
|
||||||
|
|
||||||
# Test 2: Run the role/playbook again, checking to make sure it's idempotent.
|
# Test 2: Run the role/playbook again, checking to make sure it's idempotent.
|
||||||
- >
|
- >
|
||||||
ansible-playbook -i tests/inventory tests/test_default.yml --connection=local --become | grep -q 'changed=0.*failed=0'
|
ansible-playbook -i tests/inventory tests/test_default.yml --connection=local --become | grep -q 'changed=0.*failed=0'
|
||||||
|
|
28
README.md
28
README.md
|
@ -206,6 +206,34 @@ Match Group xusers
|
||||||
X11Forwarding yes
|
X11Forwarding yes
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Since Ansible 2.4, the role can be invoked using `include_role` keyword,
|
||||||
|
for example:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
- hosts: all
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- name: "Configure sshd"
|
||||||
|
include_role:
|
||||||
|
name: willshersystems.sshd
|
||||||
|
vars:
|
||||||
|
sshd_skip_defaults: true
|
||||||
|
sshd:
|
||||||
|
Compression: true
|
||||||
|
ListenAddress:
|
||||||
|
- "0.0.0.0"
|
||||||
|
- "::"
|
||||||
|
GSSAPIAuthentication: no
|
||||||
|
Match:
|
||||||
|
- Condition: "Group user"
|
||||||
|
GSSAPIAuthentication: yes
|
||||||
|
sshd_UsePrivilegeSeparation: no
|
||||||
|
sshd_match:
|
||||||
|
- Condition: "Group xusers"
|
||||||
|
X11Forwarding: yes
|
||||||
|
|
||||||
|
|
||||||
Template Generation
|
Template Generation
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
|
7
tests/test_default_include.yml
Normal file
7
tests/test_default_include.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
- hosts: all
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- name: "Configure sshd"
|
||||||
|
include_role:
|
||||||
|
name: ansible-sshd
|
Loading…
Reference in a new issue