Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Ansible for Real-Life Automation

You're reading from  Ansible for Real-Life Automation

Product type Book
Published in Sep 2022
Publisher Packt
ISBN-13 9781803235417
Pages 480 pages
Edition 1st Edition
Languages
Concepts
Author (1):
Gineesh Madapparambath Gineesh Madapparambath
Profile icon Gineesh Madapparambath

Table of Contents (22) Chapters

Preface 1. Part 1: Using Ansible as Your Automation Tool
2. Chapter 1: Ansible Automation – Introduction 3. Chapter 2: Starting with Simple Automation 4. Chapter 3: Automating Your Daily Jobs 5. Chapter 4: Exploring Collaboration in Automation Development 6. Part 2: Finding Use Cases and Integrations
7. Chapter 5: Expanding Your Automation Landscape 8. Chapter 6: Automating Microsoft Windows and Network Devices 9. Chapter 7: Managing Your Virtualization and Cloud Platforms 10. Chapter 8: Helping the Database Team with Automation 11. Chapter 9: Implementing Automation in a DevOps Workflow 12. Chapter 10: Managing Containers Using Ansible 13. Chapter 11: Managing Kubernetes Using Ansible 14. Chapter 12: Integrating Ansible with Your Tools 15. Chapter 13: Using Ansible for Secret Management 16. Part 3: Managing Your Automation Development Flow with Best Practices
17. Chapter 14: Keeping Automation Simple and Efficient 18. Chapter 15: Automating Non-Standard Platforms and Operations 19. Chapter 16: Ansible Automation Best Practices for Production 20. Index 21. Other Books You May Enjoy

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 2022 Publisher: Packt ISBN-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.
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}