netbox_community.ansible_modules.netbox_virtual_machine (0.1.10) — module

Create, update or delete virtual_machines within Netbox

| "added in version" 0.1.0 of netbox_community.ansible_modules"

Authors: Gaelle MANGIN (@gmangin)

preview | supported by community

Install collection

Install with ansible-galaxy collection install netbox_community.ansible_modules:==0.1.10


Add to requirements.yml

  collections:
    - name: netbox_community.ansible_modules
      version: 0.1.10

Description

Creates, updates or removes virtual_machines from Netbox


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Test Netbox modules"
  connection: local
  hosts: localhost
  gather_facts: False
  tasks:
    - name: Create virtual machine within Netbox with only required information
      netbox_virtual_machine:
        netbox_url: http://netbox.local
        netbox_token: thisIsMyToken
        data:
          name: Test Virtual Machine
          cluster: test cluster
        state: present

    - name: Delete virtual machine within netbox
      netbox_virtual_machine:
        netbox_url: http://netbox.local
        netbox_token: thisIsMyToken
        data:
          name: Test Virtual Machine
        state: absent

    - name: Create virtual machine with tags
      netbox_virtual_machine:
        netbox_url: http://netbox.local
        netbox_token: thisIsMyToken
        data:
          name: Another Test Virtual Machine
          cluster: test cluster
          site: Test Site
          tags:
            - Schnozzberry
        state: present

    - name: Update vcpus, memory and disk of an existing virtual machine
      netbox_virtual_machine:
        netbox_url: http://netbox.local
        netbox_token: thisIsMyToken
        data:
          name: Test Virtual Machine
          cluster: test cluster
          vcpus: 8
          memory: 8
          disk: 8
        state: present

Inputs

    
data:
    description:
    - Defines the virtual machine configuration
    required: true
    suboptions:
      cluster:
        description:
        - The name of the cluster attach to the virtual machine
        required: true
      disk:
        description:
        - Disk of the virtual machine (GB)
      memory:
        description:
        - Memory of the virtual machine (MB)
      name:
        description:
        - The name of the virtual machine
        required: true
      platform:
        description:
        - The platform of the virtual machine
      primary_ip4:
        description:
        - Primary IPv4 address assigned to the virtual machine
      primary_ip6:
        description:
        - Primary IPv6 address assigned to the virtual machine
      rack:
        description:
        - The name of the rack to assign the virtual machine to
      site:
        description:
        - The name of the site attach to the virtual machine
      status:
        choices:
        - Active
        - Offline
        - Staged
        description:
        - The status of the virtual machine
      tags:
        description:
        - Any tags that the virtual machine may need to be associated with
      tenant:
        description:
        - The tenant that the virtual machine will be assigned to
      vcpus:
        description:
        - Number of vcpus of the virtual machine
      virtual_machine_role:
        description:
        - The role of the virtual machine

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

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

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

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
virtual machine:
  description: Serialized object as created or already existent within Netbox
  returned: success (when I(state=present))
  type: dict