From 296f428b9c7ab0c42cc609e5b63672df64456c38 Mon Sep 17 00:00:00 2001 From: Jimmy McCrory Date: Sat, 3 Nov 2018 23:34:07 -0700 Subject: [PATCH] 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 --- tasks/lxc_container_config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/lxc_container_config.yml b/tasks/lxc_container_config.yml index 8575af8..2f65062 100644 --- a/tasks/lxc_container_config.yml +++ b/tasks/lxc_container_config.yml @@ -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 }}"