Sorry I misread your second question. To answer it properly, I’m fairly
certain that you will get the same behaviour with the shell module as you
would running a script from an interactive shell, so sourcing scripts and
exporting from a sourced script will work just fine.

With the correct playbook yaml structure, your first example should work
just fine - building a dictionary of environment variables then passing it
to each task with the environment: keyword.

In your example, I’m not sure where $APP is being set, but you can define
variables using other variables in this manner.

- hosts: somegroup
  vars:
    apps: something
    myenv:
      ACE: "{{ apps }}/default-ace/ACE"
      PIN="{{ apps }}/default-ace/PIN"
      APPETIZER="{{ apps }}/default-ace/APPETIZER"
  tasks:
    - shell: /path/to/script
      environment: myenv
    - shell: /path/to/other/script
      environment: myenv

Other approaches could be to build your environment variables based on
group variables or role variables. This makes sense if you are targeting
multiple host groups like the example in your first message.

On 16 January 2015 at 16:16, Adrian Paraschiv <
[email protected]> wrote:

Hello,
>
> I know ansible does not carry env variables from one shell to another but
> can I use the "environment:" syntax in every shell I need ? Also does
> "environment:" links to "vars:" written like this ? I'm assking this
> because I need to run about 20 shell comands that all need about 30-40
> environment variables - some of these are like this:
>
> export ACE="$APPS/default-ace/ACE"
> export PIN="$APPS/default-ace/PIN"
> export APPETIZER="$APPS/default-ace/APPETIZER"
>
> not only static stuff
> and I don't know how to make it work.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/7d346bb9-4bcd-4656-9bf5-1a439d772432%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/7d346bb9-4bcd-4656-9bf5-1a439d772432%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
​

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAAnNz0OKmFjHukBnS-DfWjKswrAn_pCT253P8QTL82kmu-TN%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to