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.

Change-Id: Ida3897f2553491913a3183e67b6503bed5281d5e
This commit is contained in:
Jesse Pretorius 2017-03-29 10:58:53 +01:00
parent 67c35f0f89
commit 4af53825b1
2 changed files with 10 additions and 10 deletions

View File

@ -13,8 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Install host 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') }}"

View File

@ -1,10 +1,8 @@
# {{ ansible_managed }}
PATH="{{ openstack_host_environment_path | join(':') }}"
{% if global_environment_variables is defined %}
{% for key, value in global_environment_variables.iteritems() %}
{% if value %}
{% for key, value in global_environment_variables.iteritems() %}
{% if value %}
{{ key }}={{ value }}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}