Skip to content
Snippets Groups Projects
Commit ff960678 authored by Chris Croome's avatar Chris Croome
Browse files

Fix for ansible_managed comment

parent 3ec9bc28
No related branches found
No related tags found
No related merge requests found
Pipeline #24431 passed
......@@ -75,7 +75,7 @@
- name: Ansible managed comment present at the top of the file
ansible.builtin.lineinfile:
path: "{{ systemd_file.path }}"
line: "{{ ansible_managed | ansible.builtin.comment }}"
line: "# {{ systemd_ansible_managed }}"
state: present
insertbefore: BOF
......@@ -121,8 +121,7 @@
when: >-
( not systemd_file_state.stat.exists | bool ) or
( systemd_file.state is not defined ) or
( systemd_file.state == "templated" )
( systemd_file.state is defined and systemd_file.state == "templated" )
- name: Include flush handlers task
ansible.builtin.include_tasks: flush_handlers.yml
......
{{- ansible_managed -}}
{{ ansible_managed | ansible.builtin.comment }}
# {{ systemd_ansible_managed }}
{% if systemd_file.comment is defined %}
# BEGIN ANSIBLE MANAGED BLOCK
......
---
# https://jpmens.net/2020/09/29/using-ansible-managed/
# https://github.com/ansible/ansible/issues/53627#issuecomment-471562410
systemd_ansible_managed: "{{ lookup('ansible.builtin.template', './templates/ansible_managed.j2') | trim }}"
systemd_file_backup: "{{ systemd_file.path | ansible.builtin.dirname }}/.{{ systemd_file.path | ansible.builtin.basename }}.{{ ansible_date_time.iso8601_basic_short }}.bak }}"
systemd_unit_files_enabled_query: "[?state == 'enabled'].unit_file"
systemd_unit_names: "{{ systemd_units | community.general.json_query('[*].name') }}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment