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
This commit is contained in:
Logan V 2017-04-21 16:17:36 -05:00
parent 3b002a799e
commit 89625e66b0
3 changed files with 31 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,6 @@
# {{ ansible_managed }}
[Service]
{% for key, value in lxc_cache_environment.iteritems() %}
Environment={{ key }}={{ value }}
{% endfor %}