Skip to content

Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications — automate in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com/ansible/

License

lenovo/ansible.lenovo-tacp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ThinkAgile CP Ansible Modules

This repository contains Lenovo-created Ansible modules for automating workflows with the ThinkAgile CP composable cloud platform.

Getting Started

The following instructions will show you how to download and install the tacp_info, tacp_instance, and tacp_network modules into your existing Ansible environment.

Requirements

  • Python >= 3.6
  • python3-pip
  • ansible
  • tacp

Installation

Download this git respository.

cd ~

git clone https://github.com/lenovo/ansible.lenovo-tacp.git

cd ./ansible.lenovo-tacp

The tacp modules and module_utils files can be added to any of the following dfirectories:

  • any directory added to the ANSIBLE_LIBRARY environment variable ($ANSIBLE_LIBRARY takes a colon-separated list like $PATH). If this method is used, an ANSIBLE_MODULE_UTILS environment variable must also be set pointing to the copied module_utils directory.
  • ~/.ansible/plugins/
  • On CentOS/RHEL systems, /usr/share/ansible/plugins/
  1. For example, create the ~/.ansible/plugins/ directory:

$ mkdir -p ~/.ansible/plugins/

  1. Create the ~/.ansible/plugins/module_utils and ~/.ansible/plugins/modules/cloud directories:

$ mkdir -p ~/.ansible/plugins/module_utils ~/.ansible/plugins/modules/cloud

  1. Copy the module_utils/tacp_ansible/ directory from this ansible.lenovo-tacp repo into the local Ansible installation's module_utils/ directory. In this example the module files are copied to the /usr/share/ansible/plugins location, which requires sudo.

$ cp -R ./lib/ansible/module_utils/tacp_ansible ~/.ansible/plugins/module_utils

  1. Copy the modules/tacp/ directory from this ansible.lenovo-tacp repo into the local Ansible installation's modules/cloud/ directory.

$ cp -R ./lib/ansible/modules/tacp ~/.ansible/plugins/modules/cloud

  1. Verify the manual installation worked:
$ ansible-doc -t module tacp_instance
> TACP_INSTANCE    (/home/user/.ansible/plugins/modules/cloud/tacp/tacp_instance.py)

      This module can be used to create new application instances on the ThinkAgile CP cloud platform, as well as delete and modify power states of existing application instances. Currently this module cannot modify the resources of
      existing application instances aside from performing deletion and power state operations.
      .
      .
      .

Examples

tacp_info

tacp_instance

---
- name: Test tacp_instance Ansible module for ThinkAgile CP
  hosts: localhost
  gather_facts: false
  vars:
    api_key: SECRET_KEY_HERE
  tasks:
   - name: Create a basic VM on ThinkAgile CP
     tacp_instance:
       api_key: "{{ api_key }}"
       name: Basic_VM1
       state: started
       datacenter: Datacenter1
       migration_zone: Zone1
       template: CentOS 7.5 (64-bit) - Lenovo Template
       storage_pool: Pool1
       num_cpus: 1
       memory_mb: 4096
       disks:
       - name: Disk 0
         size_gb: 50
         boot_order: 1
       nics:
       - name: vNIC 0
         type: VNET
         network: VNET-TEST
         boot_order: 2

   - name: Create a shutdown 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: Datacenter1
       migration_zone: Zone1
       template: RHEL 7.4 (Minimal) - Lenovo Template
       storage_pool: Pool1
       num_cpus: 1
       memory_mb: 8192
       disks:
         - name: Disk 0
           size_gb: 50
           boot_order: 2
         - name: Disk 1
           size_gb: 200
           boot_order: 3
       nics:
         - name: vNIC 0
           type: VLAN
           network: VLAN-300
           boot_order: 1

   - name: Create a VM with multiple disks with limits, and two NICs with static
         MAC addresses, and don't power it on after creation
     tacp_instance:
       api_key: "{{ api_key }}"
       name: Basic_VM3
       state: stopped
       datacenter: Datacenter1
       migration_zone: Zone1
       template: RHEL 7.4 (Minimal) - Lenovo Template
       storage_pool: Pool1
       num_cpus: 1
       memory_mb: 8192
       disks:
         - name: Disk 0
           size_gb: 50
           boot_order: 2
         - name: Disk 1
           size_gb: 200
           boot_order: 3
       nics:
         - name: vNIC 0
           type: VLAN
           network: VLAN-300
           boot_order: 4
           firewall_override: Allow-All
         - name: vNIC 1
           type: VNET
           network: PXE-VNET
           boot_order: 1
           mac: b4:d1:35:00:00:01

     - name: Restart all of my Basic_VMs on ThinkAgile CP
       tacp_instance:
         api_key: "{{ api_key }}"
         name: "{{ instance }}"
         state: restarted
       loop:
         - Basic_VM1
         - Basic_VM2
         - Basic_VM3
       loop_control:
         loop_var: instance

     - name: Delete Basic_VM1 from ThinkAgile CP
       tacp_instance:
         api_key: "{{ api_key }}"
         name: Basic_VM1
         state: absent

     - name: Create a variety of VMs on TACP in a loop
       tacp_instance:
         api_key: "{{ api_key }}"
         name: "{{ instance.name }}"
         state: "{{ instance.state }}"
         datacenter: Datacenter2
         migration_zone: Zone2
         template: "{{ instance.template }}"
         storage_pool: Pool2
         num_cpus: "{{ instance.num_cpus }}"
         memory_mb: "{{ instance.memory_mb }}"
         disks:
           - name: Disk 0
             size_gb: 100
             boot_order: 1
         nics:
           - name: vNIC 0
             type: "{{ instance.network_type }}"
             network: "{{ instance.network_name }}"
             mac: "{{ instance.mac }}"
             boot_order: 2
       loop:
         - { name: CentOS VM 1,
             state: started,
             template: "CentOS 7.5 (64-bit) - Lenovo Template",
             num_cpus: 2,
             memory_mb: 4096,
             network_type: VLAN,
             network_name: VLAN-15,
             mac: b4:d1:35:00:0f:f0 }
         - { name: RHEL VM 11,
             state: stopped,
             template: "RHEL 7.4 (Minimal) - Lenovo Template",
             num_cpus: 6,
             memory_mb: 6144,
             network_type: VNET,
             network_name: Production-VNET,
             mac: b4:d1:35:00:0f:f1 }
         - { name: Windows Server 2019 VM 1,
             state: started,
             template: "Windows Server 2019 Standard - Lenovo Template",
             num_cpus: 8,
             memory_mb: 16384,
             network_type: VNET,
             network_name: Internal-VNET,
             mac: b4:d1:35:00:0f:f2 }
       loop_control:
         loop_var: instance

tacp_network

tacp_datacenter

Authors

Lenovo (@lenovo)

Xander Madsen (@xmadsen)

Marius Vigariu (@mariusvigariu)

License

GNU General Public License v3.0 or later

See COPYING to see the full text.

About

Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications — automate in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com/ansible/

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%