mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.7 KiB
ReStructuredText
61 lines
1.7 KiB
ReStructuredText
12 years ago
|
Setting the Environment (and Working With Proxies)
|
||
11 years ago
|
==================================================
|
||
12 years ago
|
|
||
11 years ago
|
.. contents::
|
||
|
:depth: 2
|
||
|
|
||
11 years ago
|
.. versionadded:: 1.1
|
||
12 years ago
|
|
||
|
It is quite possible that you may need to get package updates through a proxy, or even get some package
|
||
11 years ago
|
updates through a proxy and access other packages not through a proxy. Or maybe a script you might wish to
|
||
|
call may also need certain environment variables set to run properly.
|
||
11 years ago
|
|
||
|
Ansible makes it easy for you to configure your environment by using the 'environment' keyword. Here is an example::
|
||
12 years ago
|
|
||
12 years ago
|
- hosts: all
|
||
11 years ago
|
remote_user: root
|
||
12 years ago
|
|
||
12 years ago
|
tasks:
|
||
12 years ago
|
|
||
12 years ago
|
- apt: name=cobbler state=installed
|
||
|
environment:
|
||
|
http_proxy: http://proxy.example.com:8080
|
||
12 years ago
|
|
||
|
The environment can also be stored in a variable, and accessed like so::
|
||
|
|
||
12 years ago
|
- hosts: all
|
||
11 years ago
|
remote_user: root
|
||
12 years ago
|
|
||
12 years ago
|
# here we make a variable named "env" that is a dictionary
|
||
|
vars:
|
||
|
proxy_env:
|
||
12 years ago
|
http_proxy: http://proxy.example.com:8080
|
||
12 years ago
|
|
||
12 years ago
|
tasks:
|
||
12 years ago
|
|
||
12 years ago
|
- apt: name=cobbler state=installed
|
||
11 years ago
|
environment: proxy_env
|
||
12 years ago
|
|
||
12 years ago
|
While just proxy settings were shown above, any number of settings can be supplied. The most logical place
|
||
|
to define an environment hash might be a group_vars file, like so::
|
||
12 years ago
|
|
||
12 years ago
|
---
|
||
12 years ago
|
# file: group_vars/boston
|
||
|
|
||
|
ntp_server: ntp.bos.example.com
|
||
|
backup: bak.bos.example.com
|
||
|
proxy_env:
|
||
12 years ago
|
http_proxy: http://proxy.bos.example.com:8080
|
||
|
https_proxy: http://proxy.bos.example.com:8080
|
||
12 years ago
|
|
||
11 years ago
|
.. seealso::
|
||
|
|
||
|
:doc:`playbooks`
|
||
|
An introduction to playbooks
|
||
|
`User Mailing List <http://groups.google.com/group/ansible-devel>`_
|
||
|
Have a question? Stop by the google group!
|
||
|
`irc.freenode.net <http://irc.freenode.net>`_
|
||
|
#ansible IRC chat channel
|
||
|
|
||
|
|