Hi All,

I need to set some environment variable for all the user who is executing 
the ansible script. Currently I am doing something like this in the 
playbook:

- hosts: all
  task: 

  - name: get path 
    shell: which R
    register: r_path

  - name: create file in /etc/profile.d
    shell: touch /etc/profile.d/rpath.sh
    sudo: yes
    args:
      creates: /etc/profile.d/rpath.sh

  - name: create environment variable and paste in file
    shell: echo "export RHOME={{ r_path.stdout }}" > /etc/profile.d/rpath.sh

  - name: reload profile
    shell: source /etc/profile

When I run this playbook, it works fine on RHEL machine. But it fails on 
Ubuntu machine. The reason being, on ubuntu source command is not present. 

So what I was wondering is, can this be done in a better way? Or is there a 
better way to reload the profile on ubuntu ?

Also another question: When we have a playbook with multiple task, does 
ansible execute all the task as if it were a single session? or Each new 
task is a separate session with the host?

The reason I am asking is because, in my ansible script, once I have set 
the environment variable, I would like to use that in the next task. 

Thanks

-- 
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/a5ac7136-ac1f-41cc-85b1-ab85e02c2aca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to