Moving into Devops
July 27, 2020
debian bash devops ansibleIn my last contract role, I spent more time working with the Devops team than the frontend team. I really enjoyed it and now feel that this is a better path for me. I have been using the command line to build, manage and test servers for many many years and feel this is somewhere I can offer more to companies in the future.
I was on twitter and I found this article about alternative career paths from freecodecamp and the Devops idea was one most appealing to me.
I have spent a lot of the last few months learning more and more about linux and the Command line. Including learning Bash Scripting and Python.
ssh
create a ssh key and copy it to the raspberry pi:
root@linuxtechi:~# ssh-keygen
root@linuxtechi:~# ssh-copy-id root@192.168.1.156
This allows you to ssh into the machine without a password.
Bash Cheat sheet
Back in the days as an Apple Mac user, i really like Applescript. With these little scripts you could get stuff done quickly and easily. Laravel also provides a need way to write command line scripts which allow me to download and process the data.
Bash scripting is similar, i now have scripts to create new posts for this blog, build the css/js with webpack, deploy the site to github and many more.
To help, I have added a Bash Cheat cheet to this blog.
Ansible
Ansible is a tool to software provisioning, configuration management, and application-deployment tool. wikipedia
opensource.com intro to ansible
I do like learning from videos and I found this series of videos Ansible with Jeff Geerling
Cheatsheets
github.com/germainlefebvre4/ansible-cheatsheet
armoucar.github.io/ansible-cheatsheet/
Now i can setup a hosts file like so:
[raspberrypi]
192.168.1.166 ansible_ssh_user=pi hostname=raspberrypi
Once i set up the ssh login (see above), i can now test the server connection with
ansible -i hosts -m ping raspberrypi
i have setup a new github repo which i run like this:
ansible-playbook site.yml -i hosts
Vagrant and Virtualbox
With Laravel there is Homestead which provides an easy vagrant box with all the linux tools to run a website. I have also used Virtualbox for years to run debian boxes from around the time of Debian 6.
vagrant up
vagrant halt
vagrant ssh
Docker
Docker takes the whole Vagrant VM forward and makes an entire container which you can deploy as the finished website. I have used it before in my last contract role and found it very powerful.
Kickass Laravel Development with Docker - David McKay - Laracon EU 2018 Amsterdam
Jenkins
Jenkins is a Continuous Integration and testing environment which allows you to test your code as it is pushed to Github.
PHP UK Conference 2018 - Michael Heap - Zero to Jenkins: Automatic builds + deploys
I am installing Jenkins on my Raspberry Pi using this tutorial from https://pimylifeup.com/jenkins-raspberry-pi/
https://github.com/amochohan/laravel-jenkins-ci-boilerplate
To install jenkins add this to the playbook
tasks:
- name: ensure the jenkins apt repository key is installed
apt_key: url=https://pkg.jenkins.io/debian-stable/jenkins.io.key state=present
become: yes
- name: ensure the repository is configured
apt_repository: repo='deb https://pkg.jenkins.io/debian-stable binary/' state=present
become: yes
- name: ensure jenkins is installed
apt: name=jenkins update_cache=yes
become: yes
- name: ensure jenkins is running
service: name=jenkins state=started
If you would like to contact me with this form on londinium.com, ilminster.net or via Twitter @andylondon