Ansible on Ubuntu 16.04 - HPE Comware Switches

January 9, 2017

I’m working currently on my Freetime and on my company time with Ansible/Vagrant and so on aka

The Devops Stuff :-)

Building my new Infrastructure in the company from code with the help of Ansible.

And i love it!

Doing the same for my workstations ages, but now for the infrastructure its epic!

What i want to do was Config our Distribution Switches HPE-5900 Series (Comware 7) with Ansible to get a Stable and reapplying config.

Searching the tools

What i found was this Awesome Ansible Module ansible-hpe-cw7 with use the Python Lib pyhpecw7.

Currently it looks like a little abonded Last Commit around April + Sept/Oct 2016

But it working correctly, with a view dependencie workarounds

But Installing it on Ubuntu 16.04 was quite a pain with many dependencie erros, so i want to share it for you.

Installing Prereq on the Ansible Host with Ubuntu 16.04

What i came up with is my simple Vagrant Provision Script:

#!/usr/bin/env bash

# Installing git
sudo apt-get install git -y

# Installing Ansible over PPA
sudo apt-get install software-properties-common -y
sudo apt-add-repository ppa:ansible/ansible -y
sudo apt-get update -y
sudo apt-get install ansible -y

# Installing Kerberos Support
sudo export DEBIAN_FRONTEND=noninteractive apt-get install krb5-user -y
sudo export DEBIAN_FRONTEND=noninteractive apt-get install libkrb5-dev -y

# Installing Phyton Kerberos Support
sudo apt-get install python-dev python-pip libkrb5-dev -y
pip install 'pywinrm[kerberos]'

# Install HP Comware 7 Python Lib from Source
# https://github.com/HPENetworking/ansible-hpe-cw7
# Requirements for PIP Packages
sudo apt install libxml2-dev libxslt1-dev python-dev zlib1g-dev libffi-dev libssl-dev -y

#Upgrade Paramiko needed for pyhepcw7
sudo pip install paramiko --upgrade

# Fetch Repo and Install
git clone https://github.com/HPENetworking/pyhpecw7.git
cd pyhpecw7
sudo python setup.py install
cd ..
sudo rm -r -f pyhpecw7

After Installing the Dependencie for the Ansible Module copy the .py Files into your Ansible Project Lib folder, you should know how to do this.

and can do epic stuff like this :-)

- name: "Defining VLANs"
  hosts: fj-sw-dist
  gather_facts: no
  connection: local

  vars:
    username: "{{ cred_switch_netconf_user }}"
    password: "{{ cred_switch_netconf_password }}"

  tasks:

    # Ensure VLANS Exist
    - name: "Ensure VLAN 120 - Procurve exists"
      comware_vlan:
        vlanid: 120
        name: PROCURVE
        descr: Network Management
        username: "{{ username }}"
        password: "{{ password }}"
        hostname: "{{ ansible_host }}"

    - name: "Ensure VLAN 777 - Local MAD VLAN exists"
      comware_vlan:
        vlanid: 777
        name: mad-dist1
        descr: MAD-VLAN for IRF Stack fj-sw-dist
        username: "{{ username }}"
        password: "{{ password }}"
        hostname: "{{ ansible_host }}"

and probaly what you got now is a:

There is plenty more to discover with the Ansible Module, check the docs

Module Docs

Hopefully someone read this and go awol like me and i could help him installing this on a Ubuntu Box

See you next time when i discover something usefull to share!

comments powered by Disqus