ansible.builtin.meraki_switchport (v2.9.24) — module

Manage switchports on a switch in the Meraki cloud

| "added in version" 2.7 of ansible.builtin"

Authors: Kevin Breit (@kbreit)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.24

Description

Allows for management of switchports settings for Meraki MS switches.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Query information about all switchports on a switch
  meraki_switchport:
    auth_key: abc12345
    state: query
    serial: ABC-123
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Query information about all switchports on a switch
  meraki_switchport:
    auth_key: abc12345
    state: query
    serial: ABC-123
    number: 2
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Name switchport
  meraki_switchport:
    auth_key: abc12345
    state: present
    serial: ABC-123
    number: 7
    name: Test Port
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Configure access port with voice VLAN
  meraki_switchport:
    auth_key: abc12345
    state: present
    serial: ABC-123
    number: 7
    enabled: true
    name: Test Port
    tags: desktop
    type: access
    vlan: 10
    voice_vlan: 11
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Check access port for idempotency
  meraki_switchport:
    auth_key: abc12345
    state: present
    serial: ABC-123
    number: 7
    enabled: true
    name: Test Port
    tags: desktop
    type: access
    vlan: 10
    voice_vlan: 11
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Configure trunk port with specific VLANs
  meraki_switchport:
    auth_key: abc12345
    state: present
    serial: ABC-123
    number: 7
    enabled: true
    name: Server port
    tags: server
    type: trunk
    allowed_vlans:
      - 10
      - 15
      - 20
  delegate_to: localhost

Inputs

    
host:
    default: api.meraki.com
    description:
    - Hostname for Meraki dashboard.
    - Can be used to access regional Meraki environments, such as China.
    type: str

name:
    aliases:
    - description
    description:
    - Switchport description.

tags:
    description:
    - Space delimited list of tags to assign to a port.

type:
    choices:
    - access
    - trunk
    default: access
    description:
    - Set port type.

vlan:
    description:
    - VLAN number assigned to port.
    - If a port is of type trunk, the specified VLAN is the native VLAN.

state:
    choices:
    - query
    - present
    default: query
    description:
    - Specifies whether a switchport should be queried or modified.
    type: str

number:
    description:
    - Port number.

org_id:
    description:
    - ID of organization.
    type: str

serial:
    description:
    - Serial nubmer of the switch.

enabled:
    default: true
    description:
    - Whether a switchport should be enabled or disabled.
    type: bool

timeout:
    default: 30
    description:
    - Time to timeout for HTTP requests.
    type: int

auth_key:
    description:
    - Authentication key provided by the dashboard. Required if environmental variable
      C(MERAKI_KEY) is not set.
    required: true
    type: str

org_name:
    aliases:
    - organization
    description:
    - Name of organization.
    type: str

stp_guard:
    choices:
    - disabled
    - root guard
    - bpdu guard
    - loop guard
    default: disabled
    description:
    - Set state of STP guard.

use_https:
    default: true
    description:
    - If C(no), it will use HTTP. Otherwise it will use HTTPS.
    - Only useful for internal Meraki developers.
    type: bool

use_proxy:
    default: false
    description:
    - If C(no), it will not use a proxy, even if one is defined in an environment variable
      on the target hosts.
    type: bool

voice_vlan:
    description:
    - VLAN number assigned to a port for voice traffic.
    - Only applicable to access port type.

poe_enabled:
    default: true
    description:
    - Enable or disable Power Over Ethernet on a port.
    type: bool

output_level:
    choices:
    - debug
    - normal
    default: normal
    description:
    - Set amount of debug output during module execution.
    type: str

rstp_enabled:
    default: true
    description:
    - Enable or disable Rapid Spanning Tree Protocol on a port.
    type: bool

allowed_vlans:
    default: all
    description:
    - List of VLAN numbers to be allowed on switchport.

output_format:
    choices:
    - snakecase
    - camelcase
    default: snakecase
    description:
    - Instructs module whether response keys should be snake case (ex. C(net_id)) or camel
      case (ex. C(netId)).
    type: str

validate_certs:
    default: true
    description:
    - Whether to validate HTTP certificates.
    type: bool

link_negotiation:
    choices:
    - Auto negotiate
    - 100Megabit (auto)
    - 100 Megabit full duplex (forced)
    default: Auto negotiate
    description:
    - Link speed for the switchport.

isolation_enabled:
    default: false
    description:
    - Isolation status of switchport.
    type: bool

access_policy_number:
    description:
    - Number of the access policy to apply.
    - Only applicable to access port types.

rate_limit_retry_time:
    default: 165
    description:
    - Number of seconds to retry if rate limiter is triggered.
    type: int

internal_error_retry_time:
    default: 60
    description:
    - Number of seconds to retry if server returns an internal server error.
    type: int

Outputs

data:
  contains:
    access_policy_number:
      description: Number of assigned access policy. Only applicable to access ports.
      returned: success
      sample: 1234
      type: int
    enabled:
      description: Enabled state of port.
      returned: success
      sample: true
      type: bool
    isolation_enabled:
      description: Port isolation status of port.
      returned: success
      sample: true
      type: bool
    link_negotiation:
      description: Link speed for the port.
      returned: success
      sample: Auto negotiate
      type: str
    name:
      description: Human friendly description of port.
      returned: success
      sample: Jim Phone Port
      type: str
    number:
      description: Number of port.
      returned: success
      sample: 1
      type: int
    poe_enabled:
      description: Power Over Ethernet enabled state of port.
      returned: success
      sample: true
      type: bool
    rstp_enabled:
      description: Enabled or disabled state of Rapid Spanning Tree Protocol (RSTP)
      returned: success
      sample: true
      type: bool
    stp_guard:
      description: State of STP guard
      returned: success
      sample: Root Guard
      type: str
    tags:
      description: Space delimited list of tags assigned to port.
      returned: success
      sample: phone marketing
      type: str
    type:
      description: Type of switchport.
      returned: success
      sample: trunk
      type: str
    vlan:
      description: VLAN assigned to port.
      returned: success
      sample: 10
      type: int
    voice_vlan:
      description: VLAN assigned to port with voice VLAN enabled devices.
      returned: success
      sample: 20
      type: int
  description: Information queried or updated switchports.
  returned: success
  type: complex