ansible-network / network-engine

This role provides the foundation for building network roles by providing modules and plugins that are common to all Ansible Network roles.
GNU General Public License v3.0
112 stars 53 forks source link

validate_role_spec not populating variables/subkeys with default values #189

Closed victorock closed 5 years ago

victorock commented 6 years ago

ISSUE TYPE

ANSIBLE VERSION

2.6.4

Network OS

Tower 3.3
Arista vEOS: 4.20.1F

SUMMARY

validate_role_spec is not defining default values properly.

---
argument_spec:
  mlag_setup:
    type: dict
    options:

      state:
        type: str
        required: false
        default: present
        choices:
          - "present"
          - "absent"
        description:
          - "Desired state: present, absent"

      peer:
        type: str
        required: true
        description:
          - "The MLAG peer switch hostname (inventory_hostname)"

      vlan:
        type: int
        required: false
        default: "4094"
        description:
          - "VLAN to use for peer communication."
          - "VLAN is used to create the interface vlan for MLAG_CONTROL_PLANE."

      domain:
        type: int
        required: false
        default: "1"
        description:
          - "Represents the MLAG domain."
          - "The ID must be the same only for members of the same MLAG domain."
          - "Domain is used to create the MLAG_CONTROL_PLANE VRF with RD <site>:<domain>"

      site:
        type: int
        required: false
        default: "1"
        description:
          - "Represents the site where the domain is located."
          - "Site is used to create the MLAG_CONTROL_PLANE interface with address 169.254.<domain>.<site><device>"
          - "Site is used to create the MLAG_CONTROL_PLANE VRF with RD <site>:<domain>"

      device:
        type: int
        required: false
        default: "1"
        description:
          - "Unique ID to represent the device member of the MLAG domain"
          - "The ID is used to create the peer communication address 169.254.<domain>.<site><device>"

      linkagg:
        type: int
        required: false
        default: "1"
        description:
          - "Linkagg to use for the peer-to-peer communication."

      vlans:
        type: list
        required: false
        default:
          - "all"
        description:
          - "List of vlans member of the MLAG domain"
          - "VLANs are NOT created if they do not exist"

      interlinks:
        type: list
        required: false
        default:
          - "Ethernet1"
        description:
          - "List of physical interfaces used by linkagg as interlinks for the peer-to-peer communication"

      heartbeat:
        type: int
        default: "10000"
        required: false
        description:
          - "Timer for heartbeat in ms"

      reload_delay:
        type: int
        default: "150"
        required: false
        description:
          - "Delay to bring MLAGs up after reload."
          - "Helps to ensure that MLAGs comes up only when adjacency is done and tables are pre-populated."
          - "Prevents blackhole of traffic when device is converging and tables being populated after a reboot."

      ipv4:
        type: str
        required: true
        description:
          - "IPV4 address to use for the MLAG intercommunication"

      vrf:
        type: str
        required: false
        default: "mlag_control"
        description:
          - "The VRF name for the MLAG intercommunication"

      extension:
        type: dict
        required: false
        description:
          - "Extension of specs with platform-specific keys/values"

Undefined variables and subkeys being defined with the value defined in default.

Neither variables or subkeys are defined with the default values specified in the spec file.

trishnaguha commented 6 years ago

@victorock Do you mean that the default value is not set at all?

victorock commented 6 years ago

@trishnaguha when i ran the tests, the subkeys were not defined properly with the default value... NOTE: I am not using the merge_behaviour = merge

trishnaguha commented 5 years ago

@victorock As discussed with the team, this is not a bug but a feature idea. Currently default values need to be set via role only. This plugin only takes default here as part of documenting the role spec.

trishnaguha commented 5 years ago

resolved_by_pr https://github.com/ansible-network/network-engine/pull/198