Ansible plugin problem in pipeline code

2,363 views
Skip to first unread message

Guy Knights

unread,
Nov 28, 2016, 2:42:10 PM11/28/16
to jenkins...@googlegroups.com
I'm trying to use the ansible plugin in a pipeline script, but it fails to find ansible-playbook. I've used the "ansibleName" parameter to supply the name of the Ansible version I want to use from Jenkins' global tool config page, but it still fails. I get the following when trying to execute a playbook from a pipeline:

[workspace] $ ansible-playbook /opt/ansible-data/playbooks/client_deploy.yml -i /opt/ansible-data/inventory/prod/ -f 5 --private-key "/var/jenkins_home/jobs/Default/jobs/Client deploy/workspace/ssh7766033036773514652.key" -u ubuntu -e wl_name=default -e client_version=761c6f24
FATAL: command execution failed
java.io.IOException: Cannot run program "ansible-playbook" (in directory "/var/jenkins_home/jobs/Default/jobs/Client deploy/workspace"): error=2, No such file or directory

The path to the ansible binaries has been defined in the global config page as /opt/ansible/ansible-2.2/bin, and this works for normal jenkins (ie. not pipeline) jobs, using the "Invoke Ansible playbook" build task.

The ansible call from my Jenkinsfile is as follows:

ansiblePlaybook(
        ansibleName: 'stable-2.2',
        playbook: "${ANSIBLE_DATA_PATH}/playbooks/client_deploy.yml",
        inventory: "${ANSIBLE_DATA_PATH}/inventory/${ENVIRONMENT}/",
        credentialsId: '574fb47c-33df-4096-bd0c-0c44962b2546',
        extraVars: [
            wl_name: "${wlName}",
            client_version: "${gtpCommitId}"
        ],
        additionalParameters: '--vault-password-file "/var/jenkins_home/.ansible/vault.pwd" --forks=10',
        colorized: true

"stable-2.2" is the name I've given to the version of Ansible defined on the global tools config page.

Does anyone know why this isn't working?

Thanks,
Guy

jcsirot

unread,
Nov 29, 2016, 11:35:18 AM11/29/16
to Jenkins Users
Hello Guy,

Do not hesitate to open a JIRA ticket with the ansible-plugin component:


I'm going to look at this issue to understand what's going on.

-- 
Jean-Christophe

Yiyito

unread,
Jun 23, 2020, 11:15:57 AM6/23/20
to Jenkins Users
Was this solved? I´m having same issue

Kiran Kumar

unread,
Mar 8, 2021, 12:55:43 AM3/8/21
to Jenkins Users
same issue for me too

Kiran Kumar

unread,
Mar 8, 2021, 12:58:51 AM3/8/21
to Jenkins Users
[Create-VM-Paramater-new] $ ansible-playbook /etc/ansible/playbooks/vm-provision/vm-create-paramater.yml -f 5 --extra-vars "vm_name=..."
FATAL: command execution failed
java.io.IOException: Cannot run program "ansible-playbook" (in directory "/var/lib/jenkins/workspace/Create-VM-Paramater-new"): error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at hudson.Proc$LocalProc.<init>(Proc.java:252)
    at hudson.Proc$LocalProc.<init>(Proc.java:221)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:996)
    at hudson.Launcher$ProcStarter.start(Launcher.java:508)
    at hudson.Launcher$ProcStarter.join(Launcher.java:519)
    at org.jenkinsci.plugins.ansible.CLIRunner.execute(CLIRunner.java:49)






ansible 2.10.6
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
Reply all
Reply to author
Forward
0 new messages