ansible ad-hoc

eunyeong·2023년 2월 22일
0

Ansible_Basic

목록 보기
1/4

앤서블 공식 문서 ===> https://docs.ansible.com/

Ad-Hoc 명령

  • ad-hoc 명령은 하나 이상의 관리 노드에 단일 작업을 실행하는 임시 명령
  • 거의 반복하지 않는 간단한 작업에 주로 사용
서버 재부팅
파일 관리
패키지 관리
사용자 및 그룹 관리
서비스 관리
팩트 변수 수집

Ad-hoc 명령 사용

ansible [pattern] -m [module] -a "[module options]"
-m: 모듈 이름 지정(기본값: command)
-a: 모듈의 option/argument

  • 시스템 재부팅
    ansible databases -a "/sbin/reboot" -u username -b -K
  • 파일 복사
    ansible webservers -m copy -a "src=/etc/hosts dest=/tmp/hosts"
  • 파일 권한 변경
    ansible webservers -m file -a "dest=/srv/foo/a.txt mode=600"
  • 파일 소유권 변경
    ansible webservers -m file -a "dest=/path/to/c mode=755 owner=?? group=?? state=directory"
  • 파일 삭제
    ansible webservers -m file -a "dest=/path/to/c state=absent"
  • 패키지 설치(업데이트 X)
    ansible webservers -m apt -a "name=acme state=present"
  • 특정 버전 패키지 설치
    ansible webservers -m apt -a "name=acme=1:0.96.4-5 state=present"
  • 패키지 제거
    ansible webservers -m apt -a "name=acme state=absent"
  • 사용자 생성
    ansible all -m user -a "name=foo password="
  • 사용자 제거
    ansible all -m user -a "name=foo state=absent"
  • 서비스 시작
    ansible webservers -m service -a "name=apache2 state=started"
  • 서비스 재시작
    ansible webservers -m service -a "name=apache2 state=restarted"
profile
아무것도 모르는 초보

0개의 댓글