Forum Discussion

Cypher's avatar
Icon for Cirrus rankCirrus
Jan 03, 2023

Retrieve datagrouplist data with ansible

Hi guys,

I've been looking all over the place, but can't seem to find a way to retrieve datgrouplist data. My goal is to update the DGL with new records: Get DGL-data -> set DGL-data with content from the GET + another record.

I've been succesfull setting data with . But as i said, you need to supply all the records, so I should be able to get them first. I assumed there was a way via Ansible, but so far didn't find any. 

Any toughts on this?

With this module you can set the data but you need to supply the whole list

3 Replies

  • CypherThis could be what you are looking for.

    If you scroll to the bottom of the page you should see a section that has "Show the data format expected for records_content" which could possibly be used to populate your data-group configuration before you send it with the additions or amendments. Another possiblity is to use this module to retrieve the current configuration and then use that to build your configuration for the other module.

  • Hi Pualius,

    I haven't been able to get the first option working with "Show the data format expected for records_content". This is using the "copy" module/collection. I assume to make a file, to be used to actually import the data with the bigip_datagroup_module.

    The second option does work. Thanks! The formatting is really tricky and would be very time consuming, so letting this slide as well.

    Just like Nikoolayy1 suggesting, I was allready tinkering with the send_command module and it seems to be working fine. To add 1 line to the DGL i use the following code 

      - name: add {{key}}":="{{value}} to DGL:{{dgl}} on {{server}}
            - modify ltm data-group internal {{dgl}} records add { {{key}} { data {{value}} }}
            server: "{{server}}"
            user: "{{F5_username}}"
            password: "{{F5_password}}"

    When the String/key does not exist, the key-value pair will be added. When the 'key' does exist, it will not update the dgl and gives the following output: The requested class string item (/Common/dgl test-string) already exists in partition Common

    It also gives a Warning:

    "warnings": [
                "Using \"write\" commands is not idempotent. You should use a module that is specifically made for that. If such a module does not exist, then please file a bug. The command in question is \"modify ltm data-group internal dgl...\""

    Still i have a hard time wrapping my head around the fact that there is no idempotent function inside the bigip_data_group_module (to Manage dgl's) to add 1 key-value pair to a dgl.

    Anyway thanks for all the help, it was useful!