ansible-collection-netscaleradc icon indicating copy to clipboard operation
ansible-collection-netscaleradc copied to clipboard

[FEATURE REQUEST]: Add resource dependency list to the nitro resource dependency map module util

Open gusmb opened this issue 1 year ago • 3 comments

Summary

I have a custom role that leverages the netscaler.adc modules to provision NITRO resources in bulk, where I take a configuration iterable as input, and each element represents s partition and a list of nitro resources in that partition to configure declaratively. One thing I need to do is to figure out the right order to configure the resources to not run into issues with bound or referenced resources.

This information is almost available on the nitro_resource_map.py module, as each nitro resource contains a list of supported bindings, however it is not easy to derive the dependent resource from there directly. I would like to consume that data and build for my list of resources to configure, build the dependency graph, that I could use to determine the right order of configuration by running a topological sort on that graph.

Issue Type

Feature Idea

Component Name

All

Describe alternatives you've considered

Using Terraform since Terraform had a nice dependency resolution built-in, however for some of my use cases I might need to use the modules more imperatively and not maintain state, for which using just Ansible is more convenient.

Additional Information


gusmb avatar Mar 03 '24 22:03 gusmb

@gusmb, if I have understood your request correctly, for a given ansible-playbook/role, you need to find which task is dependent on the other, if it is.

Constructing dependency graph requires a lot more data. In terraform it is handled by the implicit and explicit dependencies in the HCL file.

I am not sure how we can achieve this in the YAML format.

sumanth-lingappa avatar Mar 04 '24 12:03 sumanth-lingappa

@gusmb, if I have understood your request correctly, for a given ansible-playbook/role, you need to find which task is dependent on the other, if it is.

Constructing dependency graph requires a lot more data. In terraform it is handled by the implicit and explicit dependencies in the HCL file.

I am not sure how we can achieve this in the YAML format.

Not exactly, I am rendering the list of tasks dynamically using Jinja2, based on an input list of resources to configure (e.g. server, servicegroup, vserver, bindings etc). I want to render the tasks in the right order. In this example, looking at the bindings would be mostly enough (e.g. a servicegroup depends on service group members being created first, and since servicegroup can be bound to monitor, monitor must be created before servicegroup. A basic dependency set for each resource type would solve this, as I would have the data I need to do the sorting and rendering the tasks in the right order.

The workaround (what I am doing now) is maintaining this resource dependency map manually in role defaults.

gusmb avatar Mar 04 '24 16:03 gusmb

Where I see it could get challenging is if the configuration list contains resources mixing multiple modes of operation (for instance, create a service, then disable it). In this case the solution might get tricky quickly. I was thinking in the direction of a filter that takes the configuration list, looks at the list of resources and modes of operation for each resource, and spits out the order in which the resources should be configured. But need to find out if there's any way of achieving this with the data that is currently available in the nitro resource map

gusmb avatar Mar 04 '24 20:03 gusmb