Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Learning Ansible 2.7
Learning Ansible 2.7

Learning Ansible 2.7: Automate your organization's infrastructure using Ansible 2.7 , Third Edition

Arrow left icon
Profile Icon Fabio Alessandro Locati
Arrow right icon
€15.99 €23.99
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.7 (3 Ratings)
eBook Apr 2019 266 pages 3rd Edition
eBook
€15.99 €23.99
Paperback
€29.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Fabio Alessandro Locati
Arrow right icon
€15.99 €23.99
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.7 (3 Ratings)
eBook Apr 2019 266 pages 3rd Edition
eBook
€15.99 €23.99
Paperback
€29.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€15.99 €23.99
Paperback
€29.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
Table of content icon View table of contents Preview book icon Preview Book

Learning Ansible 2.7

Getting Started with Ansible

Information and communications technology (ICT) is often described as a fast-growing industry. I think that the best quality of the ICT industry is not related to its ability to grow at a super-high speed, but is related to its ability to revolutionize itself, and the rest of the world, at an astonishing pace.

Every 10 to 15 years there are major shifts in how this industry works, and every shift solves problems that were very hard to manage up to that point, creating new challenges. Also, at every major shift, many of the best practices of the previous iteration are classified as anti-patterns, and new best practices are created. Although it might appear that those changes are impossible to predict, this is not always true. Obviously, it is not possible to know exactly what changes will occur and when they will take place, but looking at companies...

Technical requirements

To support the learning of Ansible, I suggest having a machine where you can install Vagrant. Using Vagrant will allow you to try many operations, even destructive ones, without fear.

Additionally, AWS and Azure accounts are suggested, since some examples will be on those platforms.

All examples in this book are available in the GitHub repository at https://github.com/PacktPublishing/-Learning-Ansible-2.X-Third-Edition/.

IT automation

IT automation is – in its broader sense – the processes and software that help with the management of the IT infrastructure (servers, networking, and storage). In the current shift, we are supporting for a huge implementation of such processes and software.

At the beginning of IT history, there were very few servers, and a lot of people were needed to make them work properly, usually more than one person for each machine. Over the years, servers became more reliable and easier to manage, so it was possible to have multiple servers managed by a single system administrator. In that period, the administrators manually installed the software, upgraded the software manually, and changed the configuration files manually. This was obviously a very labor-intensive and error-prone process, so many administrators started to implement scripts and other means to...

What is Ansible?

Ansible is an agent-less IT automation tool developed in 2012 by Michael DeHaan, a former Red Hat associate. The Ansible design goals are for it to be minimal, consistent, secure, highly reliable, and easy to learn. The Ansible company was bought by Red Hat in October 2015, and now operates as part of Red Hat, Inc.

Ansible primarily runs in push mode using SSH, but you can also run Ansible using ansible-pull, where you can install Ansible on each agent, download the playbooks locally, and run them on individual machines. If there are a large number of machines (large is a relative term; but in this case, consider it to mean greater than 500), and you plan to deploy updates to the machines in parallel, this might be the right way to go about it. As we discussed before, either agent-full and agent-less systems have their pros and cons.

In the next section, we will...

Why Ansible?

We will try and compare Ansible with Puppet and Chef during the course of this book, since many people have good experience those tools. We will also point out specifically how Ansible would solve a problem compared to Chef or Puppet.

Ansible, as well as Puppet and Chef, are declarative in nature, and are expected to move a machine to the desired state specified in the configuration. For example, in each of these tools, in order to start a service at a point in time and start it automatically on restart, you would need to write a declarative block or module; every time the tool runs on the machine, it will aspire to obtain the state defined in your playbook (Ansible), cookbook (Chef), or manifest (Puppet).

The difference in the toolset is minimal at a simple level, but as more situations arise and the complexity increases, you will start finding differences between...

Installing Ansible

Installing Ansible is rather quick and simple. You can use the source code directly, by cloning it from the GitHub project (https://github.com/ansible/ansible); install it using your system's package manager; or use Python's package management tool (pip). You can use Ansible on any Windows or Unix-like system, such as macOS and Linux. Ansible doesn't require any databases, and doesn't need to have any daemons running. This makes it easier to maintain Ansible versions and upgrade without any breaks.

We'd like to call the machine where we will install Ansible our Ansible workstation. Some people also refer to it as the command center.

Installing Ansible using the system's package manager

...

Creating a test environment with Vagrant

To be able to learn Ansible, we will need to make quite a few playbooks and run them.

Doing this directly on your computer will be very risky. For this reason, I would suggest using virtual machines.

It's possible to create a test environment with cloud providers in a few seconds, but it is often more useful to have those machines locally. To do so, we will use Vagrant, which is a piece of software by Hashicorp that allows users to quickly set up virtual environments independently from the virtualization backend used on the local system. It does support many virtualization backends (in the Vagrant ecosystem these are known as Providers) such as Hyper-V, VirtualBox, Docker, VMWare, and libvirt. This allows you to use the same syntax no matter what operating system or environment you are in.

First we will install vagrant. On Fedora,...

Version control systems

In this chapter, we have already encountered the expression infrastructure code to describe the Ansible code that will create and maintain your infrastructure. We use the expression infrastructure code to distinguish it from the application code, which is the code that composes your applications, websites, and so on. This distinction is needed for clarity, but in the end, both types are a bunch of text files that the software will be able to read and interpret.

For this reason, a version control system will help you a lot. Its main advantages are as follows:

  • The ability to have multiple people working simultaneously on the same project.
  • The ability to perform code-reviews in a simple way.
  • The ability to have multiple branches for multiple environments (that is, dev, test, QA, staging, and production).
  • The ability to track a change so that we know when...

Using Ansible with Git

For the reasons that we have just seen, and because of its huge popularity, I suggest always using Git for your Ansible repositories.

There are a few suggestions that I always provide to the people I talk to, so that Ansible gets the best out of Git:

  • Create environment branches: Creating environment branches, such as dev, prod, test, and stg, will allow you to easily keep track of the different environments and their respective update statuses. I often suggest keeping the master branch for the development environment, since I find that many people are used to pushing new changes directly to the master. If you use a master for a production environment, people can inadvertently push changes in the production environment when they wanted to push them in a development environment.
  • Always keep environment branches stable: One of the big advantages of having...

Summary

In this chapter, we have seen what IT automation is, its advantages and disadvantages, what kind of tools you can find, and how Ansible fits into this big picture. We have also seen how to install Ansible and how to create a Vagrant virtual machine. In the end, we analyzed the version control systems and spoke about the advantages Git brings to Ansible, if used properly.

In the next chapter, we will start looking at the infrastructure code that we mentioned in this chapter, without explaining exactly what it is and how to write it. We'll also see how to automate simple operations that you probably perform every single day, such as managing users, managing files, and file content.

Left arrow icon Right arrow icon

Key benefits

  • Get familiar with the fundamentals of Ansible 2.7
  • Understand how to use Ansible Tower to scale your IT automation
  • Gain insights into how to develop and test Ansible playbooks

Description

Ansible is an open source automation platform that assists organizations with tasks such as application deployment, orchestration, and task automation. With the release of Ansible 2.7, even complex tasks can be handled much more easily than before. Learning Ansible 2.7 will help you take your first steps toward understanding the fundamentals and practical aspects of Ansible by introducing you to topics such as playbooks, modules, and the installation of Linux, Berkeley Software Distribution (BSD), and Windows support. In addition to this, you will focus on various testing strategies, deployment, and orchestration to build on your knowledge. The book will then help you get accustomed to features including cleaner architecture, task blocks, and playbook parsing, which can help you to streamline automation processes. Next, you will learn how to integrate Ansible with cloud platforms such as Amazon Web Services (AWS) before gaining insights into the enterprise versions of Ansible, Ansible Tower and Ansible Galaxy. This will help you to use Ansible to interact with different operating systems and improve your working efficiency. By the end of this book, you will be equipped with the Ansible skills you need to automate complex tasks for your organization.

Who is this book for?

This beginner-level book is for system administrators who want to automate their organization's infrastructure using Ansible 2.7. No prior knowledge of Ansible is required

What you will learn

  • Create a web server using Ansible
  • Write a custom module and test it
  • Deploy playbooks in the production environment
  • Troubleshoot networks using Ansible
  • Use Ansible Galaxy and Ansible Tower during deployment
  • Deploy an application with Ansible on AWS, Azure and DigitalOcean

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Apr 30, 2019
Length: 266 pages
Edition : 3rd
Language : English
ISBN-13 : 9781789950007
Vendor :
Red Hat
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning

Product Details

Publication date : Apr 30, 2019
Length: 266 pages
Edition : 3rd
Language : English
ISBN-13 : 9781789950007
Vendor :
Red Hat
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 181.97
Practical Ansible Solutions
€118.99
Mastering Ansible
€32.99
Learning Ansible 2.7
€29.99
Total 181.97 Stars icon

Table of Contents

17 Chapters
Section 1: Creating a Web Server Using Ansible Chevron down icon Chevron up icon
Getting Started with Ansible Chevron down icon Chevron up icon
Automating Simple Tasks Chevron down icon Chevron up icon
Section 2: Deploying Playbooks in a Production Environment Chevron down icon Chevron up icon
Scaling to Multiple Hosts Chevron down icon Chevron up icon
Handling Complex Deployment Chevron down icon Chevron up icon
Going Cloud Chevron down icon Chevron up icon
Getting Notification from Ansible Chevron down icon Chevron up icon
Section 3: Deploying an Application with Ansible Chevron down icon Chevron up icon
Creating a Custom Module Chevron down icon Chevron up icon
Debugging and Error Handling Chevron down icon Chevron up icon
Complex Environments Chevron down icon Chevron up icon
Section 4: Deploying an Application with Ansible Chevron down icon Chevron up icon
Introducing Ansible for Enterprises Chevron down icon Chevron up icon
Getting Started with AWX Chevron down icon Chevron up icon
Working with AWX Users, Permissions, and Organizations Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.7
(3 Ratings)
5 star 33.3%
4 star 0%
3 star 0%
2 star 33.3%
1 star 33.3%
Mike R. Mar 14, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Comprehensive yet simple
Amazon Verified review Amazon
SirM Aug 31, 2019
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
One can tell from introduction going forward the author did not in anyway rely much on readers feedback from previous edition thus you have the same introductory formula in writing style applied. The author assumes the readers somehow have an ideal setup like he does whereby when using vagrant you have ssh issues, does not indicate whether he uses global or local inventory file and thus you have to fill-in the gaps via google search. Literally the material is hard to digest thus a greater balance of understanding will depend on the user investing their time on official ansible docs. A half baked effort that is not engaging, could have been better.
Amazon Verified review Amazon
Sp3c1 May 17, 2020
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
I bought the book since this is fairly recent, ansible 2.9 is the current version. I first considered ansible up and running from O'Reilly Press but that book is a little bit aged and reviews said that it great but it should be updated to a new edition soon. This is why I landed on this book. Unfortunately, I feel I learned not a whole lot from this book. The Author is giving examples but is failing to explain these. Or I was unable to follow as good. Also, the author is half helping with the vagrant setup, It took me a couple of hours to have a working environment with vagrant since I had to research a whole bunch. I would have liked a better thought through examples. In fact, after this book, I have read the extract from ansible up and running which is containing the first two chapters. Which explained vagrant in a far better way and how I can get started.I am missing for whom this book is written because I feel the examples are really basic but the missing of explanations I would assume it's for more advanced users. I guess this book is missing some kind of clear concept. Sometimes the Author is touching onto topics that seem completely out of place at that moment.I recently purchased jeff Geerling's Ansible for DevOps ebook which is regularly updated so it is really current, and it fits me a lot more. Since the Author is really clear about what he is trying to achieve.Unfortunately, I missed the date to give the kindle version back of this book.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.