QT-DevOps / DevOpsIssues

This Repo will be used to demonstrate the Skills & Questions in DevOps
Apache License 2.0
27 stars 130 forks source link

trying to execute ansible-playbook from jenkins(ansible plugin) getting ssh connection issue #978

Open gogondi1 opened 3 years ago

gogondi1 commented 3 years ago

Ansible is installed and able to execute playbook successfully, However trying to build a free style project from jenkins getting below errors, I have used ansible plugin and while build launched invoke ansible play book and given all options

s1 sn2 sn3

Checking out Revision 92e13eef1c84343b47cd3565330005a1077c5000 (refs/remotes/origin/master)

git config core.sparsecheckout # timeout=10 git checkout -f 92e13eef1c84343b47cd3565330005a1077c5000 # timeout=10 Commit message: "updated inventory" git rev-list --no-walk 92e13eef1c84343b47cd3565330005a1077c5000 # timeout=10 [ansible-project] $ /usr/bin/ansible-playbook book1.yml -i inventory -f 5 --private-key /tmp/ssh7537388195384154296.key -u devops

PLAY [all] *****

TASK [Gathering Facts] ***** fatal: [52.15.115.38]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Host key verification failed.", "unreachable": true} fatal: [3.138.124.64]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Host key verification failed.", "unreachable": true}

PLAY RECAP ***** 3.138.124.64 : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0
52.15.115.38 : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0

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 jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123) at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:80) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:804) at hudson.model.Build$BuildExecution.build(Build.java:197) at hudson.model.Build$BuildExecution.doRun(Build.java:163) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:514) at hudson.model.Run.execute(Run.java:1907) 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 REST API

gogondi1 commented 3 years ago

same playbook is executing fine on ansible server

sn4

santhoshd402 commented 3 years ago

Hi,

please try to run playbook in ACS(ansible control server) ex : you have to add ACS to jenkins as node and try to run that play book on ACS

If it not resolved cal me @7893532934.. we will solve it in remote

gogondi1 commented 3 years ago

Hello Santosh, you mean to say, Jenkins master and ansible control server should not exist on same server. In my scenario i used same machine as Jenkins master and ansible control server and trying to execute ansible-playbook.

I will try to execute your solution also, could you please share me your whatsapp number

gogondi1 commented 3 years ago

Hello Santosh,

your solution worked for me, may i know why job is failing, when we have both Jenkins server and ansible control server both on one system

bhaskardegala commented 3 years ago

Hi jenkins uses jenkins user and you shared keys with ansible user so this might be the cause

On Sun, 13 Dec, 2020, 3:34 AM gogondi1, notifications@github.com wrote:

Hello Santosh,

your solution worked for me, may i know why job is failing, when we have both Jenkins server and ansible control server both on one system

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/QT-DevOps/DevOpsIssues/issues/978#issuecomment-743911689, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALT4PAB2KYAOBXF2G5MROJTSUPSH5ANCNFSM4UXVDCDQ .

santhoshd402 commented 3 years ago

Hi,

If it not resolved cal me @7893532934.. we will solve it in remote.