Ansible and make all command

Hi there…

I’m trying with a playbook in where i have to do a “make all”. The problem here is that after 5 or 6 minutes running, it finishes with error:

“FATAL: all hosts have already failed – aborting”

But there’s not compile error or something like that. If I run this “make all” from command line, it finishes normally with $? = 0.

Could be a “Ansible TO”

Always finishes at the same point.

Hope you could help me :slight_smile:

Regards.!
Fede

Federico Aguirre

More about…

This is the error…

failed: [server] => (item=/usr/bin/make) => {“changed”: true, “cmd”: “cd /home/user/platform ; /usr/bin/make”, “delta”: “0:05:34.773058”, “end”: “2014-10-23 20:13:10.664475”, “item”: “/usr/bin/make”, “rc”: 2, “start”: “2014-10-23 20:07:35.891417”}
stderr: Checking for program g++ or c++ : /usr/bin/g++

ani suggestion?

Thanks,
Fede

Are you relying on .bashrc to load the environment for the user you are using to SSH with? There seems to be an environment difference from when Ansible does SSH to execute the command versus what you are doing locally. Try doing a debug by registering the command which g++

  • name: Check location of program
    command: which g++
    register: result
  • debug: var=result

Is this doing a sudo? sudo command will not source the .bashrc automatically.

I worked around it in my system with

  • name: run script
    shell: cd; bash -lc “script.sh > script.log 2>&1”

This forces the .bashrc to be loaded. I had LD_LIBRARY_PATH defined in my .bashrc that I needed to be loaded when executing the script. I know there are a dozen other ways probably could have been done, but due to legacy install reasons with my product, I was stuck with these ENV settings being in .bashrc, and I was not interested in trying to pull those ENV values over into my playbooks to prepend to the shell command.

May not be your issue, but I suspect a similar problem as it looks like make is looking for g++ / c++ and not finding it.

Lastly, I have ran into issues with TTY due to nested SSH and redirections, that is another area to check out when trying to execute applications remotely, that they behave when the TTY is / is not present. Doubt this is the case with make, but thought I would throw it out there in case it sprung a lightbulb.

Thanks!
Michael

This failed because you have a command returning “rc”:2.

It did not time out.

“There seems to be an environment difference from when Ansible does SSH to execute the command versus what you are doing locally”

Ansible does not load the remote environment intentionally. See http://docs.ansible.com/playbooks_environment.html if you need to set enviroment variables.

Since you got six minutes in, it seems like it was compiling for six minutes and that’s ok.

Now, it would be preferred to do your compiling on your build system, package something, and then just download the packages with your package manager - compiling on individual machines is a deployment practice most people seek to avoid.