我一直尝试playbook.yml
使用 Jenkins 的 Ansible 插件从 Jenkins 运行 Ansible 文件,但它抛出了文件或目录未找到错误。但是,我多次检查路径,它们是正确的。playbook.yml
也存在于适当的路径上。我还验证了 sshpass。它的最新版本安装在 Linux 主节点上。
请注意。我已经正确创建了两台 Linux VM 之间的无密码 ssh 连接。我正在使用该playbook.yml
文件将软件包从主 Linux 节点安装到从属 Linux 节点。我的 Jenkins 安装在 Windows 机器上,我从那里使用 ansible 插件。我还在 Jekins 节点管理上添加了两台 Linux 机器。
这是错误:
Started by user Admin
Running as SYSTEM
[EnvInject] - Loading node environment variables.
Building remotely on Linux_Master_Nodes (Linux_Master_Node) in workspace /data/jenkins/workspace/Invoke_Ansible_Playbook
[Invoke_Ansible_Playbook] $ sshpass ******** /data/ansible/ansible-playbook /data/ansible/playbooks/playbook.yml -f 5 -u root -k
sshpass: Failed to run command: No such file or directory
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.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:744)
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:1816)
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 failed
Finished: FAILURE
答案1
sshpass:无法运行命令:没有此文件或目录
sshpass 无法运行作为参数传递的命令。
您是否检查过 ansible 是否在命令行给出的路径中的 jenkins 从属服务器上正确安装?