Merge pull request #232 from richm/check_fingerprint

test: check generated files for ansible_managed, fingerprint
This commit is contained in:
Richard Megginson 2023-04-26 10:01:31 -06:00 committed by GitHub
commit a36faf9309
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 0 deletions

View file

@ -1,2 +1,3 @@
exclude_paths:
- tests/roles/
- .tox/

View 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') }}"

View file

@ -0,0 +1 @@
{{ ansible_managed | comment(__comment_type | d("plain")) }}

View file

@ -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