Handle proxies through environment variables

When running os-ansible-deployment on a cluster siting behind a proxy,
users may need to set up special variables for proxies so that pip, and
the services all work as expected.

Closes-bug: 1452456
Change-Id: I2a397abad6557a48bc737dcd9cca787fc5afa728
This commit is contained in:
Ian Cordasco 2015-05-08 16:47:27 -05:00
parent 56b84f0e34
commit ed7f78ea56
4 changed files with 50 additions and 0 deletions

View File

@ -61,6 +61,7 @@ ssl_cipher_suite: "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AE
# - horizon_ssl_protocol # - horizon_ssl_protocol
# - horizon_ssl_cipher_suite # - horizon_ssl_cipher_suite
## Additional pinning generator that will allow for more packages to be pinned as you see fit. ## Additional pinning generator that will allow for more packages to be pinned as you see fit.
## All pins allow for package and versions to be defined. Be careful using this as versions ## All pins allow for package and versions to be defined. Be careful using this as versions
## are always subject to change and updates regarding security will become your problem from this ## are always subject to change and updates regarding security will become your problem from this
@ -71,3 +72,19 @@ ssl_cipher_suite: "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AE
# - { package: "libvirt-bin", version: "1.2.2-0ubuntu13.1.9" } # - { package: "libvirt-bin", version: "1.2.2-0ubuntu13.1.9" }
# - { package: "rabbitmq-server", origin: "www.rabbitmq.com" } # - { package: "rabbitmq-server", origin: "www.rabbitmq.com" }
# - { package: "*", release: "MariaDB" } # - { package: "*", release: "MariaDB" }
## Environment variable settings
# This allows users to specify the additional environment variables to be set
# which is useful in setting where you working behind a proxy. If working behind
# a proxy It's important to always specify the scheme as "http://". This is what
# the underlying python libraries will handle best. This proxy information will be
# placed both on the hosts and inside the containers.
## Example environment variable setup:
# proxy_env_url: http://username:pa$$w0rd@10.10.10.9:9000/
# no_proxy_env: "localhost,127.0.0.1,{% for host in groups['all_containers'] %}{{ hostvars[host]['container_address'] }}{% if not loop.last %},{% endif %}{% endfor %}"
# global_environment_variables:
# HTTP_PROXY: "{{ proxy_env_url }}"
# HTTPS_PROXY: "{{ proxy_env_url }}"
# NO_PROXY: "{{ no_proxy_env }}"

View File

@ -62,6 +62,15 @@
vg_name: "{{ properties.container_vg_name|default(lxc_container_vg_name) }}" vg_name: "{{ properties.container_vg_name|default(lxc_container_vg_name) }}"
template_options: "{{ lxc_container_template_options }}" template_options: "{{ lxc_container_template_options }}"
container_command: | container_command: |
{% if global_environment_variables is defined %}
{%- for name, value in global_environment_variables.items() %}
{% if value %}
if ! grep '{{ name }}={{ value }}' /etc/environment;
echo '{{ name }}={{ value }}' | tee -a /etc/environment
fi
{% endif %}
{%- endfor %}
{% endif %}
mkdir -p ~/.ssh/ mkdir -p ~/.ssh/
if [ ! -f "~/.ssh/authorized_keys" ];then if [ ! -f "~/.ssh/authorized_keys" ];then
touch ~/.ssh/authorized_keys touch ~/.ssh/authorized_keys

View File

@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
- include: openstack_proxy_settings.yml
- include: openstack_host_packages.yml - include: openstack_host_packages.yml
- include: openstack_sysstat.yml - include: openstack_sysstat.yml
- include: openstack_update_hosts_file.yml - include: openstack_update_hosts_file.yml

View File

@ -0,0 +1,23 @@
---
# Copyright 2015, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Install host proxy settings
lineinfile:
dest: /etc/environment
state: present
line: "{% if item.value %}{{ item.key }}={{ item.value }}{% endif %}"
with_dict: global_environment_variables |default({})
tags:
- openstack-host-proxies