Ansible 101 – Episode 3 – Introduction to Playbooks

39 Comments



Jeff Geerling (geerlingguy) dives deeper into Ansible, exploring the basic unit of automation, Ansible Playbooks.

This episode will follow material from chapters 3 and 4 in the bestselling Ansible book, Ansible for DevOps.

Buy Ansible for DevOps: https://www.ansiblefordevops.com

Sponsor Jeff on GitHub: https://github.com/sponsors/geerlingguy
Support Jeff on Patreon: https://www.patreon.com/geerlingguy

Contents:

00:00:00 – Intro
00:04:25 – Questions from last episode
00:08:20 – Multi-host ad-hoc orchestration
00:19:02 – Using different modules ad-hoc
00:24:38 – Intro to Playbooks
00:28:18 – Comparing to shell scripts
00:32:35 – Moving commands into YAML playbooks
00:39:28 – Making playbooks more Ansible-ish
00:53:02 – Running the Apache playbook
00:56:24 – Limiting playbook runs to specific servers
01:00:14 – Outtro

source

39 Comments
    • blank
      Computer Freak CH
      May 10, 2022 13:03 pm Reply

      So the British say "Add hawk come end"?

    • blank
      Hank Barta
      May 10, 2022 13:03 pm Reply

      Beautiful Sunny Winfield (IL) Thanks! (Not watching live.)

    • blank
      Simon Summermatter
      May 10, 2022 13:03 pm Reply

      The post with the link doesn't seem to work. You find the article with the title: "Running Virtual Machines Under Vagrant on the New Mac M1"

    • blank
      Simon Summermatter
      May 10, 2022 13:03 pm Reply

      Hi Jeff. Love your content. I found the approach from James Cundle on Medium to solve the problem "missing virtualbox on Apple Silicon". I will paste the Link in a following comment (YouTube usually hinders me to post links). Does anyone has a better solution?

    • blank
      Richie Yeo
      May 10, 2022 13:03 pm Reply

      Awesome sharing. We will support you from Singapore.

    • blank
      Manazil – منازل
      May 10, 2022 13:03 pm Reply

      14:00

    • blank
      Minecraft Chest1
      May 10, 2022 13:03 pm Reply

      I don't like YAML because it makes you use spaces.

    • blank
      Klappspaten
      May 10, 2022 13:03 pm Reply

      "If I hit 10.000 before this pandemic thing is over…"
      It's almost 2022, you're at 250.000, and the pandemic ist STILL not over!

    • blank
      Anthony Russano
      May 10, 2022 13:03 pm Reply

      Thank you x100000000 Jeff

    • blank
      George Leonard
      May 10, 2022 13:03 pm Reply

      you just mentioned something, for some reason I thought vagrant only executed against VBox, you saying it can also work against something like VMWare Fusion ? … having to look at alternate VM platform due to planned MBP upgrade and VBox at the moment not looking like it has a Apple future.

    • blank
      RetconTV
      May 10, 2022 13:03 pm Reply

      I just want to point out (as well as thanking you for this series) that you mentioned hitting 7500 subs, and were aiming for 10K, hopefully when the pandemic ends.

      A year and a half later, we still have the pandemic, but you have definitely met your goal and then some, at 225K! Love your content, both the educational as well as the entertaining content!

    • blank
      xavier tichoux
      May 10, 2022 13:03 pm Reply

      Thanks!

    • blank
      xavier tichoux
      May 10, 2022 13:03 pm Reply

      Thanks!

    • blank
      SnoopDaDoop
      May 10, 2022 13:03 pm Reply

      Jeff I bought your book and have been following along with your videos. I never comment, but just wanted to say your videos and books are top notch. Keep up the good work, and keep making videos!

    • blank
      Mathew Kargarzadeh
      May 10, 2022 13:03 pm Reply

      Thanks Jeff !!. appreciate your time posting this. you are the Man !!

    • blank
      Olli Graf
      May 10, 2022 13:03 pm Reply

      Running "date" as adhoc command helped me to identify the raspis where timezone was not correctly set.

    • blank
      GrahamAtDesk
      May 10, 2022 13:03 pm Reply

      Great series Jeff, thanks!

    • blank
      Raza Hussain
      May 10, 2022 13:03 pm Reply

      at the 37:00 mark why did you use a "-" by the second command argument but not the first?

    • blank
      MrBrownpotato
      May 10, 2022 13:03 pm Reply

      I feel the terms "playbook", "play" and "task" are not the best choice for something that is supposed to describe desired state

    • blank
      domemvs
      May 10, 2022 13:03 pm Reply

      Watching this as he has 118k subs. Awesome! Well deserved!

    • blank
      Martin Müsli
      May 10, 2022 13:03 pm Reply

      New Year, 2021, your stuff is still relevant to me 🙂 Keep it up

    • blank
      Angel Gutierrez
      May 10, 2022 13:03 pm Reply

      who could actually dislike these type of videos? I mean these videos are very good and very educational as well!

    • blank
      José Aliaga Giacosa
      May 10, 2022 13:03 pm Reply

      please, make a t-shirt saying "i don't know when the stream ends – it will probably cut me mid-sentence" lol

    • blank
      Jamall Mahmoudi
      May 10, 2022 13:03 pm Reply

      Thanks a lot …..

    • blank
      Abhinav’s Space
      May 10, 2022 13:03 pm Reply

      At 15:50,
      for those who are watching this stream,
      If you run this command: [RHEL 7.8]
      ansible -i inventory multi -b -B 3600 -P 0 -m "yum -y update"
      ERROR! this task 'yum' has extra params, which is only allowed in the following modules: include_role, command, raw, include_vars, add_host, set_fact, win_command, shell, meta, include, group_by, include_tasks, import_tasks, script, import_role, win_shell

      To overcome this error, run this
      ansible -i inventory multi -b -B 3600 -P 0 -m command -a "yum -y update"

    • blank
      Peter Gebirgslok
      May 10, 2022 13:03 pm Reply

      For those, who are trying this in Ubuntu / Debian:

      The Playbook looks like this.
      tasks:
      – name: Install Apache
      apt:
      name:
      – apache2
      state: present

      – name: Copy Config File
      copy:
      src: "{{ item.src }}"
      dest: "{{ item.dest }}"
      owner: root
      group: root
      mode: 0644
      with_items:
      – src: apache2.conf
      dest: /etc/apache2/apache2.conf
      – src: site1.conf
      dest: /etc/apache2/sites-available/site1.conf

      – name: Ensure Apache is started
      service:
      name: apache2.service
      state: started
      enabled: true

    • blank
      Animesh Gupta
      May 10, 2022 13:03 pm Reply

      Just bought your book from Amazon.

    • blank
      prakash mirji
      May 10, 2022 13:03 pm Reply

      awesome tutorial…thank you for doing this

    • blank
      StormWolf01
      May 10, 2022 13:03 pm Reply

      Great tutorial, thanks a lot.
      To anyone who doesn't have access to an EC2 instance, just just launch a VM with vagrant, as shown in the previous tutorial, and have the ansible playbook executed on that VM. This seems pretty obvious, but it took me 10 minutes to realize.

    • blank
      StrikeSwiftly
      May 10, 2022 13:03 pm Reply

      Great job Jeff. Little Mermaid story brought back memories with my Daughter back in the day !!

    • blank
      Gaurav Pandey
      May 10, 2022 13:03 pm Reply

      Great work Jeff, thanks for the lessons. 😊

    • blank
      Branimir Braykov
      May 10, 2022 13:03 pm Reply

      Hey, you are doing an amazing job. This is the perfect companion to your book, which I just bought and started reading a month ago.
      I only have a small request. For the next sessions, could you keep the terminal window just a bit higher (at least the bottom edge)? I am pausing to read your command line and youtube's progress bar is coming just above the prompt 🙂

    • blank
      Naeem Arshad
      May 10, 2022 13:03 pm Reply

      Hi Jeff, Thanks for putting some nice work up here. I really appreciate it, it could really benefit me in many wayas.

    • blank
      Dylan Kumar
      May 10, 2022 13:03 pm Reply

      Thanks so much for these!

    • blank
      Alyson Whitaker
      May 10, 2022 13:03 pm Reply

      Question: what theme/settings are you using in Sublime? I like how your space is highlighted when typing your code. I think getting the yaml syntax with the correct spacing is the most difficult part of using Ansible! 🙂

    • blank
      Jon Pugh
      May 10, 2022 13:03 pm Reply

      Hi! These are fun…

    • blank
      Michael Nelson
      May 10, 2022 13:03 pm Reply

      Great work Jeff, even if I already do lots of advanced things with Ansible and AWX, this is still helpful. Keep it up.

    • blank
      William Crowell
      May 10, 2022 13:03 pm Reply

      Really great session Jeff.

Leave us a comment