Ansible Documentation
Ansible community documentation Ansible offers open-source automation that is simple, flexible, and powerful. Got thoughts or feedback on this site? We want to hear from you! Join us in the Ansible Forum or open a GitHub issue in the docsite repository.
docs.ansible.com
Ansible 모듈의 종류 : 기본 / 클라우드 / 네트워크 / 데이터베이스 / 사용자 정의 모듈
Ansible 모듈 사용 예시 : Ansible 모듈은 플레이북에서 사용되며, 각 모듈은 작업(Task)으로 정의된다.
- name: Install Apache
yum:
name: httpd
state: present
ex) `yum`모듈을 사용하여 Apache 웹 서버를 설치하는 작업
파일 전송 (copy)
# Ansible 인스턴스
mkdir tmp && cd tmp
echo "hello ansible" >> hello.txt
# Ansible 실행 구문
ansible all -m copy -a "src=./hello.txt dest=/home/ubuntu/tmp"
scp를 이용할 수도 있지만, ansible의 copy 모듈을 사용하면 좀 더 쉽게 보낼 수 있다.
사전에 tmp라는 폴더를 만들어두고, hello.txt 파일을 전송해보도록 하자.
패키지 모듈 설치
sudo apt remove nano
ansible target -m apt -a "name=nano state=present" --become
nano 에디터를 삭제하고 재설치해보자.
뒤에 붙은 `--become`옵션은 해당 apt 명령을 root 권한으로 실행하라는 명령어이다.
나는 192.168.2.53 주소에만 nano를 삭제해봤는데, 이렇게 어느 부분에 변화가 일어났는지를 보기 쉽게 표시해준다.
'🌥️Cloud Study🌥️ > IaC' 카테고리의 다른 글
[ Ansible ] Jenkins와 Ansible 연동 후 플레이북 실행 (0) | 2024.08.23 |
---|---|
[ Ansible ] Ansible Galaxy로 원하는 롤, 콜렉션 찾기 (1) | 2024.08.23 |
[ Ansible ] 플레이북(Playbook) 사용해보기 (0) | 2024.08.22 |
[ Ansible ] Ansible 개요 및 환경설정 (0) | 2024.08.22 |