Ansible plugin problem in pipeline code

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Ansible plugin problem in pipeline code

Guy Knights
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

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CANNH9mtaJBJjRzh0GgEd7o6K36QnFDdt2UccozP92S6urb6BTw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Ansible plugin problem in pipeline code

jcsirot
Hello Guy,

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

https://issues.jenkins-ci.org/issues/?jql=project%20%3D%20JENKINS%20AND%20component%20%3D%20ansible-plugin

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

-- 
Jean-Christophe

Le lundi 28 novembre 2016 20:42:10 UTC+1, Guy Knights a écrit :
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

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/ca90ac96-201d-4877-97ae-14a80b05226e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Ansible plugin problem in pipeline code

Yiyito
In reply to this post by Guy Knights
Was this solved? I´m having same issue

On Monday, November 28, 2016 at 4:42:10 PM UTC-3, Guy Knights wrote:
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

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/7e448011-02bd-412e-847b-8997349962a5o%40googlegroups.com.