Ansible 운영 - 1. 초기 설정 > Ansible 자료실

본문 바로가기

사이트 내 전체검색

뒤로가기 Ansible 자료실

운영 Ansible 운영 - 1. 초기 설정

페이지 정보

작성자 AnsibleM 작성일 20-10-21 14:25 조회 15,294 댓글 0

본문

1. Hosts File Setting

Ansible 클러스터를 구성하고자 하는 서버 hostnmae과 IP 주소 정보 업데이트

1
2
3
4
5
6
7
$ cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
 
[ ip_address ] tower
[ ip_address ] serverA
[ ip_address ] serverB
cs



2. SSH-KEY Setting

Ansible은 SSH 접속을 기반으로 원격 서버들에게 명령을 전달하기 때문에, Controller 서버와 Remote Server 간 SSH Key가 공유되어야 함.

1
2
$ ssh-keygen
$ ssh-copy-id [remote-host-user]@[remote-host-ip]
cs


3. Inventory File Setting

Inventory : 관리 대상이 될 host list를 나열하거나 그룹화한 파일. inventory 파일이 있어야 관리 대상을 정의하고 작업 수행 가능
vars를 활용하여 대상 그룹 및 host의 전역 변수 정의 가능.
Ansible Default Inventory 파일 : /etc/ansible/hosts
default inventory or 별도 inventory 파일 작성 후 활용 가능

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$ cat /etc/ansible/hosts
# This is the default ansible 'hosts' file.
#
# It should live in /etc/ansible/hosts
#
#   - Comments begin with the '#' character
#   - Blank lines are ignored
#   - Groups of hosts are delimited by [header] elements
#   - You can enter hostnames or ip addresses
#   - A hostname/ip can be a member of multiple groups
 
# Ex 1: Ungrouped hosts, specify before any group headers.
 
. . . ( 중 략 ) . . .
 
$ cat ./inventory
[servers]
serverA
serverB
 
[servers:vars]
ansible_connection=ssh
ansible_user=root
ansible_ssh_pass=root
 
cs


4. Ansible Ping Test

inventory 목록의 server 접속 정상 여부 확인

* default inventory 파일 활용 시 *
1
$ ansible all -m ping
cs


* 별도 inventory 파일 활용 시 *
1
2
3
4
5
6
7
8
9
$ ansible -i inventory all -m ping
serverA | SUCCESS => {
    "changed"false,
    "ping""pong"
}
serverB | SUCCESS => {
    "changed"false,
    "ping""pong"
}
cs

댓글목록 0

등록된 댓글이 없습니다.

Copyright © 소유하신 도메인. All rights reserved.

사이트 정보

회사명 : (주)리눅스데이타시스템 / 대표 : 정정모
서울본사 : 서울특별시 강남구 봉은사로 114길 40 홍선빌딩 2층 / tel : 02-6207-1160
대전지사 : 대전광역시 유성구 노은로174 도원프라자 5층 / tel : 042-331-1161

PC 버전으로 보기