A few misconceptions here:

#1 what you set in the shell: task is not available to other tasks as
they each reconnect to the server and open a new ssh session, they
don't all execute in the same shell process.

#2 ansible_env is not reset every time you run a task, it reflects the
environment from when facts where gathered, it can even reflect a
differnt user when remote_user/become_user are set in different
places.

#3 to set the environment for task execution we have the 'environment'
directive, which can be set at play, block and task levels:

  - hosts: all
    environment:
         ANIMAL: dropbear
    tasks:
         -  shell: env |grep ANIMAL
             register: output
         - debug: var=output


-- 
Brian Coca

-- 
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/CAJ5XC8k%3DMMw-xJJRjh6LtWXggNjgz3bL52Nzz%2BcAzhdDk770oQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to