Sidebar

Combodo

iTop Extensions

Data model for Ansible

name:
Data model for Ansible
description:
Modelization of Ansible inventories in iTop
version:
1.0.0
release:
2023-11-07
itop-version-min:
2.7
code:
combodo-ansible-datamodel
state:
Stable
php-version-max:
PHP 8.1

This extension is dedicated to Ansible, the application that automates the management of remote systems and controls their desired state. It enriches iTop's CMDB by modelizing Ansible inventories which enforces the central role of iTop for all CMDB matters. Together with the Ansible playbooks for iTop, it enables Ansible administrators and developpers to fetch in iTop, directly from Ansible playbooks, tasks or modules, CMDB related information like inventory files or list of hosts to work on.

Features

When installed on iTop, the extension creates a set of different classes that represent Ansible objects. These classes are displayed in a specific dashboard that is accessible from a submenu of the standard CMDB overview menu.

Revision History

Version Release Date Comments
1.0.0 2023-09-24 First version

Limitations

The model brings a TagSet attribute on a n:n relation. Such attribute cannot be changed on iTop 2.7 nor iTop 3.0 and therefore cannot be used with these versions.

Requirements

The extension can only be installed on iTop 2.7.x and above, including iTop 3.x, of course

Installation

Use the Standard installation process for this extension. It can be installed on any iTop datamodels as it just depends on iTop configuration management module, which is a core module that is always activated.

Configuration

By default, the extension limits the class of CIs that can be attached to an Inventory group. A configuration parameter allows you to overload this default behaviour.
The section below is by default hidden in the configuration file, you have to copy it from below if you need to adapt the list of CI classes.

Configuration
      'combodo-ansible-datamodel' => array (
                'ci_classes_in_inventory_groups' => array (
                  0 => 'Server',
                  1 => 'VirtualMachine',
                  2 => 'AzureVirtualMachine',
                  3 => 'ApplicationSolution',
                ),
        ),
Parameter Meaning Default
ci_classes_in_inventory_groups List of classes of CIs that can be linked to an Inventory group Server, VirtualMachine, ApplicationSolution
  • When the ci_classes_in_inventory_groups list is updated, no action is taken on CIs which are already attached to an inventory and whose class no longer appears in the list.
  • However, such CIs are automatically removed form the inventory files and lists generated on the fly.

Usage

Ansible Application

This class modelizes the well-known Ansible applications from which CIs can be managed via commands applied to inventories.

Ansible Application Properties

Name Type Mandatory? Displaying an Ansible Application
General Information
Name Alphanumeric string Yes
Organization Foreign key to a(n) Organization Yes
Status Possible values: Implementation, Production, Obsolete No
Business criticality Possible values: high, medium, low No
Location Foreign key to a(n) Location No
Description HTML string No
Move to production date Date (year-month-day) No
UUID Alphanumeric string No
CI Foreign key to a(n) Server, Virtual machine or Application solution No

Tabs

Tab Description
Contacts All the contacts linked to the application
Documents All the documentation related to the application
Inventories All inventories attached to the application
Inventory groups All inventory groups attached to the application through inventories
  • The UUID is the universal unique identifier of the application within iTop. It has no link with similar parameter that may exist within an Ansible instance.
  • The CI attribute defines where the Ansible controller is hosted.

Ansible Inventory

An inventory is a list of managed nodes, or hosts, that Ansible deploys and configures. These hosts can be classified within groups.

Ansible Inventory Properties

Name Type Mandatory? Displaying an Ansible Inventory
General Information
Name Alphanumeric string Yes
Application Foreign key to a(n) Ansible application Yes
Organization Organization that the application belongs to N/A
Description HTML string No

Tabs

Tab Description
Inventory groups All inventory groups attached to the inventory
CIs All the CIs attached to an inventory group belonging to the inventory
At the time of creation, a special “ungrouped” inventory group is created and attached to the Ansible Inventory. Please refer to the following section for more details.

Display inventory file

From the “Other actions” menu of an Ansible inventory, the “Display inventory file” menu will let you visualize the entire inventory as a file in INI or YAML formats.

  • A button on the top of the “file” allows you to switch from one format to the other.
  • The Details menu will bring you back to the details page of the inventory.

Ansible Inventory Group

These hierarchical objects are used to classify hosts and decide which hosts are controlled, when and for what purpose.

Ansible Inventory Group

Name Type Mandatory? Displaying an Ansible Application
General Information
Name Alphanumeric string Yes
Application Foreign key to a(n) Ansible application Yes
Organization Organization that the application belongs to N/A
Inventory Foreign key to a(n) Ansible inventory Yes
Parent group Foreign key to a(n) Ansible inventory group No
Description HTML string No

Tabs

Tab Description
CIs All the CIs that belong to the group
By default, only servers, virtual machines and application solutions can be attached to an Inventory group ! This behaviour can be changed through a configuration parameter, as described in the Configuration section.

CI to Inventory group relation

This relation hosts a Tag attribute.

  • This field is defined as an iTop tagset attribute,
  • Several tags can therefore be added to the relation (maximum 12),
  • All values will appear in inventory files, according to Ansible standards.

Management of TagSet attributes is described here on the wiki.
The Tag attribute is a TagSet. Being hosted on a n:n relation, it cannot be changed on iTop 2.7 nor iTop 3.0 and therefore cannot be used with these versions where it is left empty. On iTop 3.1, it must be edited in modal windows, through the Creation icon or Edit icon icons of the CIs box.

Special "ungrouped" Inventory group

The group called “ungrouped” is a mandatory object in YAML inventories. It contains all CIs that are not attached to a specific Inventory group. This is not the case with INI inventories where such CIs are directly attached to the root of the file. Regardless of the format, CIs that should not be attached to a group must be attached to the ungrouped group in iTop.

For a given Inventory, the “ungrouped” group is automatically created when the Inventory is created.

Virtual Machine

In iTop standard data model, Virtual Machines are linked to a Virtual Host i.e. the vCluster or Hypervisor on which they have been activated. This link is mandatory… which may cause problems when virtual machines are created from Ansible as their virtual host is not always known by the playbooks in charge of their creation (Ansible playbooks for iTop extension) or by the facts gathered from the Ansible controller (Data collector for Ansible).

As a consequence, the Data model for Ansible extension changes the 'Virtual Machines → Virtual Host' link into a non mandatory one.

Ansible Manager Profile

The extension brings with it the new profile “Ansible Manager” which has full rights on all classes brought by the extensions as well as read rights over the General, Configuration and Documentation groups.

Ansible Web Services

In addition to the classes described above, the extension provides a set of WEB services dedicated to Ansible. Based on iTop standard REST/JSON interface, they can be used to retrieve inventory files or host lists from third-party applications such as Ansible.

Don't forget that the access to the REST web services is restricted to the users having the profile REST Services User.

Operation: ansible/get_webservices_version

Provides the version currently used for iTop WEB services dedicated to Ansible.

Required parameters: None

For example, passing the following json_data:

{
   "operation": "get_webservices_version"
}

will return the information:

“Running version of the iTop WEB services dedicated to Ansible is: 1.0”

Operation: ansible/get_inventory

Get an inventory defined for an Ansible application.

Required parameters:

Name Description Example
uuid UUID of the Ansible application DEMO_UUID
inventory Name of the inventory to consider DMZ-1
format Expected format yml, ini

For example, passing the following json_data:

{
   "operation": "ansible/get_inventory",
   "uuid": "DEMO_UUID",
   "inventory": "DMZ-1",
   "format": "yml"
}

will return the “DMZ-1” inventory file in YAML format, like the one displayed in the previous chapter.

The login used to execute the web service needs to have enough rights to visualise Ansible objects.

Operation: ansible/get_hosts_by_oql

Get a subset of hosts belonging to an inventory defined for an Ansible application.

Required parameters:

Name Description Example
uuid UUID of the Ansible application DEMO_UUID
inventory Name of the inventory to consider DMZ-1
oql OQL that defines the list of hosts to retrieve SELECT VirtualMachine
attribute Host's attribute to be provided in the list name

For example, passing the following json_data:

{
   "operation": "ansible/get_inventory",
   "uuid": "DEMO_UUID",
   "inventory": "DMZ-1",
   "OQL": "SELECT VirtualMachine",
   "attribute": "name"
}

will return, as a list, the names of the virtual machines belonging to “DMZ-1” inventory:

“3cxTelephonie,VM1,VM2,VSphere Server,Windows Server 2008R2”

If no inventory is provided, the operation will return the result of the OQL without any further filtering.
The login used to execute the web service needs to have enough rights to visualise Ansible objects

Ansible playbooks for iTop

The Ansible web services have been embedded in “ready to use” Ansible playbooks that can be integrated in any Ansible scripts (playbooks, tasks or modules). Please, refer to the Ansible playbooks for iTop documentation.

extensions/combodo-ansible-datamodel.txt · Last modified: 2023/11/03 09:52 by 127.0.0.1
Back to top
Contact us