Management of F5 via Ansible complete process adding a host defining the variables and testing it-Part1




Well for the first time I had interaction with Ansible back in 2017 at that time I did't knew how to spell it properly, Thanks to Google it gives me result by guessing it. In between I didn't use ansible at all till now. This time I need to use ansible for the automation of operations task on F5 and other network devices. I have started by installing the ansible on my virtual machine and enable SSH communication in between them. Further below mentioned are the steps for deploying ansible and then doing other setting for the first playbook to be run on F5.

Installation of Ansible

For different Linux flavors we do have different commands you can search it over the internet as per your requirements

yum -y install ansible    

ansible --version

ansible 2.9.25

config file = /etc/ansible/ansible.cfg

 configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']

  ansible python module location = /usr/lib/python2.7/site-packages/ansible

  executable location = /bin/ansible

  python version = 2.7.5

 Now as ansible is install and we can see the version of it, we can move forward before going to next step make sure your working directory for ansible is /etc/ansible there will be default hosts file in this directory.

you can check it by doing ls in directory /etc/ansible

I will create another inventory file (hosts file) and will use it to define the F5 host which need to be managed via ansible.

nano inventory
You will be prompt with a black screen, and you need to define the host group and IP into it.

[F5]
192.168.1.100

We have added a F5 node in our ansible inventory file we can verify it.

ansible-inventory -i inventory --list

{

    "F5": {

        "hosts": [

            "192.168.1.100"

        ]

    },

    "_meta": {

        "hostvars": {}

    },

    "all": {

        "children": [

            "F5",

            "ungrouped"

        ]

    }

}

We can define the variables here for SSH access to the host and also, we can generate ssh-keys and copy it to the host for passwordless SSH connectivity for ansible command execution but this time i have use another file in which i have define my variables and ansible will use it for connectivity for the host in group of F5.

I have created a directory with name group_vars and have variable for each group within the inventory file.
  
mkdir group_vars

nano F5.yml

ansible_user= "username"
ansible_password: "Password"
ansible_port: 22

So till now we have setup the connectivity between ansible host and F5, please make sure to allow SSH source IP at F5 end for the machine form where you will run the ansible playbooks.

Now all done for the connectivity let try to see we have a connectivity between host and ansible machine via ansible.

ansible -i inventory 192.168.1.100 -m ping
192.168.1.100 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}

I will continue working on playbook writing for the tasks and will share my experience in coming posts before that i guess have to learn YAML for writing playbooks.

Raja Shajeel Ahmad
Enterprise DC Engineer
Happy Learning
The limit is the sky.


Comments

Popular posts from this blog

Flow with respect to Networks in AWS

Important concepts in ACI Physical/Access polices Concepts

1 sec and Team work Story