Ansible
Introduction

Ansible Automation Platform has grown over the past years to provide powerful automation solutions that work for operators, administrators and IT decision makers across a variety of technology domains. It’s a leading enterprise automation solution from Red Hat®, a thriving open source community, and the de facto standard technology of IT automation.

Ansible Automation Platform includes certified Content Collections for a variety of vendor networking solutions, helping you deliver automation more quickly with trusted, reusable automation. Certified content collections are developed and delivered by Red Hat and partners (including Cisco ) and are supported as part of a RedHat subscription. In addition to fully certified automation content provided through your Red Hat subscription, Ansible Galaxy allows automators to test, learn and share community-led automation content.

You will be using the embedded terminal window for this page:

Python

Python was conceived into this world in the late 80's by Guido van Rossum in the Netherlands. It has gained momentum over the years in many scientific circles due to it's magnificent mathematical libraries that have performance that rivals compiled languages like C. As time passed Python has also become the default scripting language in many technology areas including networking.

That popularity was primordially pushed by Google over the years. Python appeals to programmers that come from a C background and that was on purpose, as something that originally Guido attempted to accomplish.

Yet, before we install packages we want to utilize a very powerful framework that exists for Python called virtual environments. Virtual environments make it possible to install specific versions of packages in a way that your application requirements don't affect another application requirement. For example, if you have requirements for a specific version of a software development kit (SDK) or software package that is matched to your application, you want to only have that setup for your application. If another application needs a different version of the same SDK, virtual environments make it possible.

Step 1 - Install Python 3.9.11 with pyenv

Whenever you wish to run Ansible you have to setup the python environment to work with it. In python world you could just install everything to the system level ( think as you where installing an application for everyone in the system ) or you can install it creating what is known as a virtual environment.

Python virtual environments allow for easy packaging of the requirements that specific python code needs to run. For example you can install different versions of Ansible in different virtual environments for many reasons. You could have some automation that you know works with a specific version and you don't wish to gamble that it would work in a newer release.


pyenv install 3.9.11

Once this step is completed you will be able to see that this vesion is now available for pyenv.


pyenv versions

* system (set by /home/pod04/.pyenv/version)
  3.9.11

Step 2 - Configure global version of python

This will tell the system to default to this version of python outside of the virtual environment.


pyenv global 3.9.11

Step 3 - Create virtual environment with PyENV

With the right version of python installed, now you will create a python virtual environment around this version of python.


pyenv virtualenv 3.9.11 ansible

Step 4 - Create ansible directory

Create the directory for all our ansible code.


cd ~/ltrdcn-3225/ansible

Step 5 - Create local python definition inside ansible directory

Create the directory for all our ansible code.


pyenv local ansible

And with that by being inside of this directory and its children the virtual environmet will be activated. You can see this with the command pyenv versions


pyenv versions

  system
  3.9.11
  3.9.11/envs/ansible
* ansible (set by /home/pod04/ansible/.python-version)

PIP

PIP is a package management system for Python. It allows you to install and manage packages that are outside of the standard python library. Many packages are made available by the community of Python developers are available in PyPi. You will be using PIP in this lab to install some of these additional packages for Python including Ansible and requests.

Step 6 - Install Ansible in your virtual environment

Now you will be using the pip package installer to install ansible in your virtual environmet.


pip install ansible==5.7.0

Once complete you can then start using ansible. But first we have to install some additional packages to make everything work for ACI.

Step 7 - Install Cisco ACI Ansible collection

Now you will be using the pip package installer to install ansible in your virtual environmet.


ansible-galaxy collection install cisco.aci

And just like that we are ready to start building connections to the ACI fabric.