문제점
리눅스 console에서는 정상 출력되나 jenkins를 통한 ansible 명령 수행시 아래와 같은 에러가 나온다.
Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this. Please add this host's fingerprint to your known_hosts file to manage this host.
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/linux_ping
[linux_ping] $ sshpass ******** /usr/bin/ansible-playbook /home/jenkins/cent_ping.yml -i /home/jenkins/hosts -f 5 -u tempuser -k
PLAY [linux] *******************************************************************
TASK [Gathering Facts] *********************************************************
fatal: [x.x.x.x]: FAILED! => {"msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this. Please add this host's fingerprint to your known_hosts file to manage this host."}
fatal: [x.x.x.x]: FAILED! => {"msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this. Please add this host's fingerprint to your known_hosts file to manage this host."}
PLAY RECAP *********************************************************************
x.x.x.x : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
x.x.x.x : ok=0 changed=0 unreachable=0 failed=1 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:79)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:814)
at hudson.model.Build$BuildExecution.build(Build.java:199)
at hudson.model.Build$BuildExecution.doRun(Build.java:164)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:522)
at hudson.model.Run.execute(Run.java:1896)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
at hudson.model.ResourceController.execute(ResourceController.java:101)
at hudson.model.Executor.run(Executor.java:442)
ERROR: Ansible playbook execution failed
Finished: FAILURE
해결방법
/etc/ansible/ansible.cfg을 열어서 아래 값을 넣는다.(수정하고 다시 실행하면 정상 동작 됨)
host_key_checking = False
아래결과(아이피는 지움)
반응형
'인프라 > 앤서블(Ansible)' 카테고리의 다른 글
리눅스 linux playbook 예제 (0) | 2022.05.16 |
---|---|
ansible command "python setup.py egg_info" failed with error code 1 (0) | 2022.05.12 |
ansible 에러 Failed to connect to the host via ssh: Permission denied (0) | 2022.05.03 |
ansible awx 구축(cenot7 k8s) (0) | 2022.05.02 |
ansible awx windows playbook example (0) | 2022.05.02 |
댓글