Table of contents
1.
Introduction📒
2.
Ansible Playbook▶️
2.1.
Inventory in Ansible Playbook🧑‍💻
2.2.
Loops in Ansible Playbook➿
3.
Command Line in Ansible 2.9😄
4.
Collection Loader Changes in Ansible😇
5.
Modules in Ansible📳
5.1.
Renaming from _facts to _info in Ansible Modules🧑‍🏭
5.2.
Writing Modules in Ansible✍️
6.
Plugins in Ansible🔌
7.
Porting Custom Scripts in Ansible📚
7.1.
Networking in Porting Custom Scripts🌍
7.2.
Display Class in Porting Custom Scripts🏛️
8.
Networking in Ansible🌍
8.1.
Network Resource Module in Ansible🥅
8.2.
Ansible gather_facts support 📖
8.3.
Top Level Argument in Ansible Networking🎚️
9.
Frequently Asked Questions❓
9.1.
What are the requirements for Ansible Server?
9.2.
Is Ansible using Python?
9.3.
What does Ansible's host file mean?
10.
Conclusion🎯
Last Updated: Mar 27, 2024
Easy

Ansible 2.9 Porting Guide

Author Ayush Mishra
1 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Ansible 2.9 Porting Guide

Introduction📒

Ansible manages remote systems and configures them to the desired state. This Ansible 2.9 porting guide aims to compare and contrast versions 1.# and 2.0.

It's designed to help you update your Ansible playbooks, plugins, and other infrastructure components to work with the latest software version.

In this blog, we will discuss Ansible 2.9 Porting Guide in detail.

 

changes in Ansible 2.9

 

Ansible Playbook▶️

Ansible Playbooks are files that contain Ansible code. Playbooks are written in the YAML language. YAML is an abbreviation for Yet Another Markup Language. Playbooks are one of Ansible's core features that tell it what to do. They are similar to Ansible's to-do list in that they contain a list of tasks.

Inventory in Ansible Playbook🧑‍💻

Inventory in Ansible

In Ansible 2.9 Porting Guide, inventory sources are affected by hash_behaviour. If you have set it to merge, the data from Inventory may change, requiring you to update your playbooks. There will be no changes if you use the default setting (overwrite). This option was being ignored by Inventory.

Loops in Ansible Playbook➿

In Ansible 2.9 Porting Guide, Ansible now handles "unsafe" data more robustly, ensuring that data marked "unsafe" is not templated.

Ansible's previous version recursively marked all data returned by the lookup() as "unsafe." Even so, only structured data returned by with_X style loops was marked as "unsafe" if the returned elements were strings.

As a result, in Ansible 2.9, if you use with_dict to return keys with template values, your templates may no longer work as expected. To restore the previous behavior, change from with_X to loop.

Command Line in Ansible 2.9😄

In Ansible 2.9 Porting Guide, the Galaxy token file's location has been changed from /.ansible_galaxy to /.ansible/galaxy_token.

The GALAXY_TOKEN PATH config allows you to specify both the path and the file name.

Collection Loader Changes in Ansible😇

Ansible 2.9 Porting Guide's method for importing a PowerShell or C# module util from a collection has changed in Ansible 2.9.

Util with the following syntax was imported into Ansible 2.8:

#AnsibleRequires -CSharpUtil AnsibleCollections.namespace_name.collection_name.util_filename

#AnsibleRequires -PowerShell AnsibleCollections.namespace_name.collection_name.util_filename

 

Syntax of Util in Ansible 2.9:

#AnsibleRequires -CSharpUtil ansible_collections.namespace_name.collection_name.plugins.module_utils.util_filename

#AnsibleRequires -PowerShell ansible_collections.namespace_name.collection_name.plugins.module_utils.util_filename

Modules in Ansible📳

Ansible Modules.

 

Ansible modules are discrete code units used from the command line or in a playbook task. Modules in Ansible are also known as task plugins or library plugins.

Users may also create their own modules. These modules can manage services, system resources, files, and packages and execute system commands.

In Ansible 2.9 Porting Guide, changes in modules are:-

 🚀 The win_get_url and win_uri modules now send requests with ansible-httpget as the default User-Agent. The http_agent key can be used to change this.

 🚀 When installing its dependency, the apt Module now respects update_cache=false and skips the cache update. Setting update_cache=true explicitly or omitting the update_cache parameter will result in a cache update while installing its dependency.

 🚀 If you changed any tasks in 2.9.12 to specify less restrictive permissions, those changes will be obsolete in 2.9.13.

 🚀 To avoid the problem described in CVE-2020-1736, including a mode parameter in all file-based tasks that accept it.

 🚀 On file-based tasks where the user did not specify a mode parameter, Ansible version 2.9.12 changed the default mode to 0o600 & ~umask.

Renaming from _facts to _info in Ansible Modules🧑‍🏭

In Ansible 2.9 Porting Guide, modules do not return Ansible facts, and Ansible 2.9 renamed them from something>_facts to something>_info.

The configuration of a network interface, the Unix operating system, and the list of packages installed on a Windows machine are all examples of ansible facts.

The renamed modules produce results that are not specific to the host. For example, account information or region data from a cloud provider. Renaming these modules should clarify what types of return values each set of modules offers.

Writing Modules in Ansible✍️

In Ansible 2.9 Porting Guide, we will discuss the writing modules in Ansible.

✔️ Module and module_utils files can now include other module_utils files via relative imports. This helps condense long import lines, particularly in collections.

✔️ Ansible modules and module utils can also use relative imports, but the savings are smaller.

Plugins in Ansible🔌

Plugins in Ansible

Plugins in Ansible are pieces of code that extend the core functionality of Ansible. Ansible's feature set is rich, flexible, and expandable, thanks to its plugin architecture.

In Ansible 2.9 Porting Guide, Lookup plugins are removed.  

Porting Custom Scripts in Ansible📚

Ansible 2.9 Porting Guide has no changes in porting custom scripts.

Networking in Porting Custom Scripts🌍

The deprecated save and force parameters have been removed from the eos_config, ios _config and nxos_config modules. The save_when parameter now replicates its functionality.

The nxos_vrf af Module no longer includes the safi argument. This argument had had no effect on the Module since Ansible 2.4 when it was declared deprecated.

Display Class in Porting Custom Scripts🏛️

The Display class is now a "singleton," as in Ansible 2.9. Instead of using __main __.display, display, each file should import and instantiate Ansible.utils.display.

Networking in Ansible🌍

Networking in Ansible

 

Ansible is a well-known open-source network automation tool. They can configure your network stack, test and validate the current network state, and detect and correct network configuration drift.

Network Resource Module in Ansible🥅

Ansible 2.9 introduced the first group of network resource modules. Parts of a network device's configuration can be thought of as the device's resources. Network resource modules are designed to configure a single resource and can be combined to configure complex network services as building blocks.

Ansible gather_facts support 📖

In Ansible 2.9 Porting Guide, the gather_facts keyword now supports gathering network device facts in standardized key/value pairs. These network facts can be fed into additional tasks to manage the network device.

The new gather network resources parameter can also be used in conjunction with network *_facts modules to return only a subset of the device configuration.

Top Level Argument in Ansible Networking🎚️

The syntax for an older version of Top level argument in Ansible:

- name: example of using top-level options for connection properties
  ios_command:
    commands: show version
    host: "{{ inventory_hostname }}"
    username: cisco
    password: cisco
    authorize: yes
    auth_pass: cisco

 

Top-level arguments such as username, host, and password are removed from the Ansible 2.9 Porting Guide.

Change your playbooks in Ansible to the connection types network cli and netconf, and set those properties in Inventory by the group. As you update your playbooks in Ansible and inventory files, you can easily make the switch to become for privilege escalation.

Frequently Asked Questions❓

frequently Asked Questions

What are the requirements for Ansible Server?

Firstly, if you are a Windows user, you must have a virtual machine on which Linux is installed.

Secondly, it also requires Python 2.6 or higher.

Is Ansible using Python?

While Ansible modules can be written in any language, the majority of them, including the ones that make Ansible work, is written in Python. Ansible assumes by default that it can find a /usr/bin/python on your remote system that is either Python2, version 2.6 or higher, or Python3, version 3.5 or higher.

What does Ansible's host file mean?

In Ansible, host files are used to store data about distant nodes that we must manage. This file's path can be set anywhere by Ansible. It must, however, be specified in a configuration file or on the command line.

Conclusion🎯

Congratulations on finishing the blog! We have discussed Ansible 2.9 Porting Guide. We have further looked at the Playbooks, plugins, commands line, and networking in Ansible.

We hope this blog has helped you enhance your knowledge regarding the topic of Ansible 2.9 Porting Guide, and if you want to learn more, then you can check articles on:-

 

Please refer to our guided pathways on Code studio to learn more about DSACompetitive ProgrammingJavaScriptSystem Design, etc. Enroll in our courses, and use the accessible sample exams and questions as a guide. For placement preparations, look at the interview experiences and interview package.

Please do upvote our blogs if you find them helpful and informative!

Happy learning!
 

Thanking you for reading the blog.

 

Live masterclass