클라우드/Ansible
Ansible command(shell) 실행
이쿠우우
2022. 1. 27. 15:46
반응형
command(shell) 실행 (shell 모듈)
playbook 예제
---
- hosts: all
remote_user: root
become: true
tasks:
- name: execute the script
shell: ./test.sh
args:
chdir: /temp
executable: /bin/bash
|
"shell:"
shell script 실행
"chdir"
cd 명령과 동일함.
경로 이동.
"executable:"
실행 shell을 변경함.
shell 변경하지 않으면 default로 sh shell로 실행됨.
playbook 실행
ansible-playbook -i host.ini ./testplaybook
Managed node에서 결과 확인
script가 실행되서 sample.txt 파일이 생성되는 것을 확인할 수 있음.
참고
반응형