ansible.builtin.netbox_site (v2.9.27) — module

Creates or removes sites from Netbox

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

Authors: Mikhail Yohman (@FragmentedPacket)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.27

Description

Creates or removes sites from Netbox


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Test Netbox site module"
  connection: local
  hosts: localhost
  gather_facts: False
  tasks:
    - name: Create site within Netbox with only required information
      netbox_site:
        netbox_url: http://netbox.local
        netbox_token: thisIsMyToken
        data:
          name: Test - Colorado
        state: present

    - name: Delete site within netbox
      netbox_site:
        netbox_url: http://netbox.local
        netbox_token: thisIsMyToken
        data:
          name: Test - Colorado
        state: absent

    - name: Create site with all parameters
      netbox_site:
        netbox_url: http://netbox.local
        netbox_token: thisIsMyToken
        data:
          name: Test - California
          status: Planned
          region: Test Region
          tenant: Test Tenant
          facility: EquinoxCA7
          asn: 65001
          time_zone: America/Los Angeles
          description: This is a test description
          physical_address: Hollywood, CA, 90210
          shipping_address: Hollywood, CA, 90210
          latitude: 10.100000
          longitude: 12.200000
          contact_name: Jenny
          contact_phone: 867-5309
          contact_email: jenny@changednumber.com
          comments: ### Placeholder
        state: present

Inputs

    
data:
    description:
    - Defines the site configuration
    required: true
    suboptions:
      asn:
        description:
        - The ASN associated with the site
        type: int
      comments:
        description:
        - Comments for the site. This can be markdown syntax
        type: str
      contact_email:
        description:
        - Contact email for site
        type: str
      contact_name:
        description:
        - Name of contact for site
        type: str
      contact_phone:
        description:
        - Contact phone number for site
        type: str
      custom_fields:
        description:
        - must exist in Netbox
        type: dict
      description:
        description:
        - The description of the prefix
        type: str
      facility:
        description:
        - Data center provider or facility, ex. Equinix NY7
        type: str
      latitude:
        description:
        - Latitude in decimal format
        type: int
      longitude:
        description:
        - Longitude in decimal format
        type: int
      name:
        description:
        - Name of the site to be created
        required: true
        type: str
      physical_address:
        description:
        - Physical address of site
        type: str
      region:
        description:
        - The region that the site should be associated with
        type: str
      shipping_address:
        description:
        - Shipping address of site
        type: str
      status:
        choices:
        - Active
        - Planned
        - Retired
        description:
        - Status of the site
        type: str
      tags:
        description:
        - Any tags that the prefix may need to be associated with
        type: list
      tenant:
        description:
        - The tenant the site will be assigned to
        type: str
      time_zone:
        description:
        - Timezone associated with the site, ex. America/Denver
        type: str

state:
    choices:
    - absent
    - present
    default: present
    description:
    - Use C(present) or C(absent) for adding or removing.
    type: str

netbox_url:
    description:
    - URL of the Netbox instance resolvable by Ansible control host
    required: true
    type: str

netbox_token:
    description:
    - The token created within Netbox to authorize API access
    required: true
    type: str

validate_certs:
    default: 'yes'
    description:
    - 'If C(no), SSL certificates will not be validated.

      This should only be used on personally controlled sites using self-signed certificates.

      '
    type: bool

Outputs

msg:
  description: Message indicating failure or info about what has been achieved
  returned: always
  type: str
site:
  description: Serialized object as created or already existent within Netbox
  returned: on creation
  type: dict