Fireship · @fireship
Ansible in 100 Seconds
Uploaded March 28, 2023 · Length 2:34
Summary
ansible tutorial for automating linux servers with declarative yaml code
- ansible
- linux automation
- declarative code
- configuration management
- devops
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
ansible in open source automation tool
- 0:02
that can describe your it infrastructure
- 0:04
with simple declarative code it was
- 0:06
created by Michael DeHaan in 2012 then
- 0:09
acquired by Red Hat a few years later
- 0:10
and today is one of the most popular
- 0:12
configuration management tools most
- 0:14
importantly it uses declarative
- 0:16
push-based yaml code that allows devops
- 0:18
teams to easily automate their Linux
- 0:20
servers increasing efficiency while
- 0:22
reducing the likelihood of human error
- 0:24
it works by making at least one machine
- 0:26
a control node it then connects to
- 0:28
multiple manage nodes and sends them an
- 0:30
ansible module over SSH which can
- 0:33
configure that machine's dependencies
- 0:34
update network settings provision
- 0:36
databases or really any job that you
- 0:38
might need to do more than once
- 0:40
developers write playbooks that contain
- 0:42
a series of jobs called plays each play
- 0:44
is a set of instructions that can be
- 0:46
executed on one or more Target hosts it
- 0:48
will execute each task in order against
- 0:50
all machines in parallel in addition A
- 0:52
playbook is item potent which means it
- 0:54
won't actually make any changes unless
- 0:56
it has to in excellent real world use
- 0:58
case for ansible is to manage your Linux
- 1:00
servers on a platform like lenode we
- 1:02
start by provisioning a server running
- 1:04
Ubuntu as the control node then into it
- 1:07
from the terminal from there we can
- 1:08
install ansible on this machine this
- 1:10
machine needs permission to create and
- 1:12
modify other servers so we'll get an
- 1:14
access token for the lenode API and
- 1:16
store it somewhere securely now what's
- 1:18
awesome about ansible is that it has a
- 1:20
massive ecosystem of pre-built playbooks
- 1:22
that can be accessed on ansible Galaxy
- 1:24
installed a collection for lenode using
- 1:26
the ansible Galaxy command from there
- 1:28
it's a good practice to use ansible volt
- 1:30
to store sensitive information like a
- 1:33
password securely so it's not required
- 1:34
to be directly in a yaml file and will
- 1:36
want to encrypt our personal access
- 1:38
token here and now we're ready to write
- 1:40
our first Playbook create a file in the
- 1:41
develop and directory ending in Dot yml
- 1:44
and then create the first play by giving
- 1:46
it a name like create lenode instance
- 1:48
then the host property is a pattern that
- 1:50
defines one or more machines that will
- 1:51
run this play or they can be listed in a
- 1:54
dedicated inventory file next we can
- 1:56
Define reusable variables or point to
- 1:58
files that contain multiple variables


