Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow cv_device to add configlet without listing all configlets #117

Closed
titom73 opened this issue Jan 17, 2020 · 1 comment
Closed

Allow cv_device to add configlet without listing all configlets #117

titom73 opened this issue Jan 17, 2020 · 1 comment
Labels
module: cv_device Issue related to cv_device module state: accepted Issue is part of the development roadmap type: enhancement New feature or request

Comments

@titom73
Copy link
Contributor

titom73 commented Jan 17, 2020

Use case:

When devices are all deployed with their configilet, it might be useful to add a new configlet to device using cv_device module.

Current module implementation requires to list all configlet and add new configlet to the list. This approach means user has to maintain list of configlets per device and run a workflow close to the rollout targeting a larger scope than just 1 device + 1 configlet

Change behaviour:

To allow user to target only one device with one configlet, it can be useful to add an option related to configlets in cv_device to support addition or deletion of a set of configlets.

Current implementation use the following syntax:

vars:
  devices_inventory:
    veos01:
    name: veos01
    configlets:
        - cv_device_test01
        - SYS_TelemetryBuilderV2_172.23.0.2_1
        - veos01-basic-configuration
        - SYS_TelemetryBuilderV2
    parentContainerName: DC1_VEOS
tasks:
    - name: "Configure devices on {{inventory_hostname}}"
      cv_device:
        devices: "{{devices_inventory}}"
        cvp_facts: '{{cvp_facts.ansible_facts}}'
        device_filter: ['veos']
      register: cvp_device

To support such change, 2 options could be implemented and both are already present in other modules

  • Use a configlet filter:

With this approach, configlet filter allows user to target only configlets with a specific string. So as for cv_container it is easy to add only one configlet with following example:

vars:
  devices_inventory:
    veos01:
    name: veos01
    configlets:
        - veos01-basic-configuration
    parentContainerName: DC1_VEOS
tasks:
    - name: "Configure devices on {{inventory_hostname}}"
      cv_device:
        devices: "{{devices_inventory}}"
        cvp_facts: '{{cvp_facts.ansible_facts}}'
        device_filter: ['veos']
        configlet_filter: ['veos01-basic-configuration']
      register: cvp_device

But in case we want to remove it from this device, it is required to fallback to original definition with all configlets.

This approach is similar to filters implemented in cv_configlet

  • Use a definition of mode

With implemnentation of a mode keyword, we can define 3 different behaviours:
- override (default): Completely intend based approach and will apply the full list of configlet to device and remove unlisted configlets.
- merge: Only add new configlets to existing list.
- delete: Delete list of configlets from device.

vars:
  devices_inventory:
    veos01:
    name: veos01
    configlets:
        - veos01-basic-configuration
    parentContainerName: DC1_VEOS
tasks:
    - name: "Configure devices on {{inventory_hostname}}"
      cv_device:
        devices: "{{devices_inventory}}"
        cvp_facts: '{{cvp_facts.ansible_facts}}'
        device_filter: ['veos']
        configlet_mode: merge
      register: cvp_device

This approach is similar to cv_container with its mode option

@titom73 titom73 added type: enhancement New feature or request module: cv_device Issue related to cv_device module status: gathering feedback Need feedback labels Jan 17, 2020
titom73 added a commit that referenced this issue Jan 20, 2020
Start module refactor to allow mode implementation.

Phase01:
- Split to functions
- Add structure output for any function
- Implement configlet update for device
- Do not change reset mode

Todo:
- New device.
- Move device to another container.
- Configlet mode.
- Testing.
titom73 added a commit that referenced this issue Jan 21, 2020
titom73 added a commit that referenced this issue Jan 21, 2020
Phase02:
- Support device provisioning
- Support device move from one container to another
- Initial manual testing

Todo:
- Configlet mode.
- Testing.
@titom73 titom73 added status: in-progress Currently under investigation or implementation and removed status: gathering feedback Need feedback labels Jan 21, 2020
titom73 added a commit that referenced this issue Jan 22, 2020
Phase03:
- Add configlet_mode in module
- Support override (default mode)
- Support merge (only add new configlets)

Todo:
- Add support for delete (remove listed configlets)
- Perform complete testing
titom73 added a commit that referenced this issue Jan 22, 2020
Phase03:
- Add configlet_mode in module
- Support override (default mode)
- Support merge (only add new configlets)
- Support for delete (remove listed configlets)
- Global testing done
titom73 added a commit that referenced this issue Jan 22, 2020
@titom73 titom73 added state: accepted Issue is part of the development roadmap and removed status: in-progress Currently under investigation or implementation labels Jan 23, 2020
@titom73
Copy link
Contributor Author

titom73 commented Jan 23, 2020

Work is part of PR #122

@titom73 titom73 closed this as completed Jan 23, 2020
titom73 added a commit that referenced this issue Mar 18, 2020
Start module refactor to allow mode implementation.

Phase01:
- Split to functions
- Add structure output for any function
- Implement configlet update for device
- Do not change reset mode

Todo:
- New device.
- Move device to another container.
- Configlet mode.
- Testing.
titom73 added a commit that referenced this issue Mar 18, 2020
titom73 added a commit that referenced this issue Mar 18, 2020
Phase02:
- Support device provisioning
- Support device move from one container to another
- Initial manual testing

Todo:
- Configlet mode.
- Testing.
titom73 added a commit that referenced this issue Mar 18, 2020
Phase03:
- Add configlet_mode in module
- Support override (default mode)
- Support merge (only add new configlets)

Todo:
- Add support for delete (remove listed configlets)
- Perform complete testing
titom73 added a commit that referenced this issue Mar 18, 2020
Phase03:
- Add configlet_mode in module
- Support override (default mode)
- Support merge (only add new configlets)
- Support for delete (remove listed configlets)
- Global testing done
titom73 added a commit that referenced this issue Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: cv_device Issue related to cv_device module state: accepted Issue is part of the development roadmap type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant