Introduction

This post will demonstrate how to configure Ansible to work properly with Huawei remote devices.

Pre requisites

You will need SSH configured and working on your remote device, obviously. Follow this official documentation

Also, install Ansible wherever you want, following this official documentation

Then, I recommend to upload your public SSH key on your remote device.

Infrastructure

The context is really simple in our study case :

  • One Huawei router, already configured and properly working
  • My MacBookPro, with Ansible installed

And that’s all!

Configuring Ansible for Huawei

On Huawei’s website, there is a documentation, demonstrating how to configure your Ansible server.

The official pdf is available there. I do not mentionned it before, but this documentation also cover the client side preparation (SSH server configuration)

My post will cover the basics and resume the pdf.

Ncclient

First, we need to install ncclient on our Ansible server.

Download

Then unzip and install :

unzip ncclient-0.5.3.zip

cd ncclient-0.5.3/

sudo python setup.py install

Ansible CloudEngine

CloudEngine is the official Ansible module for Huawei products.

We need to download it :

wget https://github.com/HuaweiSwitch/CloudEngine-Ansible/archive/v0.2.0.zip

unzip CloudEngine-Ansible-0.2.0.zip

CloudEngine installation

Your directory might look like that :

directory

We then need to find the directories where the Ansible framework and its modules are located

For that, do the following :

find / -name network.py

I got the following :

ansible directories

I had nothing else to do, but if you got nothing, you might follow the indication on page 8 of the Huawei official pdf.

Running for the first time

Now, we can test with a really basic command that everything is working properly.

For that, I run the following, with my own parameters obviously :

ansible -m ce_command -a 'host=10.10.10.10 port=12347 username=*** password=*** commands="display version"' localhost --connection local

And the result :

ansible running

What’s next?

In the next article, I will explain how to use the others Ansible CloudEngine modules and deploy some configuration.