Getting started with Ansible 06 – Writing our first Playbook

34 Comments



Ansible is an incredible configuration management and provisioning utility that enables you to automate all the things. In this series, you’ll learn everything you need to know in order to use Ansible for your day-to-day administration duties. In video #6, we get started on writing playbooks, which is how we’ll use Ansible from here on out.

Full series:
Part 1 (Introduction): https://linux.video/ansible1
Part 2 (SSH Overview & Setup): https://linux.video/ansible2
Part 3 (Setting up the Git Repository): https://linux.video/ansible3
Part 4 (Running Commands): https://linux.video/ansible4
Part 5 (Running Elevated Commands): https://linux.video/ansible5
Part 6 (This video)
Part 7 (The “when” Conditional): https://linux.video/ansible7
Part 8 (Improving your Playbook): https://linux.video/ansible8
Part 9 (Targeting Specific Nodes): https://linux.video/ansible9
Part 10 (Tags): https://linux.video/ansible10
Part 11 (Managing Files): https://linux.video/ansible11
Part 12 (Managing Services): https://linux.video/ansible12
Part 13 (Adding Users & Bootstrapping): https://linux.video/ansible13
Part 14 (Roles): https://linux.video/ansible14
Part 15 (Host Variables): https://linux.video/ansible15
Part 16 (Templates): https://linux.video/ansible16

🙌 Support me on Patreon and get early access to new content!
➡️ https://learnlinux.link/patron

☁️ Get $100 in credit toward deploying your very own Linux servers on Linode!
➡️ http://linode.com/learnlinuxtv

🛒 Affiliate store for Linux compatible hardware/accessories (commission earned):
➡️ https://learnlinux.link/amazon

💻 Check out the Tiny Pilot KVM for your Homelab (commission earned):
➡️ https://learnlinux.link/tinypilot

💻 Check out Shells.com and spin up your very own Linux or Windows desktop in the cloud (commission earned):
➡️ https://learnlinux.link/shells

Wiki article for this video:
https://www.learnlinux.tv/getting-started-with-ansible-06-writing-our-first-playbook/

🐦 Follow me on Twitter!
➡️ https://learnlinux.link/twitter

💬 Official LearnLinux.tv Community:
➡️ https://community.learnlinux.tv

📖 Check out my latest book, Mastering Ubuntu Server 3rd Edition. Available now!
➡️ https://ubuntuserverbook.com

👨 More about me:
➡️ https://www.jaylacroix.com
➡️ https://www.learnlinux.tv/about-me

💽 How to create a bootable flash drive for installing Linux:
➡️ https://linux.video/flash-usb

🐧 Which distro do I use?
➡️ https://learnlinux.link/mydistro

🔐 How to better secure OpenSSH:
➡️ https://linux.video/secure-ssh

☁️ How to create a cloud Linux server with Linode:
➡️ https://learnlinux.link/create-linode

#AnsiblePlaybook #Ansible #LearnAnsible

source

34 Comments
    • blank
      Debashish Choudhuri
      May 12, 2022 00:45 am Reply

      legit content – well done and well presented

    • blank
      krishna rawat
      May 12, 2022 00:45 am Reply

      You are so awesome. Thanks for the video

    • blank
      kodi kodi
      May 12, 2022 00:45 am Reply

      this is a really great series. i never thought i could get this kind of quality instruction on youtube.

    • blank
      foosfighter
      May 12, 2022 00:45 am Reply

      What is this become password?

    • blank
      Langalafa Oriho
      May 12, 2022 00:45 am Reply

      I need more assistance learning ansible

    • blank
      Hung Nguyen
      May 12, 2022 00:45 am Reply

      For the amount of videos that I have been watching, none is better than Jay's. Bless you and your family.

    • blank
      Bashar Dlaleh
      May 12, 2022 00:45 am Reply

      playing your videos in 1.25 speed is perfect

    • blank
      Reza SadriNia
      May 12, 2022 00:45 am Reply

      What is the name of the bar at the bottom of tmux?

    • blank
      Bob A.
      May 12, 2022 00:45 am Reply

      Thanks Jay

    • blank
      George Smith
      May 12, 2022 00:45 am Reply

      Great. One comment: when you changed the state to absent to uninstall Apache, you should have probably change the name of the task (play) as well to read something like "Uninstall apache2 package"

    • blank
      mirzaindra
      May 12, 2022 00:45 am Reply

      i got this error when running the install_apache.yml:

      ERROR! 'task' is not a valid attribute for a Play

      The error appears to have been in '/home/mojo/ansible_test/install_apache.yml': line 3, column 3, but may
      be elsewhere in the file depending on the exact syntax problem.

      The offending line appears to be:

      – hosts: all
      ^ here

    • blank
      Walter Kelt
      May 12, 2022 00:45 am Reply

      One of the finest technical presentation series I've seen. Well done ! thank you

    • blank
      Osiel Ramirez
      May 12, 2022 00:45 am Reply

      I like how easily you explain the yaml basics, just enough for what we need in this video. Thanks to you I'm getting the hang of git commands and ansible!

    • blank
      TC
      May 12, 2022 00:45 am Reply

      at 12:30 he says 'let's add another play', but he should have said 'let's add another task'.

    • blank
      Josh URKI
      May 12, 2022 00:45 am Reply

      Great Job! Thank you so very much

    • blank
      Tarokh Yaghoubi
      May 12, 2022 00:45 am Reply

      You are amazing Jay " keep going "

    • blank
      Ibrahim Kabbash
      May 12, 2022 00:45 am Reply

      Man, you are seriously amazing. Thank you!

    • blank
      Mathew Kargarzadeh
      May 12, 2022 00:45 am Reply

      Dear Jay, your illustration of the first playbook was amazing. I loved it. Thank you again !!. Mat.

    • blank
      streamx2
      May 12, 2022 00:45 am Reply

      what is the become password

    • blank
      Robin A. Meade
      May 12, 2022 00:45 am Reply

      3:06 Did you add `become = True` to `ansible.cfg` like this:

      [privilege_escalation]
      become = True

      Why not add `become_ask_pass = True` there too?

    • blank
      Thành Vũ
      May 12, 2022 00:45 am Reply

      8:40 ok equals two, what does number two mean ?
      p/s :I understood, number two is the tasks

    • blank
      Volcker1929
      May 12, 2022 00:45 am Reply

      How dare you sir! Emacs is clearly superior. Sure, I had to have my left hand amputated due to crippling arthritis, but is is a small price to pay for the privilege of using the superior text editor.

    • blank
      Irsal Yunus
      May 12, 2022 00:45 am Reply

      hi sir,

      permission to ask there are tools such as ansible to manage mobile apps?? thanks

    • blank
      Albert Liu
      May 12, 2022 00:45 am Reply

      this guy is amazing, even better than the videos that i pay on udemy

    • blank
      Khalid Sattar
      May 12, 2022 00:45 am Reply

      Great introduction to Ansible. The depth and pace you adopt are just right. The section on ssh, git was very useful to have a great start in doing things the right way.

    • blank
      Amit Goel
      May 12, 2022 00:45 am Reply

      Thanks for sharing such amazing contents, very helpful to learn ansible.

    • blank
      pgh pete
      May 12, 2022 00:45 am Reply

      Thanks for the great series. Though I am not new to ansible, one can always learn something from others so I decided to watch them all.

      I know it may sound trivial, but I think it is an important correction, or at least something that should be conveyed.

      You refer to tasks within a play as plays. This may trip folks up if/when they ever test or go to certify on the topic.

      For example:

      # Simple playbook with two plays
      – name: name of first play
      hosts: all
      tasks:
      – name: name of first task
      <snip>
      – name: name of second task
      <snip>
      – name: name of second play
      – name: name of first task
      <snip>
      – name: name of second task
      <snip>

      In all honesty, most of us simply execute all of our items within a single play but as individual tasks… however I think its fairly important to distinguish the differences between plays and tasks. Another way to look at it is that the first, non-tabbed column are individual plays, everything indented underneath them is part of that play.

      I hope this just came through as a suggestion for completeness and not a nitpick. 🙂 Thanks again for taking the time to film, edit, and share your videos.

    • blank
      Liviu Navacioiu
      May 12, 2022 00:45 am Reply

      I may have misunderstood how Ansible works, but, still…, what's behind the ansible module? In playbooks we can use modules with their respective parameters, but what makes that module execute whatever it says it will execute on an agentless machine? What made the apt module do its job it there is nothing on the targeted machines to interpret that module and do whatever the module is intended to do, in this case to install a package using apt?

    • blank
      kjakobsen
      May 12, 2022 00:45 am Reply

      The indentation requirements makes my blood boil.

    • blank
      roy a
      May 12, 2022 00:45 am Reply

      Sir the writing format you are using in writing the playbook its a bit confusing as the alignments of sentences are having long spaces or hyphens is this standard change when writing long playbooks. I am new to this sort of thing i don't have any developer/coder background

    • blank
      Jean-Philippe Henry
      May 12, 2022 00:45 am Reply

      "I won't judge you even if it's emacs", lol, you killed me
      Thank you so much for your work. Know that it helps a lot demystifying Ansible.

    • blank
      Ozmo Syd
      May 12, 2022 00:45 am Reply

      Going through the series. And have to say … Love ya work chap.

    • blank
      Hossein Vahedi
      May 12, 2022 00:45 am Reply

      This playlist is amazing!

    • blank
      seocamo
      May 12, 2022 00:45 am Reply

      why compare nano and vim with emacs … nano and vim is text editors and emacs is a OS … how can you compare this ?

Leave us a comment