Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: check generated files for ansible_managed, fingerprint #165

Merged
merged 1 commit into from
Apr 20, 2023

Conversation

richm
Copy link
Collaborator

@richm richm commented Apr 19, 2023

Add the following files: tests/tasks/check_header.yml and
tests/templates/get_ansible_managed.j2.
Use check_header.yml to check generated files for the ansible_managed
and fingerprint headers.
check_header.yml takes two parameters:

  • __file - required - the full path of the file to check e.g. /etc/realmd.conf
  • __fingerprint - required - the fingerprint string system_role:$ROLENAME e.g.
    __fingerprint: "system_role:postfix"
  • __comment_type - optional, default plain - the type of comments used

e.g. __comment_type: c for C/C++-style comments. plain uses #.
See https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_filters.html#adding-comments-to-files
for the different types of comment styles supported.

Example:

- name: Check generated files for ansible_managed, fingerprint
  include_tasks: tasks/check_header.yml
  vars:
    __file: /etc/myfile.conf
    __fingerprint: "system_role:my_role"

@richm richm requested a review from rjeffman as a code owner April 19, 2023 18:13
@richm
Copy link
Collaborator Author

richm commented Apr 19, 2023

[citest]

Add the following files: tests/tasks/check_header.yml and
tests/templates/get_ansible_managed.j2.
Use check_header.yml to check generated files for the ansible_managed
and fingerprint headers.
check_header.yml takes these parameters:

* `__file` - required - the full path of the file to check e.g. `/etc/realmd.conf`
* `__fingerprint` - required - the fingerprint string `system_role:$ROLENAME` e.g.
  `__fingerprint: "system_role:postfix"`
* `__comment_type` - optional, default `plain` - the type of comments used

e.g. `__comment_type: c` for C/C++-style comments.  `plain` uses `#`.
See https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_filters.html#adding-comments-to-files
for the different types of comment styles supported.

Example:
```
- name: Check generated files for ansible_managed, fingerprint
  include_tasks: tasks/check_header.yml
  vars:
    __file: /etc/myfile.conf
    __fingerprint: "system_role:my_role"
```
@richm richm merged commit 47b6483 into linux-system-roles:main Apr 20, 2023
13 checks passed
@richm richm deleted the check_fingerprint branch April 20, 2023 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant