playbook을 사용하여 파일 복사

2024. 3. 11. 17:15·Ansible

playbook 을 사용하여 파일 복사


playbook 파일 내용 (filecopy.yml)

  • 복제 대상 정보는 inventory 파일에 기록 
$ cat inventory
[Server]
10.10.10.101


$ cat filecopy.yml
- name: file copy
  hosts: Server
  vars:
    ansible_ssh_user: ansible
  tasks:
    - name: file copy
      ansible.builtin.copy:
        src: /home/ansible/test.txt
        dest: /home/ansible/test.txt
        owner: ansible
        group: ansible

 

 

파일 복제

$ ansible-playbook -i inventory filecopy.yml

$ ansible-playbook -i inventory filecopy.yml
SSH password:
BECOME password[defaults to SSH password]:

PLAY [file copy] *************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************
ok: [10.10.10.101]

TASK [file copy] *************************************************************************************************************************
changed: [10.10.10.101]

PLAY RECAP *******************************************************************************************************************************
10.10.10.101               : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

 

 

복제 파일 변경 없이 동일한 playbook 재적용 시

$ ansible-playbook -i inventory filecopy.yml
SSH password:
BECOME password[defaults to SSH password]:

PLAY [file copy] *************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************
ok: [10.10.10.101]

TASK [file copy] *************************************************************************************************************************
ok: [10.10.10.101]

PLAY RECAP *******************************************************************************************************************************
10.10.10.101               : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

 

저작자표시 비영리 변경금지 (새창열림)
'Ansible' 카테고리의 다른 글
  • [playbook] 사용자 추가/제거
  • WinRM 구성 및 Ansible 테스트
  • playbook을 사용하여 apt update && apt upgrade
  • ansible 설치 및 환경 설정
기억보다는 기록을...
기억보다는 기록을...
내가 보려고 정리하는 글..
  • 기억보다는 기록을...
    메모장
    기억보다는 기록을...
    • 분류 전체보기
      • 클라우드(Azure, AWS, Alibaba)
      • 모니터링(Zabbix,Grafana)
      • 가상화(VMWare, Hyper-V)
      • Docker
      • Ansible
      • Linux
      • Windows
      • 이것저것
      • SQL
      • -------------------------
      • 재테크
  • 전체
    오늘
    어제
  • hELLO· Designed By정상우.v4.10.2
기억보다는 기록을...
playbook을 사용하여 파일 복사
상단으로

티스토리툴바