Ansible을 사용하여 파일을 원격 컴퓨터에 복사할 수 없습니다.

Ansible을 사용하여 파일을 원격 컴퓨터에 복사할 수 없습니다.

원격 시스템의 파일을 대체하여 생성 한 Linux 시스템을 사용 ansible-2.0하고 생성 중이지만 작동하지 않습니다. Ansible 상태 표시 .ansible-galaxydns.yml/etc/resolv.confOK

dns.yml

---
- name: place dns configuration
  become: true
  template:
    src: resolv.conf.j1
    dest: /tmp/resolv.conf

산출:

....
TASK [lab : include ansible related tasks] *************************************
included: /home/adminto/ansible/lab/tasks/dns.yml for pc1

TASK [lab : place dns configuration] *******************************************
ok: [pc1]

PLAY RECAP *********************************************************************
as                         : ok=3    changed=0    unreachable=0    failed=0   

mypc# : ~/ansible$ ansible all -i 'pc1,' -c local -m ping
as | SUCCESS => {
    "changed": false, 
    "ping": "pong"
`enter code here`}

심층 보기 오류:

admin:~/ansible$ sudo ansible-playbook -i "pc1," lab-data.yml -t dns.yml -vvvv
Using /etc/ansible/ansible.cfg as config file
Loaded callback default of type stdout, v2.0
1 plays in lab-push.yml

PLAY ***************************************************************************

TASK [setup] *******************************************************************
<pc1> ESTABLISH SSH CONNECTION FOR USER: None
<pc1> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/adminto/.ansible/cp/ansible-ssh-%h-%p-%r -tt as '( umask 22 && mkdir -p "$( echo $HOME/.ansible/tmp/ansible-tmp-1487592713.4-221225682479967 )" && echo "$( echo $HOME/.ansible/tmp/ansible-tmp-1487592713.4-221225682479967 )" )'
<pc1> PUT /tmp/tmpPNuqMM TO /home/admin/.ansible/tmp/ansible-tmp-1487592713.4-221225682479967/setup
<pc1> SSH: EXEC sftp -b - -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/adminto/.ansible/cp/ansible-ssh-%h-%p-%r '[as]'
<pc1> ESTABLISH SSH CONNECTION FOR USER: None
<pc1> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/adminto/.ansible/cp/ansible-ssh-%h-%p-%r -tt pc1 'LANG=en_IN LC_ALL=en_IN LC_MESSAGES=en_IN /usr/bin/python /home/admin/.ansible/tmp/ansible-tmp-1487592713.4-221225682479967/setup; rm -rf "/home/admin/.ansible/tmp/ansible-tmp-1487592713.4-221225682479967/" > /dev/null 2>&1'
ok: [pc1]

TASK [lab : include ansible related tasks] *************************************
task path: /home/adminto/ansible/lab/tasks/main.yml:1
included: /home/adminto/ansible/lab/tasks/dns.yml for pc1

pc1                         : ok=2    changed=0    unreachable=0    failed=0  

상태가 표시되어 있음에도 불구하고 파일이 복사되지 않는 이유를 아는 사람이 있습니다 ok.

답변1

흠.. 당신이 언급한 질문에서 /etc/resolv.conf당신이 만든 작업은 템플릿을 /tmp/resolv.conf다음과 같이 배포합니다.

---
- name: place dns configuration
  become: true
  template:
    src: resolv.conf.j1
    dest: /etc/resolv.conf

명령을 확인하십시오.sudo ansible-playbook -i "pc1," lab-data.yml -t dns.yml -vvvv

  • -tdns.yml태그를 선택한 후 스크립트 이름처럼 들리므로 태그 이름이 실제로 지정되었는지 확인하세요.

매우 흥미로운 인벤토리 파일 이름입니다.

관련 정보