Git Product home page Git Product logo

vagrant-ansible-test's Introduction

Vagrant & Ansible 를 이용한 서버구성 자동화

  • 필요한 도구

    • Vagrant
    • Ansible
    • VirtualBox

개요

  • Vagrant

    • 가상머신(VirtualBox 등) 에 VM 을 자동으로 생성해 준다 (Provisioning)
    • Vagrantfile 파일에 VM 구성을 정의한다
  • Ansible

    • 여러 대의 서버를 동시에 셋팅할 수 있게 해준다
    • /etc/ansible/hosts 파일에 관리할 서버 IP 를 등록한다
    • ansible-playbook playbook.yml 명령으로 서버 셋팅을 진행한다

Vagrant

  • vagrant 설치

    $ brew install vagrant
    $ vagrant plugin install vagrant-vbguest --plugin-version 0.21
    $ vagrant plugin install vagrant-disksize
  • vagrant 초기화

    # vagrant 를 사용할 폴더를 만든다
    $ mkdir vagrant-test
    $ cd vagrant-test
    
    # vagrant 를 초기화한다
    # Vagrantfile 파일이 생성된다
    $ vagrant init
    
    # vagrant 설정 파일 수정
    $ vi ./Vagrantfile

Ansible

ansible 설치 요약

  • ansible controller 서버에서

    • ansible 명령어를 설치한다
    • /etc/ansible/hosts 파일에 서버 IP 를 등록한다
    • ssh key 를 생성하고 ansible client 노드에 등록
      • ssh key 를 생성한다
      • 생성한 ssh key 를 ansible client 노드로 카피한다
      • ansible client 노드로 비밀번호 입력 없이 ssh 접속이 되는지 확인한다
  • ansible client 노드에서

    • /etc/ssh/sshd_config 설정을 변경한다

ansible controller 서버

  • ansible 명령어 설치

    # ansible 명령어를 설치한다
    $ sudo yum update -y
    $ sudo yum install -y ansible
    
    # ansible 이 설치됐는지 확인한다
    $ ansible --version
  • /etc/ansible/hosts 수정

    • /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 key 를 생성한다

    $ 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 key 를 ansible-client 노드로 카피한다

    $ ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
    $ ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
  • ansible-client 노드로 비밀번호 입력없이 ssh 접속이 되는지 확인한다

ansible client 노드

  • ansible-client 노드에서 /etc/ssh/sshd_config 수정

    # PasswordAuthentication yes 로 수정
    $ sudo sed -i 's/^PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
    
    $ sudo systemctl restart sshd

vagrant-ansible-test's People

Contributors

hothoony avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.