From 89625e66b0bbf7abfbd31b162296a98ab173ce74 Mon Sep 17 00:00:00 2001 From: Logan V Date: Fri, 21 Apr 2017 16:17:36 -0500 Subject: [PATCH] Configure proxy settings for machined The machined pull does not utilize the lxc_cache_environment variable to configure its environment, so it will not use proxies. This fixes machined to properly configure its environment so pulls can operate through proxies. Based on https://wbl.krm.io/howto-proxify-systemd-machined/ Change-Id: I17c452a8ba67561435737ee9d672219a2e306489 --- tasks/lxc_cache_preparation.yml | 24 +++++++++++++++++++++ tasks/lxc_cache_preparation_systemd_new.yml | 2 +- templates/systemd-proxy-unit.conf.j2 | 6 ++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 templates/systemd-proxy-unit.conf.j2 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 %}