Update instead of replacing the environment file
Currently the entire environment file is replaced, which may remove any existing configuration on the hosts including any pre-existing proxy configurations and anything else the deployer may have put there. This method replaces it with an additive process which respects pre-existing content, but still allows the global_environment_variables variable changes to be fully reflected in the resulting environment file. As the PATH setting in the previous template was the default path which will already be present in the container, that has been removed from the template. Change-Id: I930f1711fbd56d2c97e8c80bd990350fa0c7ba73
This commit is contained in:
parent
eeabfbc042
commit
fb362ccc74
|
@ -417,14 +417,14 @@
|
|||
tags:
|
||||
- lxc_container_create-networks
|
||||
|
||||
- name: Install container proxy settings
|
||||
template:
|
||||
- name: Add global_environment_variables to environment file
|
||||
blockinfile:
|
||||
dest: "/etc/environment"
|
||||
src: "environment.j2"
|
||||
mode: "0644"
|
||||
state: present
|
||||
marker: "# {mark} Managed by OpenStack-Ansible"
|
||||
insertbefore: EOF
|
||||
block: "{{ lookup('template', 'environment.j2') }}"
|
||||
remote_user: root
|
||||
when:
|
||||
- global_environment_variables is defined
|
||||
tags:
|
||||
- lxc_container_create-proxy
|
||||
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
# {{ ansible_managed }}
|
||||
|
||||
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
|
||||
{% if global_environment_variables %}
|
||||
{% for key, value in global_environment_variables.iteritems() %}
|
||||
{% if value %}
|
||||
{% if global_environment_variables is defined %}
|
||||
{% for key, value in global_environment_variables.iteritems() %}
|
||||
{% if value %}
|
||||
{{ key }}={{ value }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
|
@ -32,4 +32,4 @@ properties:
|
|||
service_name: "{{ inventory_hostname }}"
|
||||
|
||||
global_environment_variables:
|
||||
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
foo: "bar"
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
- name: Check /etc/enviroment matches expectations
|
||||
assert:
|
||||
that:
|
||||
- "'/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games' in environment_content"
|
||||
- "'foo=bar' in environment_content"
|
||||
- name: Test connectivity to external address
|
||||
shell: ping -c 3 8.8.8.8
|
||||
register: ping_external_address
|
||||
|
|
Loading…
Reference in New Issue