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 #192

Merged
merged 1 commit into from
Apr 26, 2023

Conversation

richm
Copy link
Collaborator

@richm richm commented Apr 21, 2023

Clean up more ansible-lint issues in code and README

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. fingerprint is required,
and one of __file or __file_content:

  • __file - the full path of the file to check e.g. /etc/realmd.conf
  • __file_content - the output of slurp of the file
  • __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"

Signed-off-by: Rich Megginson rmeggins@redhat.com

Clean up more ansible-lint issues in code and README

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.  `fingerprint` is required,
and one of `__file` or `__file_content`:

* `__file` - the full path of the file to check e.g. `/etc/realmd.conf`
* `__file_content` - the output of `slurp` of the file
* `__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"
```

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
@richm
Copy link
Collaborator Author

richm commented Apr 21, 2023

[citest]

1 similar comment
@richm
Copy link
Collaborator Author

richm commented Apr 25, 2023

[citest]

@spetrosi
Copy link
Contributor

[citest bad]

@richm richm merged commit db2a4cc into linux-system-roles:main Apr 26, 2023
@richm richm deleted the check_fingerprint branch April 26, 2023 13:43
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

2 participants