Details
-
Type:
Bug
-
Status: Open (View Workflow)
-
Priority:
Major
-
Resolution: Unresolved
-
Component/s: ansible-plugin
-
Labels:None
-
Similar Issues:
Description
Faild always
Jenkins ver. 2.60.1 under Windows
jenkins agent under linux:
ansible 2.7.0 config file = /etc/ansible/ansible.cfg configured module search path = [u'/etc/ansible/my_modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /usr/bin/ansible python version = 2.7.5 (default, Aug 4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
run from jenkins:
// code placeholder
$ /usr/bin/ansible-playbook /etc/ansible/playbooks/tools/Check_hostname.yml -i host -f 5
PLAY [all] *********************************************************************
TASK [Gathering Facts] ********************************************************
.......
TASK [Comprobando nombre equipo] ***********************************************
.....
PLAY RECAP *********************************************************************
.......
w********p : ok=0 changed=0 unreachable=1 failed=0
FATAL: command execution failedhudson.AbortException: Ansible playbook execution failed at org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder.perform(AnsiblePlaybookBuilder.java:236) at org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder.perform(AnsiblePlaybookBuilder.java:207) at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:735) at hudson.model.Build$BuildExecution.build(Build.java:206) at hudson.model.Build$BuildExecution.doRun(Build.java:163) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:490) at hudson.model.Run.execute(Run.java:1735) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:405)
ERROR: Ansible playbook execution failed
Archiving artifacts
Recording test results
Finished: FAILURE
Run in host:
// code placeholder
$ /usr/bin/ansible-playbook /etc/ansible/playbooks/tools/Check_hostname.yml -i host -f 5
PLAY [all] *********************************************************************
TASK [Gathering Facts] ********************************************************
.......
TASK [Comprobando nombre equipo] ***********************************************
.....
PLAY RECAP *********************************************************************
.......
w********p : ok=0 changed=0 unreachable=1 failed=0
#
Attachments
Attachments
Activity
We are experiencing the same issue as Paulius Bulotas when using the ansible plugin (since the beginning or middle of November too).
At the same time we noticed that the last log lines of the ansible playbook were missing when the playbook was exiting in error state when played on a slave node.
And it is really complicated to understand the playbooks issues without the last log lines.
We found a dirty fix by adding a Thread.Sleep in AnsiblePlaybookBuilder.java, before throwing the exceptions in the perform function.
public void perform(@Nonnull Run<?, ?> run, @Nonnull Node node, @Nonnull FilePath ws, @Nonnull Launcher launcher, @Nonnull TaskListener listener, EnvVars envVars) throws InterruptedException, IOException { try { CLIRunner runner = new CLIRunner(run, ws, launcher, listener); String exe = AnsibleInstallation.getExecutable(ansibleName, AnsibleCommand.ANSIBLE_PLAYBOOK, node, listener, envVars); AnsiblePlaybookInvocation invocation = new AnsiblePlaybookInvocation(exe, run, ws, listener, envVars); invocation.setPlaybook(playbook); invocation.setInventory(inventory); invocation.setLimit(limit); invocation.setTags(tags); invocation.setSkippedTags(skippedTags); invocation.setStartTask(startAtTask); invocation.setBecome(become, becomeUser); invocation.setSudo(sudo, sudoUser); invocation.setForks(forks); invocation.setCredentials(StringUtils.isNotBlank(credentialsId) ? CredentialsProvider.findCredentialById(credentialsId, StandardUsernameCredentials.class, run) : null, copyCredentialsInWorkspace); invocation.setVaultCredentials(StringUtils.isNotBlank(vaultCredentialsId) ? CredentialsProvider.findCredentialById(vaultCredentialsId, StandardCredentials.class, run) : null); invocation.setExtraVars(extraVars); invocation.setAdditionalParameters(additionalParameters); invocation.setDisableHostKeyCheck(disableHostKeyChecking); invocation.setUnbufferedOutput(unbufferedOutput); invocation.setColorizedOutput(colorizedOutput); if (!invocation.execute(runner)) { throw new AbortException("Ansible playbook execution failed"); } } catch (IOException ioe) { Thread.sleep(10000); Util.displayIOException(ioe, listener); ioe.printStackTrace(listener.fatalError(hudson.tasks.Messages.CommandInterpreter_CommandFailed())); throw ioe; } catch (AnsibleInvocationException aie) { Thread.sleep(10000); listener.fatalError(aie.getMessage()); throw new AbortException(aie.getMessage()); } }
Experiencing the same as Paulius Bulotas
Latest Centos 7, running Jenkins 2.138.3, but Ansible 2.4
Another one here, experiencing same issue as Paulius Bulotas and seems to be related to a recent Jenkins update.
I have 2 Jenkins instances, one running v2.138.1 with Ansible Plugin v1.0 which is working fine.
The other running Jenkins v2.1.50.1 and Ansible Plugin v1.0 which shows the same issue as above.
Both tested running the same version of ansible v2.7.2 on same Linux host.
Another one here:
FATAL: command execution failed hudson.AbortException: Ansible playbook execution failed at org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder.perform(AnsiblePlaybookBuilder.java:262) at org.jenkinsci.plugins.ansible.workflow.AnsiblePlaybookStep$AnsiblePlaybookExecution.run(AnsiblePlaybookStep.java:400) at org.jenkinsci.plugins.ansible.workflow.AnsiblePlaybookStep$AnsiblePlaybookExecution.run(AnsiblePlaybookStep.java:321) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47) at hudson.security.ACL.impersonate(ACL.java:290) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
Centos 7.6
Jenkins 2.156
Ansible 2.74
Ansible plugin 1.0
Hello! I have problem too.
I ran playbook with ansible jenkins plugin.
If all tasks are SUCCES, jenkins build is SUCCES too.
BUT if any task is FAILED or UNREACHABLE, i see "hudson.AbortException Ansible playbook execution failed" in console.
Is this error the same that in start topic?
–
piipel
UPD. For some reason, I can't attach screenshot. I uploaded it here https://photos.app.goo.gl/9gXvttYMPaAVxkex8
I have encountered the same issue, and I can confirm that the 'dirty fix' Nicolas MENETRIER mentioned does indeed work. The two additions of thread.sleep in AnsiblePlaybookBuilder.java allow the ansible errors to appear in the output again when the error occurs from a jenkins slave node.
We have this issue (we have RedHat 7 master and slaves). As we use shared libraries we have add a post clean up step to "sh sleep 5". It gives enough time for the log to then be printed before the job terminates. You get the abort, then sleeps 5s (while sleeping error is printed), then exits.
It works but far from ideal
Hi,
We have the same issue.
We are using Jenkins 2.150.3 running on CentOS 6.9 OS.
Ansible plugin version : 1.0
Ansible version: 2.3.2.0
Hello,
We are using Jenkins Version: 2.138.2 running on Ubuntu 16.04
Ansible plugin version: 1.0
Ansible version: 2.7.9
We have the same issue. It appears on different task sporadically.
like once trying to run a bash script with command module and the other time with ansible template module.
- name: Run script
become: yes
shell: ./test_script.sh
args:
chdir: "{{ jenkins_home }}" - name: Create new configuration
become: yes
template: src={{ config_template }}.j2 dest={{ user_home }}/{{ config_template }} backup=yes
Error while running task for template module:
TASK [configure_test_jenkins : Create new configuration] ***********************16:28:10 FATAL: command execution failed*16:28:10* hudson.AbortException: Ansible playbook execution failed*16:28:10* at org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder.perform(AnsiblePlaybookBuilder.java:262)16:28:10 at org.jenkinsci.plugins.ansible.workflow.AnsiblePlaybookStep$AnsiblePlaybookExecution.run(AnsiblePlaybookStep.java:400)16:28:10 at org.jenkinsci.plugins.ansible.workflow.AnsiblePlaybookStep$AnsiblePlaybookExecution.run(AnsiblePlaybookStep.java:321)16:28:10 at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)16:28:10 at hudson.security.ACL.impersonate(ACL.java:290)16:28:10 at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)16:28:10 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)16:28:10 at java.util.concurrent.FutureTask.run(FutureTask.java:266)16:28:10 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)16:28:10 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)16:28:10 at java.lang.Thread.run(Thread.java:748)
We also see this issue.
Ansible Plugin version 1.0
Jenkins Version: 2.164.1
Surprisingly, downgrading the Ansible Plugin to version 0.6.2 didn't even fix the issue.
I'm seeing this as well. Strikes at different places during the playbook execution.
jenkins-2.164
ansible-1.0
I also have this issue
Jenkins ver. 2.153
Ansible plugin 1.0
I got the same issue. The same playbook command can run successfully in command line. But failed in Jenkins.
Jenkins version: 2.164.1
Ansible plugin 1.0
Jean-Christophe Sirot, this is a sev 1 issue, could you please help to investigate this? Thanks.
I got the same issue.
But I found a work around in my case.
I wrote a rescue block in the end of my playbook to ensure that the pipeline continues execution
Then I enabled ansible log in ansible configuration file.
I wrote a python snippet to parse my ansible configuration and create retry file.( based on fail >0)
This way we can ensure that the pipeline execution doesn't stop.
Hi Team,
I have created the job to deploy AKS on Azure using Ansible
Here is my environment details:
Ansible Version: 2.5.1
Jenkins Version: 2.180
once I start the build getting below error:
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Do you have packaging installed? Try `pip install packaging`- No module named packaging.version"}fatal: [localhost]: FAILED! => {"changed": false, "msg": "Do you have packaging installed? Try `pip install packaging`- No module named packaging.version"} to retry, use: --limit @/var/lib/jenkins/workspace/K8s/aks-azure-cni.retry
PLAY RECAP *********************************************************************localhost : ok=1 changed=0 unreachable=0 failed=1
FATAL: command execution failedhudson.AbortException: Ansible playbook execution failed at org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder.perform(AnsiblePlaybookBuilder.java:262) at org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder.perform(AnsiblePlaybookBuilder.java:232) at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:79) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741) at hudson.model.Build$BuildExecution.build(Build.java:206) at hudson.model.Build$BuildExecution.doRun(Build.java:163) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504) at hudson.model.Run.execute(Run.java:1818) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:429)ERROR: Ansible playbook execution failedFinished: FAILURE
Please let me know the changes I have to do.
Thanks & Regards
Shaik.Nagulameera
I also had this error when using the Ansible plugin, but I figured it was due to unreachable errors (since the return code of ansible-playbook is 4 instead of 0 when at least one host is unreachable). Since Ansible 2.7, the keyword
ignore_unreachable = yes
is usable in playbooks / tasks, which results in Ansible returning 0 even if hosts are unreachable. This fixed the issue for me and the Jenkins job continued to execute.
Has there been any update to this? We use other tools for simple Ansible jobs for complex pipelines we need access to basic error handling in Ansible.
I'm experiencing the issue with Ansible plugin 1.0, and my specific issue is Jenkins seeming to error before triggering or completely bypass rescue blocks that otherwise work in CLI
I can add that we are also experiencing such issue with Jenkins master/slave on latest Centos 7, running Jenkins 2.138.3.
Thread dump looks like:
FATAL: command execution failed
hudson.AbortException: Ansible playbook execution failed
at org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder.perform(AnsiblePlaybookBuilder.java:262)
at org.jenkinsci.plugins.ansible.workflow.AnsiblePlaybookStep$AnsiblePlaybookExecution.run(AnsiblePlaybookStep.java:400)
at org.jenkinsci.plugins.ansible.workflow.AnsiblePlaybookStep$AnsiblePlaybookExecution.run(AnsiblePlaybookStep.java:321)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
at hudson.security.ACL.impersonate(ACL.java:290)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
This started happening in middle of November after some plugin update. All runs fail in less than 4 minutes (not sure if it's related to some timeout).
ansible 2.7.2
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/.../.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Jul 13 2018, 13:06:57) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]