Skip to content

[Proposal] Platform agnostic role ansible.network.resource_manager to manage network resources. #13

@ganeshrn

Description

@ganeshrn

Proposal:

Provide a single platform agnostics entry point to manage all the resources supported for given network os.
This will be achieved by implementing a platform-agnostic role ansible.network.network_resource as part of ansible.network collection.

Motivation

Describe the reasons for this proposal.
Provide a single entry point to manage network resource and ease the usage of Ansible network resource modules.

Problems

  • As a user, I want to be able to get the list of resource modules supported for a given network os.
  • As a user, I want to get the facts for a given resource and store it as host_vars thus enabling the capability to get facts for all the host within the inventory and store facts in a structured format.
  • As a user, I want to be able to push the resource config stored as host_vars to the remote host.

Solution proposal

  • The role will use a platform-agnostic module ansible.netcommon.network_resource (action plugin) that will provide a single entry point to higher-order roles to manage all the resource modules.

Example usage:

  1. Get the list of resource modules for given ansible_network_os
- name: get list of resource modules for given ansible_network_os
  ansible.netcommon.network_resource:
  register: result
  vars:
     ansible_network_os: cisco.ios.ios
  1. Fetch ACL resource config for given ansible_network_os
- name: fetch acl resource config
  ansible.netcommon.network_resource:
    name: acls
    state: gathered
  vars:
     ansible_network_os: cisco.ios.ios
  1. Push acl resource config for given ansible_network_os
  - name: manage acl config
    ansible.netcommon.network_resource:
      name: acls
      config:
        - afi: ipv4
          acls:
            - name: test_acl
              acl_type: extended
              aces:
                - grant: deny
                  protocol_options:
                    tcp:
                      fin: true
                  source:
                    address: 192.0.2.0
                    wildcard_bits: 0.0.0.255
                  destination:
                    address: 192.0.3.0
                    wildcard_bits: 0.0.0.255
      state: merged
  vars:
     ansible_network_os: cisco.ios.ios

The ansible.network. resource_manager role will support the following functions

  • list: The function will take the value of ansible_network_os as input and will return a list of supported resource modules.
  • get: The function will take the value of ansible_network_os, the name of the resources (optional) and path to the inventory (optional) as input. This function will fetch the resource facts from the remote host and build the inventory host_vars at runtime.
  • configure: The function will take the value of ansible_network_os, the name of the resources (optional) and path to the inventory (optional) as input. This function will then read the host_vars for the given resource from inventory and push it to the remote host. If the name of the resource is not provided in the input it pushes the entire inventory host_vars to the remote host.

Example usage:

  1. list function
- hosts: ios
  gather_facts: no
  tasks:
  - name: invoke list fuctnion
    include_role:
      name: ansible.network.resource_manager
      tasks_from: list
    vars:
      ansible_network_os: cisco.ios.ios
  1. Get function
- hosts: ios
  gather_facts: no
  tasks:
  - name: invoke get function for all resources
    include_role:
      name: ansible.network.resource_manager
      tasks_from: get
    vars:
      ansible_network_os: cisco.ios.ios
     network_resource_include: [all]       # default value
     network_resource_exclude: []          # default value
     network_resource_inventory_path: "./inventory/host_vars"
  1. Configure function
- hosts: ios
  gather_facts: no
  tasks:
  - name: invoke configure function for given resources
    include_role:
      name: ansible.network.resource_manager
      tasks_from: configure
    vars:
      ansible_network_os: cisco.ios.ios
     network_resource_include: ["acls", "interfaces"]
     network_resource_inventory_path: "./inventory/host_vars"

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalproposal for network collections

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions