Project Introduction: Ansible Alibaba Cloud Collection
The Ansible Alibaba Cloud Collection is an extensive toolkit designed to assist users in automating the management of Alibaba Cloud instances. This collection is curated and maintained by the Alibaba Cloud team, ensuring it is tailored specifically for the efficient management of Alibaba Cloud resources.
Python Version Compatibility
The collection is compatible with Python 3.6 or newer versions.
How to Install the Collection
Users can easily install this collection using the Ansible Galaxy CLI. Follow these simple steps:
- Create a
requirements.txt
file with the necessary details:collections: - name: https://github.com/alibaba/alibaba.alicloud.git type: git branch: master
- Use the following command to install the collection through the
requirements.txt
file:ansible-galaxy collection install -r requirements.txt
Utilizing the Collection
Modules in this collection can be invoked using their Fully Qualified Collection Namespace (FQCN), like alibaba.alicloud.ali_vpc
. Alternatively, if this collection is listed in the playbook's collections
keyword, users can call the modules by their short names.
Here's a basic example of using a module to create a new Virtual Private Cloud (VPC):
---
- name: Using module alibaba.alicloud.ali_vpc
hosts: localhost
remote_user: root
vars:
name: "ansible-testacc-ali_vpc-module"
vpc_cidr: "172.16.0.0/12"
vpc_description: "Create a new VPC resource via Ansible example alicloud-ecs-vpc."
roles:
- vpc
tasks:
- name: Create a new vpc with user_cidrs
alibaba.alicloud.ali_vpc:
cidr_block: '{{ vpc_cidr }}'
vpc_name: '{{ name }}-user_cidrs'
description: '{{ vpc_description }}'
user_cidrs:
- 172.16.100.0/24
- 172.16.101.0/24
Available Modules and Plugins
The collection boasts numerous modules capable of performing various operations on Alibaba Cloud products:
- ali_instance.py: Handles operations like creating, starting, stopping, restarting, or terminating an ECS instance, as well as security group management.
- ali_disk.py: Facilitates the creation, attachment, detachment, or deletion of ECS disks.
- ali_security_group.py: Supports the creation or deletion of security groups.
- ali_vpc.py: Manages the creation or deletion of VPCs.
- ali_vswitch.py: Dedicated to creating or deleting VSwitches.
- ali_route_entry.py: Manages the creation or deletion of route entries.
- ali_slb_lb.py: Allows the creation or deletion of load balancers.
- ali_slb_listener.py: Manages listeners on load balancers.
- ali_slb_server.py: Adds or removes backend servers from load balancers.
- ali_ess_group.py: Facilitates the creation or deletion of scaling groups.
- ali_ess_configuration.py: Manages scaling configurations.
- ali_ess_instance.py: Adds or removes ECS instances in a scaling group.
- ali_ess_task.py: Handles scheduled tasks for scaling activities.
- ali_ess_rule.py: Manages scaling rules.
- ali_eni.py: Supports the creation or deletion of network interfaces.
- ali_bucket.py: Facilitates the creation or deletion of OSS buckets.
- ali_bucket_object.py: Manages object uploads or downloads to/from OSS buckets.
Module Utilities
Within the module utilities directory lies alicloud_ecs.py
, which is crucial for parameter identification and interaction between playbooks and modules. It acts as a bridge, facilitating API connections to Alibaba Cloud via Footmark.
Example Playbooks
The collection includes various playbooks to guide users in creating resources or building infrastructure on Alibaba Cloud. Before executing a playbook, users must input their Alibaba Cloud access keys either directly in the playbook or set them as environment variables (ALICLOUD_ACCESS_KEY
and ALICLOUD_SECRET_KEY
).
Execute the playbook using:
$ ansible-playbook xxx.yml
Reference
For further details, users can consult the Ansible Documentation and the Ansible Alibaba Cloud Documentation.