server – Create/Delete the Virtual Machines from PowerVC.

Synopsis

This playbook helps in performing the Create and Delete VM operations.

Parameters

name (optional, str, None)

Name of the Server

flavor (optional, str, None)

Name of the flavor

image (optional, str, None)

Name of the image

host (optional, str, None)

MTMS of the host

collocation_rule_name (optional, str, None)

Name of the collocation_rule_name

max_count (optional, str, None)

The maximum number of servers to create.

scg_id (optional, str, None)

ID of the Storage Connectivity Group.

virtual_serial_number (optional, str, None)

Virtual Serial Number (VSN) to be assigned to the VM.

Valid values are auto, none, or a valid 7-character alpha-numeric VSN.

key_name (optional, str, None)

The key pair name to be used when creating a instance.

user_data (optional, str, None)

activation_input data which is passed to the instance.

network (optional, str, None)

Name or ID of a network to attach this instance to. A simpler version of the nics parameter, only one of network or nics should be supplied.

This server attribute cannot be updated.

nics (optional, list, [])

A list of networks to which the instance’s interface should be attached. Networks may be referenced by network_id/network_name

image_volume_override (optional, list, [])

A list of volume id and templated id which will be attached to the VM. Referenced by volume_id and template_id.

volume_name (optional, list, [])

A list of volumes that are to be attached to the VM

pmem_volume (optional, list, None)

List of Persistent Memory (PMEM) volumes to attach to the VM.

state (True, str, None)

VM Operation to be performed

Examples

- name: PowerVC Create VM Playbook
  hosts: localhost
  gather_facts: no
  vars:
   auth:
    auth_url: https://<POWERVC>:5000/v3
    project_name: PROJECT-NAME
    username: USERID
    password: PASSWORD
    project_domain_name: PROJECT_DOMAIN_NAME
    user_domain_name: USER_DOMAIN_NAME
    - name: Create a new instance and attaches to a network
      ibm.powervc.server:
        auth: "{{ auth }}"
        name: "VM_NAME"
        image: "VM_IMAGE"
        host: "HOST_ID"
        timeout: 200
        max_count: "COUNT"
        collocation_rule_name: "COLLOCATION_RULE_NAME"
        nics:
          - network_name: "NETWORK_NAME"
            fixed_ip: "FIXED_IP" # "fixed_ip: 192.168.10.20"
        image_volume_override:
          - volume_id: "VOLUME_ID"
            template_id: "TEMPLATE_ID"
        flavor: "FLAVOR_NAME"
        volume_name: ["VOLUME_1","VOLUME_2"]
        state: present
        validate_certs: no
      register: result
    - name: Display server info
      debug: var=result

- name: PowerVC Create VM Playbook
  hosts: localhost
  gather_facts: no
    - name: Create a new instance and attaches to a network
      ibm.powervc.server:
        cloud: "CLOUD_NAME"
        name: "VM_NAME"
        image: "VM_IMAGE"
        host: "HOST_ID"
        timeout: 200
        max_count: "COUNT"
        collocation_rule_name: "COLLOCATION_RULE_NAME"
        user_data: |
          #!/bin/sh
          apt update
          apt -y full-upgrade
        nics:
          - network_name: "NETWORK_NAME"
            fixed_ip: "FIXED_IP" # "fixed_ip: 192.168.10.20"
        image_volume_override:
          - volume_id: "VOLUME_ID"
            template_id: "TEMPLATE_ID"
        flavor: "FLAVOR_NAME"
        volume_name: ["VOLUME_1","VOLUME_2"]
        state: present
        validate_certs: false
      register: result
    - name: Display server info
      debug: var=result

- name: PowerVC Create VM Playbook with Storage Connectivity Group
  hosts: localhost
  gather_facts: no
    - name: Create a new instance and attaches to a network
      ibm.powervc.server:
        cloud: "CLOUD_NAME"
        name: "VM_NAME"
        image: "VM_IMAGE"
        host: "HOST_ID"
        timeout: 200
        max_count: "COUNT"
        collocation_rule_name: "COLLOCATION_RULE_NAME"
        scg_id: "STORAGE_CONNECTIVITY_GROUP_ID"
        nics:
          - network_name: "NETWORK_NAME"
            fixed_ip: "FIXED_IP" # "fixed_ip: 192.168.10.20"
        image_volume_override:
          - volume_id: "VOLUME_ID"
            template_id: "TEMPLATE_ID"
        flavor: "FLAVOR_NAME"
        volume_name: ["VOLUME_1","VOLUME_2"]
        state: present
        validate_certs: false
      register: result
    - name: Display server info
      debug: var=result

- name: PowerVC Create VM Playbook with Storage Connectivity Group
  hosts: localhost
  gather_facts: no
    - name: Create a new instance and attaches to a network
      ibm.powervc.server:
        cloud: "CLOUD_NAME"
        name: "VM_NAME"
        image: "VM_IMAGE"
        host: "HOST_ID"
        timeout: 200
        max_count: "COUNT"
        collocation_rule_name: "COLLOCATION_RULE_NAME"
        scg_id: "STORAGE_CONNECTIVITY_GROUP_ID"
        nics:
          - network_name: "NETWORK_NAME"
            fixed_ip: "FIXED_IP" # "fixed_ip: 192.168.10.20"
        image_volume_override:
          - volume_id: "VOLUME_ID"
            template_id: "TEMPLATE_ID"
        flavor: "FLAVOR_NAME"
        volume_name: ["VOLUME_1","VOLUME_2"]
        state: present
        validate_certs: false
      register: result
    - name: Display server info
      debug: var=result

- name: PowerVC Create VM Playbook with custom VSN
  hosts: localhost
  gather_facts: no
  tasks:
    - name: Create VM with custom VSN
      ibm.powervc.server:
        cloud: "CLOUD_NAME"
        name: "VM_NAME"
        image: "VM_IMAGE"
        flavor: "FLAVOR_NAME"
        host: "HOST_ID"
        virtual_serial_number: "ABCD001"
        nics:
          - network_name: "NETWORK_NAME"
        state: present
        validate_certs: false
      register: result
    - name: Display server info
      debug:
        var: result

- name: PowerVC Create VM Playbook with auto VSN
  hosts: localhost
  gather_facts: no
  tasks:
    - name: Create VM with auto VSN
      ibm.powervc.server:
        cloud: "CLOUD_NAME"
        name: "VM_NAME"
        image: "VM_IMAGE"
        flavor: "FLAVOR_NAME"
        host: "HOST_ID"
        virtual_serial_number: "auto"
        nics:
          - network_name: "NETWORK_NAME"
        state: present
        validate_certs: false
      register: result
    - name: Display server info
      debug:
        var: result

- name: PowerVC Create VM Playbook with Persistent memory
  hosts: localhost
  gather_facts: no
  tasks:
    - name: Create VM with auto VSN
      ibm.powervc.server:
        cloud: "CLOUD_NAME"
        name: "VM_NAME"
        image: "VM_IMAGE"
        flavor: "FLAVOR_NAME"
        host: "HOST_ID"
        nics:
          - network_name: "NETWORK_NAME"
        pmem_volume:
         - name: pmem1
           size: 256
           affinity: true
           device: DRAM
         - name: pmem2
           size: 256
           affinity: false
           device: DRAM
        state: present
        validate_certs: false
      register: result
    - name: Display server info
      debug:
        var: result

- name: PowerVC Delete VM Playbook
  hosts: localhost
  gather_facts: no
  vars:
   auth:
    auth_url: https://<POWERVC>:5000/v3
    project_name: PROJECT-NAME
    username: USERID
    password: PASSWORD
    project_domain_name: PROJECT_DOMAIN_NAME
    user_domain_name: USER_DOMAIN_NAME
    - name: Delete the VM based on the input name provided
      ibm.powervc.server:
        auth: "{{ auth }}"
        name: "VM_NAME"
        state: absent
      register: result
    - name: Display server info
      debug: var=result

Status

  • This module is not guaranteed to have a backwards compatible interface. [preview]

  • This module is maintained by PowerVC.

Authors

  • Karteesh Kumar Vipparapelli (@vkarteesh)