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
- install ubuntu 16.04 LTS
- create an account: deployer
- set up the ssh key
- disalbe password ssh login by edithing this file
- /etc/ssh/sshd_config
PasswordAuthentication no
Port 1022
- update sudoer to sudo without password
- /etc/sudoers
- change this
%sudo ALL=(ALL:ALL) ALL
%sudo ALL=(ALL:ALL) NOPASSWD: ALL
- 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