ans1에서 ans2와 ans3를 관리한다.

ans1에서 ans2와 ans3를 관리한다.

VM

  1. CensOS clone 3개 생성

    ans1, ans2, ans3

  2. IP 주소 변경

    vi /etc/sysconfig/network-scripts/ifcfg-ens32
    
    1. ans1: 211.183.3.10
    2. ans2: 211.183.3.20
    3. ans3: 211.183.3.30
  3. hostname 변경

    hostnamectl set-hostname ans1
    
  4. ans1 NetworkManager 끄기

    [root@ans1 ~]# systemctl stop NetworkManager
    [root@ans1 ~]# systemctl disable NetworkManager
    

Ansible 설치

  1. [root@ans1 ~]# yum -y update

  2. [root@ans1 ~]# yum install -y epel-release [root@ans1 ~]# yum install -y ansible

  3. [root@ans1 ~]# vi /etc/ansible/hosts

    **211.183.3.20 #ans2
    211.183.3.30 #ans3**
    
    # 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
    
    <후략>
    
  4. [root@ans1 ~]# ping 211.183.3.20 [root@ans1 ~]# ping 211.183.3.30

    [root@ans1 ~]# ping 211.183.3.20
    PING 211.183.3.20 (211.183.3.20) 56(84) bytes of data.
    64 bytes from 211.183.3.20: icmp_seq=1 ttl=64 time=0.555 ms
    ^C
    --- 211.183.3.20 ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 0.555/0.555/0.555/0.000 ms
    
    [root@ans1 ~]# ping 211.183.3.30
    PING 211.183.3.30 (211.183.3.30) 56(84) bytes of data.
    64 bytes from 211.183.3.30: icmp_seq=1 ttl=64 time=1.96 ms
    64 bytes from 211.183.3.30: icmp_seq=2 ttl=64 time=0.675 ms
    ^C
    --- 211.183.3.30 ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1008ms
    rtt min/avg/max/mdev = 0.675/1.317/1.960/0.643 ms
    

연결 확인(inven 설정 없이)

  1. [root@ans1 ~]# ansible all -m ping

    서버 개수만큼 무지성 yes

    네트워크 연결을 위한 fingerprint를 만드는 작업이다.

    근데 현재는 인증 정보가 없어서 연결이 불가능하다.

  2. [root@ans1 ~]# ansible all -m ping -k

연결 확인(inven 설정)

  1. [root@ans1 ~]# cd /etc/ansible [root@ans1 ansible]# vi my_inven.txt

    211.183.3.20
    211.183.3.30
    
  2. [root@ans1 ansible]# ansible all -i my_inven.txt -m ping -k

    처음에는 안 됐는데 재부팅하니까 됐음