DevOps

[IaC] Ansible이란? Ansible config,SSH 설정, module Test

차노도리 2023. 6. 11. 00:24

Iac - Infrastructure as Code 

  • 인프라의 정보를 스크립트를 통해서 관리하는 것
  • 버전 관리를 통한 리소스 관리가 가능하다.

 

https://www.ansible.com/

 

Ansible is Simple IT Automation

Ansible is the simplest way to automate apps and IT infrastructure. Application Deployment + Configuration Management + Continuous Delivery.

www.ansible.com

 

Ansible

  • SSH를 통해 대상 서버에 접속하여 작업을 수행한다.
  • 에이전트 없이 동작한다.
  • 여러개의 서버를 효율적으로 관리할 수 있게 해주는 환경 구성 자동화 도구

 

Ansible에서 관리할 서버 설정

  • /etc/ansible/hosts - 관리할 서버 등록

Ansible에서 접속 SSH Key 생성

  • 키 생성
    • ssh-keygen
  • 키 복사
    • ssh-copy-id root@[접속할 서버 IP]

 

ex)추가 인증 없이 접속 가능

 

Ansible module 실행 옵션

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

ex) module 사용 예시