ansible-maven-plugin icon indicating copy to clipboard operation
ansible-maven-plugin copied to clipboard

java.io.IOException: error=2, No such file or directory while using ansible from pip installation

Open Nereis opened this issue 10 years ago • 2 comments

While running ansible from jenkins with ansible installed with pip, I get the next stacktrace

[INFO] --- ansible-maven-plugin:1.1.2:playbook (ansible-playbook-env-deploy) @ project-name ---
[INFO] Command: [ansible-playbook, -i, /opt/jenkins/jenkins-work/workspace/[...]/inventory_jenkins, /opt/jenkins/jenkins-work/workspace/[...]/deploy_env.yml]

[ERROR] Failed to execute goal co.escapeideas.maven:ansible-maven-plugin:1.1.2:playbook (ansible-playbook-env-deploy) on project project-name: Unable to run playbook: Cannot run program "ansible-playbook" (in directory "/tmp"): error=2, No such file or directory -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal co.escapeideas.maven:ansible-maven-plugin:1.1.2:playbook (ansible-playbook-env-deploy) on project project-name: Unable to run playbook
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
    at org.jvnet.hudson.maven3.launcher.Maven31Launcher.main(Maven31Launcher.java:132)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)
    at jenkins.maven3.agent.Maven31Main.launch(Maven31Main.java:181)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:134)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:69)
    at hudson.remoting.UserRequest.perform(UserRequest.java:118)
    at hudson.remoting.UserRequest.perform(UserRequest.java:48)
    at hudson.remoting.Request$2.run(Request.java:328)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to run playbook
    at co.escapeideas.maven.ansible.AbstractAnsibleMojo.execute(AbstractAnsibleMojo.java:137)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 30 more
Caused by: java.io.IOException: Cannot run program "ansible-playbook" (in directory "/tmp"): error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
    at co.escapeideas.maven.ansible.AbstractAnsibleMojo.execute(AbstractAnsibleMojo.java:168)
    at co.escapeideas.maven.ansible.AbstractAnsibleMojo.execute(AbstractAnsibleMojo.java:132)
    ... 32 more
Caused by: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:186)
    at java.lang.ProcessImpl.start(ProcessImpl.java:130)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1028)
    ... 34 more

Everything is working fine when I use the debian packet manager to install ansible with the exact same configuration (I checked the logged command which is also the same). Ansible is working while running it from ssh with jenkins user and pip install.

Version: ansible 1.7.2 pip + apt-get, 1.8.2 pip maven 3.2.3 jenkins 1.553 debian 7

Nereis avatar Jan 19 '15 10:01 Nereis

"No such file or directory" can indicate that the ansible command is not available on the PATH.
Are you able to check the PATH is updated correctly when using pip?

It's also possible to specify the full path to the ansible executable using the executable configuration parameter

tmullender avatar Jan 19 '15 17:01 tmullender

HI,

I have the same problem with Ansible installed with pip, but i'm using Ansible plugin for Jenkins, in jenkins Configuration Page, i set the correct Path to ansible executables directory in slave machine,

but both steps : "Invoke Ansible Ad-hoc command" and "Invoke Ansible Playbook" reports the same error, and no more details in the console even when i add verbosity option -vvvv

Any idea ?? thx

Ansible 1.9.1 Red Hat Enterprise Linux Server release 6.6 (Santiago) Jenkins plugin : 0.3.1

logs

FATAL: Ansible executable not found, check your installation. Build step 'Invoke Ansible Ad-Hoc Command' marked build as failure FATAL: Ansible executable not found, check your installation. Build step 'Invoke Ansible Playbook' marked build as failure Finished: FAILURE

atiyou avatar Aug 14 '15 16:08 atiyou