diff --git a/CHANGELOG.md b/CHANGELOG.md index 9201a629..d8bc1684 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ The **patch** part changes is incremented if multiple releases happen the same m * haproxy: add haproxy_allow_ip_nonlocal_bind to set sysctl value (optional) * kvm-host: fix depreciation of "drbd-overview" by "drbdadm status" in add-vm.sh * openvpn: configure logrotate +* lxc: Add /etc of containers in git ### Changed diff --git a/etc-git/tasks/repository.yml b/etc-git/tasks/repository.yml index 80987da2..24093c2d 100644 --- a/etc-git/tasks/repository.yml +++ b/etc-git/tasks/repository.yml @@ -45,8 +45,10 @@ - name: "Some entries MUST be in the {{ repository_path }}/.gitignore file" lineinfile: dest: "{{ repository_path }}/.gitignore" - line: "{{ item }}" + line: "{{ gitignore_line }}" loop: "{{ gitignore_items | default([]) }}" + loop_control: + loop_var: gitignore_line tags: - etc-git diff --git a/lxc/files/gitignore b/lxc/files/gitignore new file mode 120000 index 00000000..c2246c01 --- /dev/null +++ b/lxc/files/gitignore @@ -0,0 +1 @@ +../../etc-git/files/gitignore \ No newline at end of file diff --git a/lxc/tasks/create-container.yml b/lxc/tasks/create-container.yml index ad4f35d6..1a299f6e 100644 --- a/lxc/tasks/create-container.yml +++ b/lxc/tasks/create-container.yml @@ -52,6 +52,22 @@ insertbefore: "^exit 0$" when: release == 'jessie' +# For some reason import_role/include_role doesn't work here. +# Apparently ansible see some condition that end up being false. +# So we use import_tasks and a symlink. +- name: "Put /etc of container {{ name }} into git" + import_tasks: repository.yml + vars: + repository_path: "/var/lib/lxc/{{ name }}/rootfs/etc" + gitignore_items: + - "aliases.db" + - "*.swp" + - "postfix/sa-blacklist.access" + - "postfix/*.db" + - "postfix/spamd.cidr" + - "evobackup/.keep-*" + - "letsencrypt/.certbot.lock" + - name: "Ensure that {{ name }} container is running" lxc_container: name: "{{ name }}" diff --git a/lxc/tasks/main.yml b/lxc/tasks/main.yml index 70f5dc2b..91796a1b 100644 --- a/lxc/tasks/main.yml +++ b/lxc/tasks/main.yml @@ -52,6 +52,8 @@ - name: Create containers include: create-container.yml vars: - name: "{{ item.name }}" - release: "{{ item.release }}" + name: "{{ container.name }}" + release: "{{ container.release }}" loop: "{{ lxc_containers }}" + loop_control: + loop_var: container diff --git a/lxc/tasks/repository.yml b/lxc/tasks/repository.yml new file mode 120000 index 00000000..0576d445 --- /dev/null +++ b/lxc/tasks/repository.yml @@ -0,0 +1 @@ +../../etc-git/tasks/repository.yml \ No newline at end of file