Jump to content

Recommended Posts

This is often the case with devops tools.  Unless there is a company or core contributor behind it who wants to write one, there probably isn't going to be a book.  

Being written in Python, the better you understand Python, the more you'll understand Ansible basics, particularly in terms of the data types.  You also want to feel pretty comfortable with Yaml, given your playbooks are yaml files.

It's not my favorite way to try and learn a tool, but this is a really complete and well done video that covers Yaml (and probably some things that it allows for but you rarely see used) -> 

 

 

I will also say that for tools like this, I find you really want to have some ongoing problems you are trying to solve, because books or courses aren't guaranteed to match up with your particular needs.  What I did at the time (and I didn't know Python at all at that point) was to go through this Udemy class:  https://www.udemy.com/course/diveintoansible/

Just to be clear, I only buy Udemy courses during the times when they have their sales, and courses are $20 or less.  That course was very good.  The instructor provides a Docker based lab environment you work with, so you can follow along, experiment etc.  As I was already using Docker quite a bit, that was easy for me to work with, and at the time struck me as a great way to tackle things.  I also had a long history of unix system administration experience under my belt, and all of those fundamentals (things like ssh keys, and security, and how you set up servers etc), not to mention years of working with AWS, allowed me to absorb the material, discern how to start working with Ansible, and get things built with it.   

Even with all that being true, there were still many things that I had to figure out how to do on my own, but the course was really the dividing point for me of knowing Ansible existed (I'd used Puppet and a little bit of Chef previously) and believing it could be the basis of some automation tools I wanted to create, and actually writing/testing and using those playbooks.  

 

Just for the heck of it, here's one very simple playbook I wrote one day, that uses the yum package manager (used with redhat based distros) to update a group of servers.  This is so generic I can share it.  Obviously, most of it just comes from knowing I wanted to update server packages using yum, and googling "ansible yum module" seeing there was an existing module, and just scanning that.  

There's the boilerplate yaml file and comments I got from the course (which I have as a starter file I use when writing one), and you can see just the one task.  

---
# YAML documents begin with the document separator ---

# The minus in YAML this indicates a list item.  The playbook contains a list
# of plays, with each play being a dictionary
-
  # Hosts: where our play will run and options it will run with
  hosts: prod

  # Tasks: the list of tasks that will be executed within the playbook
  tasks:
    - name: Update installed packages
      become: yes
      become_method: sudo
      yum:
         name: '*'
         state: latest
      become_user: root
# Three dots indicate the end of a YAML document
...

 

So to conclude:  the fundamentals of Yaml and Ansible are fairly simple.  The power is in the modules, and you are going to read the module documentation at the point you already know that there's a particular tool you would otherwise be using to solve a problem.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.