Reader small image

You're reading from  Ansible for Real-Life Automation

Product typeBook
Published inSep 2022
PublisherPackt
ISBN-139781803235417
Edition1st Edition
Concepts
Right arrow
Author (1)
Gineesh Madapparambath
Gineesh Madapparambath
author image
Gineesh Madapparambath

Gineesh Madapparambath has over 15 years of experience in IT service management and consultancy with experience in planning, deploying, and supporting Linux-based projects. He has designed, developed, and deployed automation solutions based on Ansible and Ansible Automation Platform (formerly Ansible Tower) for bare metal and virtual server building, patching, container management, network operations, and custom monitoring. Gineesh has coordinated, designed, and deployed servers in data centers globally and has cross-cultural experience in classic, private cloud (OpenStack and VM ware), and public cloud environments (AWS, Azure, and Google Cloud Platform). Gineesh has handled multiple roles such as systems engineer, automation specialist, infrastructure designer, and content author. His primary focus is on IT and application automation using Ansible, containerization using OpenShift (and Kubernetes), and infrastructure automation using Terraform.
Read more about Gineesh Madapparambath

Right arrow

Exploring Collaboration in Automation Development

When you work as a team, collaboration is the key to your team’s harmony. Instead of keeping your automation content and knowledge to yourself, you can share it with your team, or even other departments. By doing that, the content will be useful to many others and also, they can contribute with their own ideas and tips. Compared to custom scripts, Ansible content is human-readable and easy for others to understand. Hence, they can modify it and later contribute to the content by fixing bugs or adding features. It is possible to use any standard methods to keep and distribute your Ansible automation content, such as a Git server, Subversion, or any other Version Control System (VCS).

In this chapter, you will learn about the following topics:

  • The importance of version control in IT automation
  • Where should I keep automation artifacts?
  • Managing automation content in a Git server
  • Collaboration is the key...

Technical requirements

The following are the technical requirements to proceed with this chapter:

  • One Linux machine for the Ansible control node.
  • One or more Linux machines with Red Hat repositories configured (if you are using other Linux operating systems instead of RHEL machines, then make sure you have appropriate repositories configured to get packages and updates).
  • An email ID to create a new GitHub account (if you don’t already have a GitHub account).
  • Basic knowledge about source control server and version control systems.

All the Ansible code, Ansible playbooks, commands, and snippets for this chapter can be found in the GitHub repository at https://github.com/PacktPublishing/Ansible-for-Real-life-Automation/tree/main/Chapter-04.

The importance of version control in IT automation

Like any other software, configurations, or scripts, it is not a best practice to keep your Ansible playbooks and configurations on the local machine, which is the Ansible control node. There are many reasons for not keeping the automation content on the local Ansible control node. A few of them are listed here:

  • If something happens to the Ansible control node, you will lose all your automation content, which is not desirable.
  • If someone accidentally deletes any files or changes any configurations, you will not have the opportunity to restore the original content.
  • If you want to make any changes to configurations or playbooks, then you need to make a backup of files and configurations. This is general practice in case something goes wrong and you want to restore an old version of your files.

You need to consider the Ansible automation content as software code, which should keep track of every change and have...

Where should I keep automation artifacts?

Keep your playbooks and configurations in multiple Git repositories based on the automation and content type.

Ansible and Git repositories – best practices

There are many best practices for keeping your Ansible automation content in a VCS.

Repository for Ansible roles

If you are creating Ansible roles alone (it is no longer common to create individual roles for distribution without a collection), then create one Git repository per role so that the development and collaboration will be easy without depending on other tasks and configurations. See the sample ansible-role repositories in Figure 4.1.

Figure 4.1 – Separate repositories for Ansible roles

Repositories for Ansible collections

If you are creating Ansible collections, then create one Git repository per collection to make the development and management easy. Move your existing Ansible roles, libraries, modules, and other plugins...

Managing automation content in a Git server

In this section, you will learn how to create a GitHub (github.com) account, create, install, and configure the repositories, and keep Ansible automation content inside the repositories.

Setting up a GitHub account

If you already have a GitHub personal or enterprise account, then you can skip the account creation steps:

  1. Open your web browser and go to github.com, then click the Signup button in the top-right corner of the page.
  2. Enter your email address and a password and username on the next screen, as shown in Figure 4.4. GitHub will tell you whether the username is available as usernames in GitHub must be unique:

Figure 4.4 – Creating a GitHub account

  1. Click Continue and finish the simple puzzle (CAPTCHA) on the next screen to verify your identity. Once done, create your account.
  2. On the next screen, GitHub will ask you for the one-time code that you will receive on your registered...

Collaboration is the key to automation

Now you have your Ansible automation content in your GitHub repository. There are several advantages to this:

  • You do not need to take a backup of your files before you make changes (once you make the changes, remember to test, commit, and push the changes to a remote GitHub repository).
  • Pull the content to any of the machines whenever needed and test it. For example, you can download the code to your local workstation and develop it further. Once you make the changes, push it back to the remote repository; a new version of the code will be stored there.
  • Other users and developers can test and contribute to your code without having access to your Ansible control node. You just need to allow appropriate access to other users.
  • If any of the code is not working after an update, you can revert to an old version of the code at any point in time.

Let’s learn how to use Git branching in the next session.

Using Git...

Summary

In this chapter, you have learned the importance of version control in an IT automation environment. You have learned the basics of Git and different Git servers and providers. You have practiced creating a GitHub account, Git repository, and other steps. You also learned how to accept contributions to your Git content, branching methods, and PR processes.

In the next chapter, you will learn how to find more automation use cases from your workplace and personal projects. You will also learn more about inventory management and different strategies to keep your managed nodes’ information.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Ansible for Real-Life Automation
Published in: Sep 2022Publisher: PacktISBN-13: 9781803235417
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Gineesh Madapparambath

Gineesh Madapparambath has over 15 years of experience in IT service management and consultancy with experience in planning, deploying, and supporting Linux-based projects. He has designed, developed, and deployed automation solutions based on Ansible and Ansible Automation Platform (formerly Ansible Tower) for bare metal and virtual server building, patching, container management, network operations, and custom monitoring. Gineesh has coordinated, designed, and deployed servers in data centers globally and has cross-cultural experience in classic, private cloud (OpenStack and VM ware), and public cloud environments (AWS, Azure, and Google Cloud Platform). Gineesh has handled multiple roles such as systems engineer, automation specialist, infrastructure designer, and content author. His primary focus is on IT and application automation using Ansible, containerization using OpenShift (and Kubernetes), and infrastructure automation using Terraform.
Read more about Gineesh Madapparambath