Notice: This blog post was originally published on Men&Mice before its acquisition by BlueCat.

The content reflects the expertise and perspectives of the Men&Mice team at the time of writing. While some references may be outdated, the insights remain valuable. For the latest updates and solutions, explore the rest of our blog

Key Takeaways
  • Ansible should be installed on a Linux control machine (e.g., Ubuntu 22.04) with Python 3.6+ and Ansible version 2.10 or later for the Micetro collection to function correctly.
  • The Micetro Ansible collection is installed via Ansible Galaxy using ansible-galaxy collection install menandmice.ansible_micetro, which deploys the required plugins and modules.
  • Micetro uses a custom Ansible inventory plugin rather than a traditional static inventory file, enabling interaction with Micetro APIs instead of managed hosts.
  • Global connection parameters to Micetro (URL, username, password) are defined in /etc/ansible/group_vars/all under the mm_provider structure, with strict attention to YAML spacing for correct parsing.
  • The Ansible configuration file (ansible.cfg) must enable the menandmice.ansible_micetro.inventory plugin and reference a micetro.yml inventory configuration that includes Micetro API credentials.
  • Once configured, users can run Micetro-specific playbooks such as play_claimIP.yml with ansible-playbook to automate DDI operations like IP address allocation through Micetro.

Want to learn how you can start automating and orchestrating DNS, DHCP, and IPAM with Ansible? Micetro has an up-to-date Ansible collection and plug-in right on Ansible Galaxy. If you missed our first article on setting GitHub up and installing Ansible, check it out here (especially if this is the first time you’ve used Ansible or GitHub).

This article is for someone who has never used Ansible before and is not currently running it in their environment. If you are an Ansible enthusiast already, I recommend just diving into the playbooks we’ve already created! https://galaxy.ansible.com/menandmice/ansible_micetro

Installing Ansible:

I’ll be using a Linux Ubuntu 22.04 VM for this. It’s highly recommended to use Linux as your Ansible control machine, because it’s just really hard to run it on Windows using the subsystem for Linux. Also, just do yourself a favor and install pip if you don’t have it already.

Note: Make sure you are installing at least version 2.10 of Ansible for the Micetro plugin to work correctly. You’ll also need to have Python 3.6 or above installed as well.

$ sudo apt update
$ sudo apt install software-properties-common
$ sudo add-apt-repository –yes –update ppa:ansible/ansible
$ sudo apt install ansible

$ ansible –version

$ sudo apt install python3-pip

Ansible Version > 2.10

Setting Up Ansible for Micetro

Ansible for Micetro works a bit differently in that you won’t actually create an inventory list to reach out to managed nodes or “hosts.” Instead you’ll run the following command which will build out the necessary configuration to connect to your Micetro APIs. This will include building out the plugins and modules files we’ll talk about in the next section.

$ sudo ansible-galaxy collection install menandmice.ansible_micetro

Note, you will need to have Micetro up and running as well as have a Micetro account/password with necessary access to run API commands.

I can now go to ‘/root/.ansible/ to see what’s been configured.

#cd .ansible/

~/.ansible# ls

Plugins and Modules

If you’re following along in the Ansible documentation, then you’ll see there are a few different chapters or sections on Plugins and Modules. These are not the same as Ansible Playbooks, which we’ll talk about in just a bit.

Ansible Plugins – Extend the core functionality of Ansible.

Ansible Modules – a type of plugin that execute automation tasks on a ‘target’ (usually a remote system).

The Micetro plugins and modules have been built then, to extend the core capabilities of Ansible so that you may use it to create and manage workflows in your Micetro DDI environment. For more information on general plugins and modules, you can find it in the Ansible documentation here https://docs.ansible.com/ansible/latest/dev_guide/developing_locally.html

You don’t have to do anything with these plugins and modules as they. It’s like adding features to Ansible specific to Micetro. When we create Ansible Playbooks then, we’ll call upon these plugins and modules to do some of the work.

Now that we have Ansible installed and configured for Micetro generally, we can create a group_vars/all files which will tell Ansible where to look for Micetro.

Create a group_vars/all file in /etc/ansible/.

$ mkdir group_vars
$ touch group_vars/all
$ nano group_vars/all

mm_provider:
 mm_url: http://micetro.example.net
 mm_user: apiuser
 mm_password: apipassword

Note: Generally you’ll want to encrypt this password so it’s not stored in plaintext anywhere, but we’re just going to use plaintext for the sake of this demo.

Note: Make sure you’re using proper indentation! The group_vars/all file requires spaces instead of tabs, where as in your playbooks you can use tabs.

You’ll also create an ansible configuration file called ansible.cfg. This will call the micetro.yml file, which we’ll get to in just a moment.

$ touch ansible.cfg

$ nano ansible.cfg

[defaults]
remote_tmp = $HOME/.ansible/tmp
inventory = micetro.yml
nocows = 1

[inventory]
enable_plugins = menandmice.ansible_micetro.inventory, host_list, auto
cache = yes
cache_plugin = jsonfile
cache_prefix = micetro_inv
cache_timeout = 60
cache_connection = /tmp/micetro_inventory_cache

[privilege_escalation]
become = False
become_method = sudo
become_user = root
become_ask_pass = False

You’ll also see a sample micetro.yml-sample file in /root/.ansible/collections/ansible_collections/menandmice/ansible_micetro

You can either change the name of that file or create a new file called micetro.yml.

$ touch micetro.yml

$ nano micetro.yml

plugin: menandmice.ansible_micetro.inventory
mm_url: “http://micetro.example.net
mm_user: apiuser
mm_password: apipassword

Running a Playbook

Now, your Ansible control machine should be all set up to start running playbooks! Ansible playbooks contain tasks or “plays” which you can run to automate your environment. We’re going to get started with an easy one, of just claiming an IP.

This playbook may also be find in Ansible Galaxy, linked above. Remember that indentation really matters! So I’m just going to link to the README.pdf which contains the playbook example. https://github.com/menandmice/ansible_micetro/blob/main/docs/README.pdf

You can find the “play_claimIP” playbook in chapter 4, at 4.5. You’ll just need to create a yaml file on your control machine with a name like:

$ touch play_claimIP.yml

$ nano play_claimIP.yml

Once you’re in the editor, copy and paste the content from the example in the pdf. Make sure you go through and check indentation, although Ansible is pretty helpful and pointing out where syntax is incorrect.

When you’re ready to run it type the command:

$ ansible-playbook play_claimIP.yml

Then go check in Micetro to see if you were able to successfully claim the IP you indicated in the playbook.

Have Suggestions?

We’d love to hear how you’re using Ansible. Share your playbooks and ask for suggestions right in Ansible Galaxy or at the Github repo! https://galaxy.ansible.com/menandmice/ansible_micetro

Related content

Three armored figures walking toward a futuristic Las Vegas skyline with pyramids, glowing orb, and "Welcome to Fabulous Las

Your journey to intelligent NetOps begins at Cisco Live

Visit BlueCat’s booth or book a meeting now to learn more about how our solutions can help you build a network that supports constant change.

Read more
Stacked colorful wooden directional arrows on a post by a calm seaside with distant hills and blue sky

Replace BIND and ISC with Micetro DNS/DHCP Server (MDDS)

Tired of patching and manually configuring BIND DNS and ISC DHCP? Discover how Micetro MDDS appliances can replace them for modern DDI.

Read more
Row of orange industrial robotic arms positioned along an automated conveyor belt in a factory setting

Automate it all in Integrity with REST v2 API-first DDI management

Discover API-first DDI with Integrity X by using REST v2 to automate DNS, DHCP, and IPAM for scalable, secure network operations.

Read more
Three colleagues at monitors collaborating, overlaid with network, analytics, cloud, and gear icons.

Agentic AI adoption in network observability propels NetOps teams

Network observability is crucial for today’s networks and even more capable with agentic AI, according to new Omdia and BlueCat research.

Read more

⏳ Cisco Live is almost here. Put BlueCat on your agenda for smarter, more secure networks.