Set up VM with ansible

Infrastructure as a Code

Recetnly I’ve been playing a lot with Terraform, Ansible and Kubernetes mostly related to work. With these three, devops engineer can build the infrastructure with code without much problem compare to the previous generation of technology

Ansible

  • easy to build up the VM

installation

pip3 install ansible

Environment

ansible -v
ansible 2.7.10

Preparing VM before ansible

  1. install ubuntu 16.04 LTS
  2. create an account: deployer
  3. set up the ssh key
  4. disalbe password ssh login by edithing this file
    • /etc/ssh/sshd_configd.cfg
      PasswordAuthentication no
      Port 1022
      
  5. update sudoer to sudo without password
    • /etc/sudoers
    • change this
%sudo ALL=(ALL:ALL) ALL
%sudo ALL=(ALL:ALL) NOPASSWD: ALL

side note, how to get ssh finger print from your public key

[email protected]:~/.ssh$ ssh-keygen -E md5 -lf ~/.ssh/id_rsa.pub | awk '{print $2}'
MD5:93:2c:6e:5c:6b:c6:4e:bb:07:77:33:56:51:26:84:1a

Ansible Roles:

Using the playbook that someone else already wrote

  • Go checkout what’s popular and stable in Ansible Galaxy
  • Install the role
    ansible-galaxy install franklinkim.fail2ban
    
  • or install roles from requirements.yml file
    ansible-galaxy install -r requirements.yml
    

To get free $100 from Digital Ocean

click this link: https://m.do.co/c/edcc3b490a38

###

COMMENTS
Related Post