Global environment variables

I have installed some software into /usr/local/bin on a server. I want to reference use them without passing environment to every task or playbook.

`

- command: foo
  environment:

PATH: ‘/usr/local/bin:{{ ansible_env.PATH }}’

`

I have tried updating /etc/profile, /etc/environment, but Ansible does not load them. It only displays this when I dump echo $PATH.

`

ok: [fizz.buzz.com] => {

“changed”: false,

“test”: {

“changed”: true,

“cmd”: “echo $PATH”,

“delta”: “0:00:00.002801”,

“end”: “2017-05-30 13:04:44.151947”,

“rc”: 0,

“start”: “2017-05-30 13:04:44.149146”,

“stderr”: “”,

“stderr_lines”: ,

“stdout”: “/sbin:/bin:/usr/sbin:/usr/bin”,

“stdout_lines”: [

“/sbin:/bin:/usr/sbin:/usr/bin”

]

}

}

`

Is there any way I can make it load them automatically? I don’t really want to install into /bin because of the possibility of package managers overwriting software.

Thanks

Use the shell module instead of the command module. This will give you a valid shell environment (incl. /etc/profile, /etc/environment etc.)