Introduction to Ansible Transcripts
Chapter: Ansible Core Concepts
0:00 We see how each of the Ansible core concepts
0:02 relates to each other and fills a specific need
0:04 for how to handle configuration management.
0:06 Now, let's take a look at each of these concepts
0:08 individually, give them a clear concise definition
0:11 so that we know what we're working with
0:12 and to take a look at some examples
0:13 so that in the next chapter
0:15 when we write our first playbook
0:16 we at least have enough of an idea
0:18 of why we're working on each step.
0:19 The first concept is modules.
0:22 Modules are code provided by Ansible.
0:24 Now, they're typically written in Python
0:25 and in fact, the core Ansible modules
0:27 that are provided with the Ansible project
0:30 when you install it, are all written in Python.
0:32 So, more advanced topic but
0:33 they don't actually need to be in Python.
0:35 You could write a module in Java
0:38 There's a standard way to call Ansible modules.
0:40 But for our purposes in the introduction
0:42 just think about this as Python code
0:44 that Ansible provides you to perform
0:46 a specific action you want to take.
0:48 What do we mean by specific action?
0:50 Well, for example, if we want to clone a Git repository.
0:52 For working on a web application
0:54 we want to clone it to our development server
0:56 where we're going to do a dev deployment.
0:58 There is a Git module for handling that task.
1:01 If we want to enable an operating system's firewall
1:03 and configure various settings on it
1:05 there's a module for working with firewalls
1:08 in various operating systems.
1:09 If we want to send notifications
1:11 let's say, e-mail or text message, or Slack message
1:14 there are notification modules.
1:15 The creators and maintainers of the Ansible project
1:18 have done a fantastic job of providing modules
1:20 for almost any purpose you can think of.
1:22 And as you can imagine, that's a whole lot of modules.
1:24 So, if we look at the Ansible modules documentation
1:27 it's listed by category.
1:29 It can get overwhelming very quickly.
1:31 And as I mentioned, there's notification modules.
1:33 So, if you click on notification modules
1:35 in the Ansible documentation
1:37 it's going to list them all out for you.
1:38 If you're ambitious enough to list all of the modules
1:41 you will be inundated with everything
1:43 that comes with Ansible.
1:45 However, I would say this is a really bad place to start.
1:48 I have never used all of these modules as we scroll through
1:52 we're barely past the modules
1:54 that come with Ansible that start with C.
1:55 I strongly recommend against trying
1:57 to memorize all the modules.
1:59 Instead, throughout the course
2:00 we'll introduce the most important modules
2:03 and then you can branch out from there
2:04 depending on how your deployment needs and your
2:06 configuration management needs require various modules.
2:09 At least you know you can search for all modules
2:11 on the all modules page.
2:13 For know, let's say we want to accomplish an action.
2:17 Typically, what I do is go to the specific module.
2:20 If we want to send a message
2:21 in Slack/Slack notification
2:23 we can click on the Slack module
2:25 it'll give us any required parameters
2:27 and it will give us examples.
2:29 This is typically where I copy and paste
2:32 start playing with the module that I've never used before
2:34 and start using it.
2:35 We'll cover how to use the modules when we go over tasks.
2:37 But I have to commend the
2:39 Ansible core developers and contributors
2:41 for all the great documentation that they provide.
2:43 I strongly recommend keeping the documentation up
2:46 so we know that when we want
2:47 to accomplish an action in Ansible
2:48 there's a documentation list by category.
2:50 There is also the code on GitHub.
2:52 Everything about Ansible is open source
2:54 and reading the source code is really helpful
2:57 when you're working with modules.
2:59 So, on GitHub, github.com/ansible/ansible
3:02 we've got the code for Ansible and you're going to want
3:05 to look under lib/ansible and this is where
3:07 the modules directory lies
3:09 and all of the modules underneath.
3:11 So, when we took a look at the notification modules
3:13 if we click on notification
3:15 this is where the source code
3:16 to each one of the modules lives
3:18 if we look at slack.py, we can reference the source code
3:21 for sending messages to Slack.
3:25 So, we've got Ansible documentation
3:27 so as we start writing our first playbooks
3:29 we're going to want to accomplish one or more actions
3:31 we'll use the module's documentation
3:33 and the module's source code
3:34 how to use each module properly
3:36 and philosophically, Ansible modules work well
3:38 because they abstract all the low-level complexity
3:41 the previous automation systems like Bash Shell scripts
3:44 and have really hard time of containing.
3:46 One of my first jobs out of college
3:47 before there were any configuration management systems
3:50 we used Bash scripts to automate our whole deployment
3:52 and those scripts were littered with conditional statements
3:54 if we're deploying to dev, take these steps
3:57 if we're deploying to staging, to test, to production
3:59 for deploying one version or another version
4:02 Ansible modules work well because
4:03 they abstract that low-level complexity.
4:05 So we know where to look when we want to use a module
4:07 but how do we actually use them?
4:09 They are invoked by writing Ansible tasks.
4:11 So, let's take a look at how to create our tasks.