diff --git a/tasks/lxc_cache_preparation.yml b/tasks/lxc_cache_preparation.yml index 733bbc8e..f249cbb5 100644 --- a/tasks/lxc_cache_preparation.yml +++ b/tasks/lxc_cache_preparation.yml @@ -35,6 +35,30 @@ {%- endfor %} {{- images -}} +- block: + - name: Create machined proxy override unit directories + file: + path: "/etc/systemd/system/{{ item }}" + owner: root + group: root + mode: '0755' + state: directory + with_items: + - systemd-machined.service.d + - systemd-importd.service.d + + - name: Drop the machined proxy override units + template: + src: systemd-proxy-unit.conf.j2 + dest: /etc/systemd/system/{{ item }}/proxy.conf + owner: root + group: root + mode: '0644' + with_items: + - systemd-machined.service.d + - systemd-importd.service.d + when: lxc_cache_environment.keys() | length > 0 + - include: "lxc_cache_preparation_systemd_{{ (systemd_version.stdout_lines[0].split()[-1] | int > 219) | ternary('new', 'old') }}.yml" - name: Generate apt keys from LXC host for the container cache diff --git a/tasks/lxc_cache_preparation_systemd_new.yml b/tasks/lxc_cache_preparation_systemd_new.yml index fbfcf327..b33f548c 100644 --- a/tasks/lxc_cache_preparation_systemd_new.yml +++ b/tasks/lxc_cache_preparation_systemd_new.yml @@ -15,7 +15,7 @@ # NOTE(cloudnull): When modern SystemD is running everywhere this can be # collapsed back into the base preparation task file. -- name : Remove old image cache +- name: Remove old image cache command: "machinectl remove {{ lxc_container_base_name }}" register: cache_refresh changed_when: cache_refresh.rc == 0 diff --git a/templates/systemd-proxy-unit.conf.j2 b/templates/systemd-proxy-unit.conf.j2 new file mode 100644 index 00000000..6db769df --- /dev/null +++ b/templates/systemd-proxy-unit.conf.j2 @@ -0,0 +1,6 @@ +# {{ ansible_managed }} + +[Service] +{% for key, value in lxc_cache_environment.iteritems() %} +Environment={{ key }}={{ value }} +{% endfor %}