Automation Tools/Ansible
1.2 ansible | [test][playbook] 파일 복사와 삭제
ploz
2021. 3. 16. 14:47
반응형
1. 파일 복사 playbook
[root@ANSIBLE ansible]# cat copy_file.yml
---
- name: "copy file"
hosts: test02
become: true
tasks:
- name: "backup file" # command로 파일 선 백업
command: mv /hosts /hosts.bak
- name: "copy files" # copy 모듈로 local -> remote로 파일 복사
copy:
src: /etc/hosts
dest: /
2. 파일 삭제 playbook
[root@ANSIBLE ansible]# cat rm_file.yml
---
- name: "delete file"
hosts: test1
become: true
tasks:
- name: "delete files"
file:
path: /hosts
state: absent
## file모듈의 state 파라미터
## absent : 파일 삭제, 심볼릭 링크도 삭제
## directory : 디렉토리 생성
## touch : 파일 생성
반응형