관리 메뉴

개발그래머

Ansible[3] Ansible 기본 명령어 본문

Devops/Ansible

Ansible[3] Ansible 기본 명령어

임요환 2023. 3. 26. 19:55

ansible 명령어 실행옵션

  • -i(--inventory-file) 적용될 호스트들에 대한 파일정
  • -m(--module-name) 모듈 선택
  • -k(--ask-pass) 관리자 암호 요청
  • -K(--ask-become-pass) 관리자 권한 상승
  • --list-hosts 적용되는 호스트 목록

 

ansible의 중요한 특성 = 멱등성

  • 같은 설정을 여러 번 적용하더라도 결과가 달라지지 않는 성질

 

1. 서버 연결 확인

ansible all -m ping

2. 메모리 용량 확인

ansible all -m shell -a "free -h"

3. 파일 전송 테스트

touch test.txt  //파일 생성
echo "Hi,there" >> test.txt
cat test.txt

ansible all -m copy -a "src=./test.txt dest=/tmp"

 

4. httpd 설치

ansible devops -m yum -a "name=httpd state=present" //all 대신 hosts파일에 설정했던 그룹명(devops)으로도 가능

'Devops > Ansible' 카테고리의 다른 글

Ansible[5] Docker 이미지 관리  (0) 2023.03.26
Ansible[4] Ansible Playbook  (0) 2023.03.26
Ansible[2] Docker 컨테이너로 실행  (0) 2023.03.25
Ansible[1] 소개  (0) 2023.03.24