클라우드/Ansible
Ansible directory 생성 (file 모듈)
이쿠우우
2022. 1. 27. 15:43
반응형
managed node에 directory 생성 (file 모듈)
playbook 예제
---
- hosts: all
remote_user: root
become: true
tasks:
- name: Creates directory
file:
path: /temp
state: directory
|
"become: true" 옵션
become은 특정 사용자로 전환(become)할지 여부확인
true 설정 시 sudo 명령과 동일함.
해당 설정 없으면 errno 13 permission denied 오류 발생함.
"file: "
state 사용 시 해당 경로에 directory가 없다면 directory 생성
playbook 실행
ansible-playbook -i host.ini ./testplaybook
Managed node에서 결과 확인
directory가 생성된 것을 확인할 수 있음.
반응형