Welcome to mirror list, hosted at ThFree Co, Russian Federation.

environment.yml « language_features - github.com/ansible/ansible-examples.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: af686362d20fd6ab9a5bfb12602bad00fe0eb656 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
---

# it is often useful to be able to set the environment for one command and have that environment be totally
# different for another.  An example is you might use a HTTP proxy for some packages but not for others.
#
# in Ansible 1.1 and later, you can pass the environment to any module using either a dictionary variable
# or a dictionary itself.


- hosts: all
  remote_user: root

  # here we make a variable named "env" that is a dictionary
  vars:
    env:
       HI: test2
       http_proxy: http://proxy.example.com:8080

  tasks:

    # here we just define the dictionary directly and use it
    # (here $HI is the shell variable as nothing in Ansible will replace it)

    - shell: echo $HI
      environment:
         HI: test1

    # here we are using the "env" map variable above

    - shell: echo $HI
      environment: "{{ env }}"