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

create or cancel a virtual instance in SoftLayer

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

Authors: Matt Colton (@mcltn)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.27

Description

Creates or cancels SoftLayer instances.

When created, optionally waits for it to be 'running'.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Build instance
  hosts: localhost
  gather_facts: no
  tasks:
  - name: Build instance request
    sl_vm:
      hostname: instance-1
      domain: anydomain.com
      datacenter: dal09
      tags: ansible-module-test
      hourly: yes
      private: no
      dedicated: no
      local_disk: yes
      cpus: 1
      memory: 1024
      disks: [25]
      os_code: UBUNTU_LATEST
      wait: no
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Build additional instances
  hosts: localhost
  gather_facts: no
  tasks:
  - name: Build instances request
    sl_vm:
      hostname: "{{ item.hostname }}"
      domain: "{{ item.domain }}"
      datacenter: "{{ item.datacenter }}"
      tags: "{{ item.tags }}"
      hourly: "{{ item.hourly }}"
      private: "{{ item.private }}"
      dedicated: "{{ item.dedicated }}"
      local_disk: "{{ item.local_disk }}"
      cpus: "{{ item.cpus }}"
      memory: "{{ item.memory }}"
      disks: "{{ item.disks }}"
      os_code: "{{ item.os_code }}"
      ssh_keys: "{{ item.ssh_keys }}"
      wait: "{{ item.wait }}"
    with_items:
      - hostname: instance-2
        domain: anydomain.com
        datacenter: dal09
        tags:
          - ansible-module-test
          - ansible-module-test-slaves
        hourly: yes
        private: no
        dedicated: no
        local_disk: yes
        cpus: 1
        memory: 1024
        disks:
          - 25
          - 100
        os_code: UBUNTU_LATEST
        ssh_keys: []
        wait: True
      - hostname: instance-3
        domain: anydomain.com
        datacenter: dal09
        tags:
          - ansible-module-test
          - ansible-module-test-slaves
        hourly: yes
        private: no
        dedicated: no
        local_disk: yes
        cpus: 1
        memory: 1024
        disks:
          - 25
          - 100
        os_code: UBUNTU_LATEST
        ssh_keys: []
        wait: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Cancel instances
  hosts: localhost
  gather_facts: no
  tasks:
  - name: Cancel by tag
    sl_vm:
      state: absent
      tags: ansible-module-test

Inputs

    
cpus:
    description:
    - Count of cpus to be assigned to new virtual instance.
    required: true

tags:
    description:
    - Tag or list of tags to be provided to a virtual instance.

wait:
    default: 'yes'
    description:
    - Flag used to wait for active status before returning.
    type: bool

disks:
    default:
    - 25
    description:
    - List of disk sizes to be assigned to new virtual instance.
    required: true

state:
    choices:
    - absent
    - present
    default: present
    description:
    - Create, or cancel a virtual instance.
    - Specify C(present) for create, C(absent) to cancel.

domain:
    description:
    - Domain name to be provided to a virtual instance.

hourly:
    default: 'yes'
    description:
    - Flag to determine if the instance should be hourly billed.
    type: bool

memory:
    description:
    - Amount of memory to be assigned to new virtual instance.
    required: true

os_code:
    description:
    - OS Code to be used for new virtual instance.

private:
    default: 'no'
    description:
    - Flag to determine if the instance should be private only.
    type: bool

hostname:
    description:
    - Hostname to be provided to a virtual instance.

image_id:
    description:
    - Image Template to be used for new virtual instance.

post_uri:
    description:
    - URL of a post provisioning script to be loaded and executed on virtual instance.

ssh_keys:
    description:
    - List of ssh keys by their Id to be assigned to a virtual instance.

dedicated:
    default: 'no'
    description:
    - Flag to determine if the instance should be deployed in dedicated space.
    type: bool

nic_speed:
    default: 10
    description:
    - NIC Speed to be assigned to new virtual instance.

wait_time:
    default: 600
    description:
    - Time in seconds before wait returns.

datacenter:
    description:
    - Datacenter for the virtual instance to be deployed.

local_disk:
    default: 'yes'
    description:
    - Flag to determine if local disk should be used for the new instance.
    type: bool

instance_id:
    description:
    - Instance Id of the virtual instance to perform action option.

public_vlan:
    description:
    - VLAN by its Id to be assigned to the public NIC.

private_vlan:
    description:
    - VLAN by its Id to be assigned to the private NIC.