Configuring proxy using environment variables

From Notes_Wiki

Home > CentOS > CentOS 6.x > System administration tools > ansible > Ansible tips and tricks > Configuring proxy using environment variables

To configure proxy using environment variables, esp for modules such as get_url or yum use:

vars:
  proxy_env:
    http_proxy: http://proxy.virtual-labs.ac.in:8080/
    https_proxy: http://proxy.virtual-labs.ac.in:8080/

Then the same can be referred into various tasks as:

  - name: Download GLPI from Internet
    get_url: url="{{ glpi_download_url }}"  dest="{{ glpi_local_path }}"
    environment: proxy_env

  - name: Install apache, mod_ssl, php, php-ldap, mysql-server, php-mysql, php-mbstring, php-gd 
    yum: name={{ item }} state=present
    with_items:
      - httpd
      - mod_ssl
      - php
      - php-ldap
      - mysql-server
      - php-mysql
      - php-mbstring
      - php-gd
      - MySQL-python
    environment: proxy_env
    notify:
      - restart apache



Home > CentOS > CentOS 6.x > System administration tools > ansible > Ansible tips and tricks > Configuring proxy using environment variables