Provisioning and managing DataMiner using Ansible

Provisioning and managing DataMiner using Ansible

Ansible is a great DevOps tool that can help you with the development, testing, deployment, and monitoring of your infrastructure and software. Using DataMiner’s web API, you can also use Ansible to provision and manage your DataMiner System.

Ansible consists of several tools that help you with automating tasks in your infrastructure. To run it, all you need is an Ansible control node running on a Linux operating system. From this control node, you can then manage your other servers, which can have any operating system you want (Windows, Linux, or macOS). You can either manage the operating system itself or the software that is running on it.

To control your DataMiner System using Ansible, you’ll need to use DataMiner’s web REST API to configure an Ansible Playbook. It allows you to use either JSON or SOAP requests to execute actions on your DataMiner System. The more recent your DataMiner version, the more possibilities you will have.

Want to know more about Ansible? Go to docs.ansible.com. For detailed info on the DataMiner web API, go to docs.dataminer.services.

When you configure the Ansible playbook, your first step should always be to request a connection ID. This is the same as for any other program you use the API with. Within the Ansible task, you can retrieve the value from this request and then use it in other requests. You can for example request the connection ID like this:

    - name: Connect With DataMiner
      ansible.windows.win_uri:
        url: "{{jsonServer}}{{connect}}"
        return_content: yes
        content_type: "{{jsonContent}}"
        url_method: POST
        body: '{
            "host": "{{server}}",
            "login": "[Insert DataMiner User]",
            "password": "[Insert Password of DataMiner User]",
            "clientAppName": "[Name for your connection]",
            "clientAppVersion": "1.0",
            "clientComputerName": "[Client Computer Name]]"
            }'
        register: connectionID

In addition to JSON requests, you can also do SOAP requests. Below you can find an example of how you can provision a new element in the DataMiner System using a SOAP request. The values in square brackets in the example are placeholder values; when you actually create your request, you should replace these with the correct values.

    - name:
      ansible.windows.win_uri:
        url: "{{soapServer}}"
        return_content: yes
        content_type: "{{soapContent}}"
        url_method: POST
        body: '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Body>
        <CreateElement xmlns="http://www.skyline.be/api/v1">
            <connection>{{connectionid.json.d}}</connection>
            <dmaID>[DataMiner ID]</dmaID>
            <viewIDs>
                <int>{{ansibleView.json.d | int}}</int>
            </viewIDs>
            <configuration>
                <Name>[NameOfElement]</Name>
                <ProtocolName>[ProtocolName]</ProtocolName>
                <ProtocolVersion>[ProtocolVersion]</ProtocolVersion>
                <Ports>
                    <DMAElementBasePortInfo xsi:type="DMAElementSerialPortInfo">
                        <IPAddress>[IPAddress]</IPAddress>
                        <TimeoutTime>60</TimeoutTime>
                        <ElementTimeoutTime>30</ElementTimeoutTime>
                    </DMAElementBasePortInfo>
                </Ports>
            </configuration>
        </CreateElement>
        </soap:Body>
        </soap:Envelope>

In this new request, the connection ID from the previous request is reused as a variable. Such a variable is declared as {{variable_name}} in the playbook. At the top of your playbook, you can make a list of the variables you want to use, e.g. jsonServer, soapServer, jsonContent, soapContent, etc. This way, these can easily be reused.

You can actually do a lot more with this request than is illustrated in this example. Go to https://[DMA hostname]/API/v1/json.asmx or https://[DMA IP]/API/v1/json.asmx to find out which parameters you can add with your DataMiner version, or check out our documentation about the web services.

Want to find out more about provisioning and managing your DataMiner System with Ansible? Our detailed guide on docs.dataminer.services contains all the information you need.

3 thoughts on “Provisioning and managing DataMiner using Ansible

  1. Simon Raine

    Great to see the capability to integrate DataMiner deployment and configuration with tools like Ansible. Endless possibilities!

Leave a Reply