클라우드/Ansible
Ansible file 전달 (copy 모듈)
이쿠우우
2022. 1. 27. 15:44
반응형
managed node에 file 전달 (copy 모듈)
먼저 sample file을 생성함.
test.sh 파일
#!/bin/bash
echo "ansible playbook Test!!!!!" > sample.txt
|

playbook 예제
---
- hosts: all
remote_user: root
become: true
tasks:
- name: store file to remote server
copy:
src: /root/ansible_test/temp/test.sh
dest: /temp/test.sh
|
"become: true"
become은 특정 사용자로 전환(become)할지 여부확인
true 설정 시 sudo 명령과 동일함.
해당 설정 없으면 errno 13 permission denied 오류 발생함.
"copy:"
managed node에 파일 복사
playbook 실행
ansible-playbook -i host.ini ./testplaybook
Managed node에서 결과 확인
파일이 정상적으로 복사된 것을 확인할 수 있음.
반응형