mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.3 KiB
YAML
53 lines
1.3 KiB
YAML
- name: copy the sshd_config to the test dir
|
|
copy:
|
|
src: sshd_config
|
|
dest: "{{ output_dir_test }}"
|
|
|
|
- name: insert/update "Match User" configuration block in sshd_config
|
|
blockinfile:
|
|
path: "{{ output_dir_test }}/sshd_config"
|
|
block: |
|
|
Match User ansible-agent
|
|
PasswordAuthentication no
|
|
backup: yes
|
|
register: blockinfile_test0
|
|
|
|
- name: ensure we have a bcackup file
|
|
assert:
|
|
that:
|
|
- "'backup_file' in blockinfile_test0"
|
|
|
|
- name: check content
|
|
shell: 'grep -c -e "Match User ansible-agent" -e "PasswordAuthentication no" {{ output_dir_test }}/sshd_config'
|
|
register: blockinfile_test0_grep
|
|
|
|
- debug:
|
|
var: blockinfile_test0
|
|
verbosity: 1
|
|
|
|
- debug:
|
|
var: blockinfile_test0_grep
|
|
verbosity: 1
|
|
|
|
- name: validate first example results
|
|
assert:
|
|
that:
|
|
- 'blockinfile_test0.changed is defined'
|
|
- 'blockinfile_test0.msg is defined'
|
|
- 'blockinfile_test0.changed'
|
|
- 'blockinfile_test0.msg == "Block inserted"'
|
|
- 'blockinfile_test0_grep.stdout == "2"'
|
|
|
|
- name: check idemptotence
|
|
blockinfile:
|
|
path: "{{ output_dir_test }}/sshd_config"
|
|
block: |
|
|
Match User ansible-agent
|
|
PasswordAuthentication no
|
|
register: blockinfile_test1
|
|
|
|
- name: validate idempotence results
|
|
assert:
|
|
that:
|
|
- 'not blockinfile_test1.changed'
|