Stop creating duplicate lines in lxc config files

The 'Ensure containers have access RO cgroups' will currently add the
same line to an lxc container's config file on every run of the role.

Add a regular expression to the task to check if the line to be inserted
already exists in the file, and if so, don't insert it again.

Change-Id: I5ac57bd59ea943c019dd0a5530c8246284b33269
This commit is contained in:
Jimmy McCrory 2018-11-03 23:34:07 -07:00
parent 6509751e13
commit 296f428b9c

View File

@ -29,6 +29,7 @@
lineinfile:
dest: "/var/lib/lxc/{{ inventory_hostname }}/config"
line: "lxc.mount.auto = proc:rw sys:ro cgroup:ro"
regexp: "^lxc.mount.auto = proc:rw sys:ro cgroup:ro$"
insertafter: "^lxc.mount.auto"
backup: "true"
delegate_to: "{{ physical_host }}"