-
- Vagrant
- Ansible
- VirtualBox
-
- 가상머신(VirtualBox 등) 에 VM 을 자동으로 생성해 준다 (Provisioning)
Vagrantfile
파일에 VM 구성을 정의한다
-
- 여러 대의 서버를 동시에 셋팅할 수 있게 해준다
/etc/ansible/hosts
파일에 관리할 서버 IP 를 등록한다ansible-playbook playbook.yml
명령으로 서버 셋팅을 진행한다
-
$ brew install vagrant $ vagrant plugin install vagrant-vbguest --plugin-version 0.21 $ vagrant plugin install vagrant-disksize
-
# vagrant 를 사용할 폴더를 만든다 $ mkdir vagrant-test $ cd vagrant-test # vagrant 를 초기화한다 # Vagrantfile 파일이 생성된다 $ vagrant init # vagrant 설정 파일 수정 $ vi ./Vagrantfile
-
ansible
명령어를 설치한다/etc/ansible/hosts
파일에 서버 IP 를 등록한다- ssh key 를 생성하고 ansible client 노드에 등록
- ssh key 를 생성한다
- 생성한 ssh key 를 ansible client 노드로 카피한다
- ansible client 노드로 비밀번호 입력 없이 ssh 접속이 되는지 확인한다
-
/etc/ssh/sshd_config
설정을 변경한다
-
# ansible 명령어를 설치한다 $ sudo yum update -y $ sudo yum install -y ansible # ansible 이 설치됐는지 확인한다 $ ansible --version
-
/etc/ansible/hosts
파일에 서버 IP 를 등록한다
$ sudo vi /etc/ansible/hosts [was] 192.168.56.21 192.168.56.22
- ansible 명령으로 서버 IP 가 리스트업 되는지 확인한다
# ansible client 노드에 ssh public key 를 등록한 후에 테스트한다 $ ansible all --list-hosts hosts (2): 192.168.56.21 192.168.56.22
-
$ ssh-keygen -f ~/.ssh/id_rsa -P '' $ ls -l ~/.ssh -rw-------. 1 vagrant vagrant 1679 Jan 13 02:40 id_rsa -rw-r--r--. 1 vagrant vagrant 404 Jan 13 02:40 id_rsa.pub
-
$ ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected] $ ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
-
$ ssh [email protected] $ ssh [email protected]
-
# PasswordAuthentication yes 로 수정 $ sudo sed -i 's/^PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config $ sudo systemctl restart sshd