Skip to content
Posted on:May 6, 2019 at 07:00 AM

Set up VM with ansible

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_config
PasswordAuthentication no
Port 1022
  1. update sudoer to sudo without password
  • /etc/sudoers
  • change this
%sudo ALL=(ALL:ALL) ALL
%sudo ALL=(ALL:ALL) NOPASSWD: ALL
  1. comment out apt update list from cdrom
  • open this file: nano /etc/apt/sources.list
  • comment out any line start with cdrom:

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

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

Web Analytics