mirror of
https://github.com/willshersystems/ansible-sshd
synced 2024-11-21 18:40:19 +01:00
Merge pull request #232 from richm/check_fingerprint
test: check generated files for ansible_managed, fingerprint
This commit is contained in:
commit
a36faf9309
4 changed files with 25 additions and 0 deletions
|
@ -1,2 +1,3 @@
|
|||
exclude_paths:
|
||||
- tests/roles/
|
||||
- .tox/
|
||||
|
|
16
tests/tasks/check_header.yml
Normal file
16
tests/tasks/check_header.yml
Normal file
|
@ -0,0 +1,16 @@
|
|||
# SPDX-License-Identifier: MIT
|
||||
---
|
||||
- name: Get file
|
||||
ansible.builtin.slurp:
|
||||
path: "{{ __file }}"
|
||||
register: __content
|
||||
when: not __file_content is defined
|
||||
|
||||
- name: Check for presence of ansible managed header, fingerprint
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- ansible_managed in content
|
||||
- __fingerprint in content
|
||||
vars:
|
||||
content: "{{ (__file_content | d(__content)).content | b64decode }}"
|
||||
ansible_managed: "{{ lookup('template', 'get_ansible_managed.j2') }}"
|
1
tests/templates/get_ansible_managed.j2
Normal file
1
tests/templates/get_ansible_managed.j2
Normal file
|
@ -0,0 +1 @@
|
|||
{{ ansible_managed | comment(__comment_type | d("plain")) }}
|
|
@ -118,5 +118,12 @@
|
|||
"{{ sshd_options.stdout_lines }}"
|
||||
when: not sshd_skip_test
|
||||
|
||||
- name: Check generated files for ansible_managed, fingerprint
|
||||
ansible.builtin.include_tasks: tasks/check_header.yml
|
||||
vars:
|
||||
__file_content: "{{ config }}"
|
||||
__fingerprint: "willshersystems:ansible-sshd"
|
||||
when: not sshd_skip_test
|
||||
|
||||
- name: Restore configuration files
|
||||
ansible.builtin.include_tasks: tasks/restore.yml
|
||||
|
|
Loading…
Reference in a new issue