Ansible 101 – Episode 5 – Playbook handlers, environment vars, and variables


    Jeff Geerling (geerlingguy) dives deeper into Ansible playbooks, following material from chapter 5 in the bestselling Ansible book, Ansible for DevOps.

    Buy Ansible for DevOps:

    Sponsor Jeff on GitHub:
    Support Jeff on Patreon:


    00:00 – Intro
    04:25 – Questions from last episode
    07:58 – Raspberry Pi K8s cluster
    10:00 – Simple Apache playbook
    11:33 – Playbook handlers
    23:45 – Environment variables
    35:43 – Dynamic variable files for multi-OS
    48:40 – Ansible facts and setup module
    50:48 – Registered variables
    54:56 – facter and ohai
    56:25 – Preview of Ansible Vault
    58:00 – Outtro


    Previous article15-Ansible – Создание Ролей – Roles
    Next articleAnsible Automation for Linux Workshop USA – 28th April 2021


    1. at the current version i'm using i do net get the registered value to work. It always outputs an empty field.
      The ansible version is 2.10.9, with python 3.6.8.
      It seems to be that saving the variable is not succesful. I've tried just using cat ~/.bash_profile which does give me the whole file as output as the debug message. I think that it therefore has something to do with the output of the source and echo line. As a non bash hero I couldn't find the solution to this, did any had the same problem and solved it?

    2. Fantastic tutorial, and great book!

      One point I'd like to add, when you show environment variables, it works "by accident"

      By accident that happened at the beginning of that topic. You created ENV_VAR as root, then added "become: false" to create a variable for centos user. Then you are reading ENV_VAR variable, but this is the root ENV_VAR, not centos one. To correct that, "become: false" should also be added to the "Get the value of an environment variable" task.

    3. Sad! that I missed this live series. But, I'm catching up on youtube. Bought the book and started chipping in on github. keep doing what you're doing. You're an inspiration, and I'll add most of your projects to my learning schedule. Good luck. Just got couple itchy questions about ansible as it relates to gns3. Hopefully answers shall come as droplets.

    4. New subscriber here!. Why am I missed out these live stream back in April 🙁
      Thanks for the excellent live stream upload by the way, will definitely buy the book on LeanPub once I got the money saved, haha.
      And lastly, congrats on the brand new laptop Jeff, totally awesome of device42 for sponsoring..

    5. Loving the live Ansible live streams, bought the Ansible for Devops book a few months ago (happy to of paid for it, and I hope that the people who can afford it in this climate have thrown a few $ your way). A question around your Molecule content, will it be around v3? Lots of things have changed from v2 like the default verifier changing to Ansible, which I can’t get my head around and I haven’t found any tutorials using the Ansible verifier. From watching all your recordings of your live streams it seems that people are interested in learning Molecule, is this worth having either a dedicated episode or couple of dedicated videos/live streams to?