Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
systemd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
webarch
systemd
Commits
ff960678
Commit
ff960678
authored
2 years ago
by
Chris Croome
Browse files
Options
Downloads
Patches
Plain Diff
Fix for ansible_managed comment
parent
3ec9bc28
No related branches found
No related tags found
No related merge requests found
Pipeline
#24431
passed
2 years ago
Stage: lint
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
tasks/file_present.yml
+2
-3
2 additions, 3 deletions
tasks/file_present.yml
templates/ansible_managed.j2
+1
-0
1 addition, 0 deletions
templates/ansible_managed.j2
templates/unit.j2
+1
-1
1 addition, 1 deletion
templates/unit.j2
vars/main.yml
+3
-0
3 additions, 0 deletions
vars/main.yml
with
7 additions
and
4 deletions
tasks/file_present.yml
+
2
−
3
View file @
ff960678
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
templates/ansible_managed.j2
0 → 100644
+
1
−
0
View file @
ff960678
{{- ansible_managed -}}
This diff is collapsed.
Click to expand it.
templates/unit.j2
+
1
−
1
View file @
ff960678
{{
ansible_managed
|
ansible.builtin.comment
}}
#
{{
systemd_
ansible_managed }}
{%
if
systemd_file.comment
is
defined
%}
# BEGIN ANSIBLE MANAGED BLOCK
...
...
This diff is collapsed.
Click to expand it.
vars/main.yml
+
3
−
0
View file @
ff960678
---
# 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')
}}"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment