The final version to support Ansible is 3.9.3220.
Make sure CentOS 8 EPEL repository is installed:
sudo yum install epel-release
sudo yum install ansible
.Configuring the Ansible hosts (file includes the switches to be accessed)
Open the vim /etc/ansible/ansible.cfg file and search for the host_key_auto_add.
Un-comment it as shown in the example below.
When using persistent connections with Paramiko, the connection runs in a background process. If the host doesn’t already have a valid SSH key, by
defaultAnsible will prompt to add the host key. This will cause connections running in the background processes to fail. Uncomment
thisline to have Paramiko automatically add host keys. #host_key_auto_add = TRUE
Open the /ansible/hosts file with root privileges
Keep output file for future more complex Ansible configuration scenarios.
Add switch information to the following configuration file, based on the following examples:
EX1: switch132; ansible_host=10.209.37.249; ansible_user=admin; ansible_ssh_pass=admin
EX2: switch131; ansible_host=l-csi-2700-l05; ansible_user=admin; ansible_ssh_pass=admin
Create a .yml file under /etc/ansible
hosts: switch132 gather_facts: no connection: network_cli become: yes become_method: enable vars: ansible_network_os: onyx tasks: onyx_vlan: vlan_id:
List of switches required for running this yml file on
List of required tasks
Desired module name
Run the playbook.
ansible-playbook <path_of_yml file> -i /etc/ansible/host -vvvvv –check
Full module variables explanation, and examples of playbooks can be created for each module of Onyx modules supported by Ansible.
All Onyx-supported modules in Ansible are available in the following link: https://docs.ansible.com/ansible/latest/collections/mellanox/onyx/index.html.
The Onyx modules are available in the following path: lib/ansible/modules/network/onyx, where any module can be run in order to see the structure of the playbook.