ansible(앤서블)

Ansible - A Beginner's Tutorial, Part 1

$ ssh-keygen

$ ssh-copy-id webserver

$ ssh-copy-id appserver

$ ssh-copy-id dbserver

$ ssh webserver

$ ssh appserver

$ ssh dbserver

# apt-add-repository ppa:ansible/ansible

# apt-get update

# apt-get install ansible

# ansible --version

$ ls -lha /etc/ansible/

$ cp -R /etc/ansible myplatform

$ cd myplatform/

$ ls -lha

$ vi ansible.cfg

inventory = hosts

$ vi hosts

webserver

appserver

dbserver

$ ansible -m ping all

dbserver | SUCCESS=> {

    "changed": false,

    "ping" : "pong"

}

...

$ ansible -m shell -a 'hostname' all

appserver | SUCCESS | rc=0 >>

appserver

...

$ ansible -m shell -a 'df -h' all

dbserver | SUCCESS | rc=0 >>

Filesystem    Size    Used    Avail    Use%    Mounted on

udev           473M      0      473M   0%     /dev

...

$ ansible -m shell -a 'whoami' all

webserver | SUCCESS | rc=0 >>

ben

...

$ ansible -b -K -m user -a 'name=testuser' all

SUDO password:

webserver | SUCCESS => {

    "changed": true,

    "comment": "",

    "createhome": true,

    "group": 1001,

    "home": "/home/testuser",

...

$ ssh webserver

$ gettent passwd | grep testuser

testuser:x:1001:1001::/home/testuser:

$ ansible -m shell -a 'getent passwd | grep testuser' all

webserver | SUCCESS | rc=0 >>

testuser:x:1001:1001::/home/testuser:

...

$ ansible -b -K -m user -a 'name=testuser state=absent' all

appserver | SUCCESS => {

    "changed": true,

    "force": false,

    "name": "testuser",

    "remove": false,

    "state": "absent"

}

...

 

댓글

댓글 본문
작성자
비밀번호
버전 관리
Frank
현재 버전
선택 버전
graphittie 자세히 보기