[PYTHON] Ansible as an infrastructure learning tool

Ansible, one of the configuration management tools alongside Chef and Puppet. However, I thought that it would be good not only as a configuration management tool but also as a learning tool on the infrastructure side, so I will write it. I'm also a beginner, so I think there are various things to do, but I'm very welcome.

Features and writing

First, let's briefly describe the features of Ansible.

--Since you can build an environment as long as you can connect to the target environment with SSH, it is simple. --Since the processing is executed in the order of writing, it is simple --Since it can be written in YAML, it is simple ――Since it is simple, the initial learning cost is low! --Even those who are frustrated by Chef can go (should)

ansible-base.001.jpg

Ansible itself is written in Python, but I don't think you are aware of Python. However, Python must be installed in the target environment.

As an example, I will take the one that builds the nginx + wordpress environment from the official sample. I think you can imagine that it will be shaped like this.

This article was easy to read as an explanation of the installation method and the introduction part.

-Notes from reading Ansible's documentation --Qiita

Why i thought it was good

--Economical because you can discard the built environment as long as you have a playbook (YAML that is the base that describes the configuration). ――Even if you want to learn only a part, if you have a base playbook, you can learn smoothly by changing a part of it. ――Since Ansible's notation is simple, it's easy to get an overall picture of the composition you made. --If you manage it with git, you can easily follow the history of changes. ――Since the documents are extensive, I often read the documents and learn from them during trial and error. --There is a lot of information that can be referred to in the public playbook. You can learn with a small particle size, which is different from learning from books.

Tips

--VPS such as Digital Ocean looks better than Vagrant ――It is good to use Vagrant for testing, but it takes time to start up each time, and when the playbook becomes large to some extent, it may take time depending on the power of the host OS. I think it is better to use a VPS that can be used on an hourly basis. -AWS is good, but DigitalOcean, which is easy to use, cheap and easy to understand, may be good. --Grow with git management --If you use it for learning, it may be better to create a directory like / ansible / nginx-rails and manage git under the ansible directory. If you make a mistake and can't revive, you can go back to the past.

Example of how to use it as a learning tool

  1. First try writing a simple playbook yourself
  2. If you are unsure about how to write, look at Official Documents or search for * [What you want to know] + ansible *, and you will find a lot of playbooks. Refer to it.
  3. If you are unsure about how to configure Ansible, see Best Practices or Ansible Galaxy. Search and find.
  4. Start a new server and try it.
  5. Watch the movement and correct

Basically this is repeated.

Other pages that are generally helpful

-Introduction to Ansible (15 times in total) --Dot install for programming ――If you do this, you can definitely start.

Japanese books

It is very easy to understand and easy to read. It's a list of commands, but instead of trying to read everything from the beginning, I think it's better to start making it after reading about half of it and refer to it again later as a reference book. When referring to it, it is helpful because it is a description that is separated by theme and does not waste.

Introduction Ansible

Recommended Posts

Ansible as an infrastructure learning tool
Machine learning of sports-Analysis of J-League as an example-②
An introduction to machine learning