Skip to main content

Ansible Modules: tacp_instance

The tacp_instance module creates or deletes application instances from the ThinkAgile CP stack.

The tacp_instance module provides the following functions:

  • Create application instances

    • Assign VDCs

    • Assign Migration Zones

    • Assign source application template

    • Assign virtual CPU and memory resources

    • Set boot order

    • Assign multiple storage disks

    • Assign multiple vNICs

      • Static or automatic MAC address assignment

      • Firewall override

    • Assign application group

    • Change the power state of application instances

    • Assign vNICs

    • Assign storage disks

    • Configure a bandwidth limit

    • Configure an IOPS (input/output operations per second) limit

  • Delete application instances

  • Modify an application instance

    • Add a new vDisk to an instance

    • Remove an existing vDisk from an instance (set state to absent)

    • Increase existing vDisk size

    • Edit bandwidth limits and IOPS limits for a vDisk

    • Remove an existing vNIC from an instance (set state to absent)

    • Update the boot order of an instances (vDisks and vNICs)

For an overview of application instances in ThinkAgile CP, see the following topic:

Application instances

Sample Playbooks

Note
  • For more information about the parameters used with the tacp_instance module, run the following command:

    ansible-doc -t module tacp_instance
  • For more information about obtaining the API key, which is used to access to the ThinkAgile CP Cloud Controller, see the following topic:

    Authorize Token

Create an application instance (virtual machine) with basic settings

The following is an Ansible playbook in .yml format that creates a new virtual machine (VM) with basic settings on the ThinkAgile CP stack:

---
- name: Create a VM on ThinkAgile CP
hosts: localhost
gather_facts: false
vars:
api_key: <api-key-created-from-the-developer-options-page>
tasks:
- name: Create a basic VM on ThinkAgile CP
tacp_instance:
api_key: "{{ api_key }}"
name: Basic_VM1
state: started
datacenter: <VDC-name>
migration_zone: <migration-zone-name>
template: CentOS 7.5 (64-bit) - Lenovo Template
storage_pool: Pool1
vcpu_cores: 1
memory: 4096MB
disks:
- name: <vDisk-name>
size_gb: 50
boot_order: 1
nics:
- name: <vNIC-name>
type: VNET
network: <network-name>
boot_order: 2

Create an application instance (virtual machine), assign multiple disks, and set the boot order

The following Ansible playbook creates a new virtual machine in the shut down state, assigns multiple storage disks, and sets its NIC as the first boot device:

---
- name: Create a shut down VM with multiple disks and set its NIC to the first boot device
hosts: localhost
gather_facts: false
vars:
api_key: <api-key-created-from-the-developer-options-page>
tasks:
- name: Create a shut down VM with multiple disks and set its NIC to the first boot device
tacp_instance:
api_key: "{{ api_key }}"
name: Basic_VM2
state: shutdown
datacenter: <VDC-name>
migration_zone: <migration-zone-name>
template: RHEL 7.4 (Minimal) - Lenovo Template
storage_pool: <storage-pool-name>
vcpu_cores: 1
memory: 8G
disks:
- name: <vDisk-name>
size_gb: 50
boot_order: 2
- name: <vDisk-name>1
size_gb: 200
boot_order: 3
nics:
- name: <vNIC-name>
type: VLAN
network: <network-name>
boot_order: 1

Create an application instance (virtual machine), assign multiple disks with bandwidht and IOPS limits, and configure multiple vNICs

The following Ansible playbook creates a new virtual machine in the shut down state, assigns multiple storage disks with bandwidth and IOPS limits, and configures two NICs with static MAC addresses:

---
- name: Create a shut down VM with multiple disks with limits and two NICs with static MAC addresses
hosts: localhost
gather_facts: false
vars:
api_key: <api-key-created-from-the-developer-options-page>
tasks:
- name: Create a shut down VM with multiple disks with limits and two NICs with static MAC addresses
api_key: "{{ api_key }}"
name: Basic_VM3
state: shutdown
datacenter: <VDC-name>
migration_zone: <migration-zone-name>
template: RHEL 7.4 (Minimal) - Lenovo Template
storage_pool: <storage-pool-name>
vcpu_cores: 1
memory: 8GB
disks:
- name: <vDisk-name>
size_gb: 50
boot_order: 2
iops_limit: 200
- name: <vDisk-name>
size_gb: 200
boot_order: 3
bandwidth_limit: 10000000
nics:
- name: <vNIC-name>
type: VLAN
network: <network-name>
boot_order: 4
firewall_override: Allow-All
- name: <vNIC-name>
type: VNET
network: <network-name>
boot_order: 1
mac_address: <MAC-address>

Restart application instances using a loop

The following Ansible playbook restarts application instances:

---
- name: Restart all basic VMs on ThinkAgile CP
hosts: localhost
vars:
api_key: <api-key-created-from-the-developer-options-page>
tasks:
- name: Restart all basic VMs on ThinkAgile CP
tacp_instance:
api_key: "{{ api_key }}"
name: "{{ instance }}"
state: restarted
loop:
- <basic-application-instance-1>
- <basic-application-instance-2>
- <basic-application-instance-3>

loop_control:
loop_var: instance

Delete an application instance

The following Ansible playbook deletes an application instance:

---
- name: Delete Basic_VM1 from ThinkAgile CP
hosts: localhost
vars:
api_key: <api-key-created-from-the-developer-options-page>
tasks:
- name: Delete Basic_VM1 from ThinkAgile CP
tacp_instance:
api_key: "{{ api_key }}"
name: <basic-application-instance>1
state: absent

Create application instances using a loop

The following Ansible playbook creates multiple and varied virtual machines using a loop

---
- name: Create a variety of VMs on ThinkAgile CP in a loop
hosts: localhost
vars:
api_key: <api-key-created-from-the-developer-options-page>
tasks:
- name: Create a variety of VMs on ThinkAgile CP in a loop
tacp_instance:
api_key: "{{ api_key }}"
name: "{{ instance.name }}"
state: "{{ instance.state }}"
datacenter: <VDC-name>
migration_zone: <migration-zone-name>
template: "{{ instance.template }}"
storage_pool: <storage-pool-name>
vcpu_cores: "{{ instance.vcpu_cores }}"
memory: "{{ instance.memory }}"
disks:
- name: <vDisk-name>
size_gb: 100
boot_order: 1
nics:
- name: <vNIC-name>
type: "{{ instance.network_type }}"
network: "{{ instance.network_name }}"
mac_address: "{{ instance.mac_address }}"
boot_order: 2
loop:
- { name: CentOS VM 1,
state: started,
template: "CentOS 7.5 (64-bit) - Lenovo Template",
vcpu_cores: 2,
memory: 4096MB,
network_type: VLAN,
network_name: <network-name>,
mac_address: <MAC-address> }
- { name: RHEL VM 11,
state: stopped,
template: "RHEL 7.4 (Minimal) - Lenovo Template",
vcpu_cores: 6,
memory: 6g,
network_type: VNET,
network_name: P<network-name>,
mac_address: <MAC-address> }
- { name: Windows Server 2019 VM 1,
state: started,
template: "Windows Server 2019 Standard - Lenovo Template",
vcpu_cores: 8,
memory: 16GB,
network_type: VNET,
network_name: <network-name>,
mac_address: <MAC-address> }
loop_control:
loop_var: instance