해결된 질문
작성
·
613
·
수정됨
0
windows 에서 docker를 설치 해서 실습중입니다.
세션4.Ansible playbook으로 Kubernetes Script 실행하기에서 막혀서 질문을 남깁니다.
ansible에서 windows로 ping 하는 것은 성공했는데 ansible-playbook을 실행하는것은 되지 않습니다.
제가 설정을 잘못 한게 있을까요?
windows ping 설정
[root@7a7d20fbb691 ~]# ansible windows -m win_ping
192.168.0.100 | SUCCESS => {
"changed": false,
"ping": "pong"
}
2. k8s-cicd-deployment-playbook.yml
command를 win_command로 변경
[root@7a7d20fbb691 ~]# cat k8s-cicd-deployment-playbook.yml
- name: Create pods using deployment
hosts: kubernetes
# become: true
# user: ubuntu
tasks:
- name: delete the previous deployment
win_command: kubectl delete deployment.apps/cicd-deployment
- name: create a deployment
win_command: kubectl apply -f cicd-devops-deployment.yml
ansible-playbook 실행
[root@7a7d20fbb691 ~]# ansible-playbook -i ./k8s/hosts k8s-cicd-deployment-playbook.yml -u lsh
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
PLAY [Create pods using deployment] **************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************
fatal: [www.iptime.org]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: lsh@www.iptime.org: Permission denied (publickey,password,keyboard-interactive).", "unreachable": true}
PLAY RECAP ***************************************************************************************************************************
www.iptime.org : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0
[root@7a7d20fbb691 ~]# ansible-playbook -i ./k8s/hosts k8s-cicd-deployment-playbook.yml
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
PLAY [Create pods using deployment] **************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************
fatal: [www.iptime.org]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: root@www.iptime.org: Permission denied (publickey,password,keyboard-interactive).", "unreachable": true}
PLAY RECAP ***************************************************************************************************************************
www.iptime.org : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0
4. /etc/ansible/hosts
[devops]
172.17.0.3
172.17.0.4
[windows]
192.168.0.100
[windows:vars]
ansible_password='xxxx'
ansible_connection=winrm
ansible_winrm_server_cert_validation=ignore
ansible_user=lsh
ansible_port=5986
답변 1
0
안녕하세요, 이도원입니다.
ansible에서 ping을 실행하신 대상은 hosts 파일에 있는 windows 로 보여지는데, playbook yaml 파일에서 실행하고 있는 hosts의 대상이 kubernetes로 되어 있는 것 같습니다. 강의에서는 kubernetes를 hosts 파일에 등록하고 사용하고 있습니다. 말씀하신 windows로 실행하실거면 yaml 파일의 hosts 부분을 windows로 변경해 보시기 바랍니다.
감사합니다.
강사님 질문에 힌트를 얻어
k8s-cicd-deployment-playbook.yml의 hosts를 windows로 변경하고
ansible-server에서 window의 쿠버네티스를 실행하는 스크립트를
[root@ansible-server]# ansible-playbook -i /etc/ansible/hosts k8s-cicd-deployment-playbook.yml
이렇게 실행 했더니 실행 되었습니다.