From the course: Ansible for Automation Essential Training: Advanced Playbooks, Roles, and Diverse Hosts
Unlock this course with a free trial
Join today to access over 24,700 courses taught by industry experts.
Creating dynamic inventory files - Ansible Tutorial
From the course: Ansible for Automation Essential Training: Advanced Playbooks, Roles, and Diverse Hosts
Creating dynamic inventory files
- [Instructor] Thus far, all the inventories used are manually constructed, which is just fine for static or slow-changing environments. To work around this, an admin can employ something called a dynamic inventory. In short, it's a Python script that runs and generates an inventory from an external source. This source could be something as simple as a CSV file that is consumed, but more commonly, it's something like ServiceNow, VMware vCenter, AWS, or GCP. For common sources of truth, there are already existing scripts just a Google away. It's when I'm trying to do something more complex or a system less used that I have to do something custom. This example playbook uses the groups magic variable to print out hosts in the inventory. It gives me access to every group in the inventory, and in this instance, I'm asking for the contents of the all group. The real magic comes from the custom_inventory Python script. There's a lot going on in this file, but most of it's boilerplate. The…
Contents
-
-
-
(Locked)
Installing collections2m 20s
-
Construct a simple playbook4m 19s
-
(Locked)
Using variables5m 7s
-
(Locked)
Using loops2m 45s
-
(Locked)
Adding conditionals4m 57s
-
(Locked)
Utilizing blocks3m 49s
-
(Locked)
Exploring templates4m 29s
-
(Locked)
Discovering handlers2m 23s
-
(Locked)
Using tags2m 53s
-
(Locked)
Testing plays with check mode2m 15s
-
(Locked)
Conditional failure with assert2m 20s
-
(Locked)
Failure and change control2m 32s
-
(Locked)
Nesting loops3m 29s
-
(Locked)
Creating dynamic inventory files3m 7s
-
(Locked)
Challenge: Create a complex playbook1m 17s
-
Solution: Verify the complex playbook2m 52s
-
(Locked)
-
-
-
-