-1

I am running an Ansible master machine with a shell script which clones my repo to my local git server. I am cloning from Perforce and hence using git-p4 module for the same.

#!/bin/bash

p4port=myport
p4user=myuser
p4repourl=myurl
p4path=/usr/local/bin/p4
p4passwd=mypass
clone_dest=/root/mycode
gitp4=/usr/local/bin/git-p4

export P4PORT=$p4port
export P4USER=$p4user
$p4path trust -y
echo $p4passwd|$p4path login
echo "now using git-p4 to clone repo.."
python $gitp4 clone -v $p4repourl $clone_dest

My target machine has RHEL 7 and if I execute this shell script on the target machine it works fine. However, if I run this from my Ansible master using the command module it throws the following error:

 ['git', 'config', 'git-p4.client']\nOpening pipe: ['p4', '-G', 'files', 'mydepot/...#head']\nTraceback (most recent call last):\n  File \"/usr/local/bin/git-p4\", line 3657, in <module>\n    main()\n  File \"/usr/local/bin/git-p4\", line 3651, in main\n    if not cmd.run(args):\n  File \"/usr/local/bin/git-p4\", line 3525, in run\n    if not P4Sync.run(self, depotPaths):\n  File \"/usr/local/bin/git-p4\", line 3330, in run\n    self.importHeadRevision(revision)\n  File \"/usr/local/bin/git-p4\", line 3079, in importHeadRevision\n    for info in p4CmdList([\"files\"] + fileArgs):\n  File \"/usr/local/bin/git-p4\", line 495, in p4CmdList\n    stdout=subprocess.PIPE)\n  File \"/usr/lib64/python2.7/subprocess.py\", line 711, in __init__\n    errread, errwrite)\n  File \"/usr/lib64/python2.7/subprocess.py\", line 1308, in _execute_child\n    raise child_exception\nOSError: [Errno 2] No such file or directory", "stdout": 
ydaetskcoR
  • 53,225
  • 8
  • 158
  • 177
Gaurav S
  • 121
  • 15

1 Answers1

0

Your PATH isn't set correctly while under ansible, so git-p4 can't find p4.

Also I suggest replacing \n with newlines in your error message to make it easier to understand.

Douglas Leeder
  • 52,368
  • 9
  • 94
  • 137