Hi all,
Am trying to install nvm and PM2 from a playbook and I’ve hit a snag. One of the commands I need to run is to source the pm2 users .profile file. The issue is I don’t seem to be able to do that from ansible (am using 1.9.1, in case that matters):
`
- name: Source nvm profile
command: source /home/pm2/.profile
sudo: yes
sudo_user: pm2
`
Results in:
`
TASK: [Source nvm profile] ****************************************************
failed: [10.17.100.59] => {“cmd”: “source /home/pm2/.profile”, “failed”: true, “rc”: 2}
msg: [Errno 2] No such file or directory
FATAL: all hosts have already failed – aborting
`
I’ve confirmed the /home/pm2/.profile file actually exists, anyone have any ideas how I can accomplish this? TIA!
D
use shell: module,e, source is a built in which you cannot use unless
you invoke it from a shell.
I get a slightly different error now:
TASK: [Source nvm profile] ****************************************************
failed: [10.17.100.59] => {"changed": true, "cmd": "source /home/pm2/.profile", "delta": "0:00:00.001528", "end": "2015-06-19 17:18:58.307304", "rc": 127, "start": "2015-06-19 17:18:58.305776", "warnings": []}
stderr: /bin/sh: 1: source: not found
FATAL: all hosts have already failed -- aborting
source is specifically a BASH builtin, you might want to set your
executable to /bin/bash or make it part of the task, for sh use "."
to source
Awesome, . was what I was after, now onto the next error! Thanks Brian!
D
Hi People,
You have to define the executable path.
- name: for source command
command: source /home/ubuntu/.bash_profile executable=/bin/bash
thx ,it worked!
在 2016年12月12日星期一 UTC+8下午11:11:36,Jitendra Bhalothia写道: