The Ansible Aliyun ApsaraStack collection includes a variety of Ansible content to help automate the management of Aliyun ApsaraStack instances. This collection is maintained by the Aliyun ApsaraStack team.
This collection requires Python 3.6 or greater.
You can install the Aliyun ApsaraStack collection with the Ansible Galaxy CLI:
ansible-galaxy collection install alibaba.apsarastackalso you can also install it through source code:
- create a
requirements.txtfile with the following:collections: - name: https://github.com/aliyun/apsarastack-ansible.git#/src/ansible_collections/alibaba type: git branch: master
- running the commond to install alibaba.apsarastack using
requirements.txtfile:ansible-galaxy collection install -r requirements.txt
The python module dependencies are not installed by
ansible-galaxy. They can be manually installed using pip:pip install -r requirements.txtor:
pip install footmark jmespath==0.10.0
You can either call modules by their Fully Qualified Collection Namespace (FQCN), such as alibaba.apsarastack.ali_vpc, or you can call modules by their short name if you list the alibaba.apsarastack collection in the playbook's collections keyword:
---
- name: Using module alibaba.apsarastack.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 apsarastack-ecs-vpc."
tasks:
- name: Create a new vpc with user_cidrs
alibaba.apsarastack.ali_vpc:
popgw_domain: "xxxx"
region: "xxxx"
access_key: "xxxx"
secret_key: "xxxx"
organization_id: "xxxx"
resourcegroupset_id: "xxxx"
cidr_block: '{{ vpc_cidr }}'
vpc_name: '{{ name }}-user_cidrs'
description: '{{ vpc_description }}'
user_cidrs:
- 172.16.100.0/24
- 172.16.101.0/24There are several files in the module directory, and these files describe some function that can operate apsarastack products.
ali_disk.py: Create, Attach, Detach, or Delete a disk in ECSali_disk_info.py: Query information about a disk in ECSali_vpc.py: Create or Delete a VPCali_vpc_info.py: Query information about a VPCali_vswitch.py: Create or Delete a VSwitchali_vswitch_info.py: Query information about a VSwitchali_dns_domain.py: Create, Delete, or Update a DNS domainali_dns_domain_info.py: Query information about a DNS domainali_ecs_tag.py: Manage tags for ECS instances and disks (Create, Delete, Update, or Query)ali_eip.py: Allocate or Release an Elastic IP addressali_eip_info.py: Query information about an Elastic IP addressali_image.py: Create or Delete a custom imageali_image_info.py: Query information about an imageali_instance.py: Create, Start, Stop, Restart, or Terminate an ECS instanceali_instance_info.py: Query information about an ECS instanceali_instance_type_facts.py: Query available ECS instance typesali_rds_account.py: Create or Delete an RDS accountali_rds_account_info.py: Query information about an RDS accountali_rds_backup.py: Create or Delete an RDS backupali_rds_backup_info.py: Query information about an RDS backupali_rds_database.py: Create or Delete an RDS databaseali_rds_database_info.py: Query information about an RDS databaseali_rds_instance.py: Create or Delete an RDS instanceali_rds_instance_info.py: Query information about an RDS instanceali_route_entry.py: Add or Remove a route entryali_route_entry_info.py: Query information about a route entryali_security_group.py: Create or Delete a Security Groupali_security_group_info.py: Query information about a Security Groupali_slb_lb.py: Create or Delete a Load Balancerali_slb_lb_info.py: Query information about a Load Balancerali_slb_listener.py: Create or Delete a Load Balancer listenerali_slb_listener_info.py: Query information about a Load Balancer listenerali_slb_server.py: Add or Remove backend servers from a Load Balancerali_slb_server_info.py: Query backend servers of a Load Balancerali_slb_tag.py: Manage tags for a Load Balancer (Create, Delete, Update, or Query)ali_slb_vsg.py: Create or Delete a Virtual Server Group for a Load Balancerali_slb_vsg_info.py: Query information about a Virtual Server Groupali_ess_instance.py: Create or Delete an Auto Scaling instanceali_ess_configuration.py: Create or Delete an Auto Scaling configurationali_ess_group.py: Create or Delete an Auto Scaling groupali_ess_rule.py: Create or Delete an Auto Scaling ruleali_ess_task.py: Query or Manage Auto Scaling tasksali_ram_group.py: Create or Delete a RAM groupali_ram_group_info.py: Query information about a RAM groupali_ram_login_profile_info.py: Query login profile details for a RAM userali_ram_login_profile.py: Create or Delete a RAM login profileali_ram_policy_info.py: Query information about a RAM policyali_ram_policy.py: Create or Delete a RAM policyali_ram_role_info.py: Query information about a RAM roleali_ram_role.py: Create or Delete a RAM roleali_ram_user_info.py: Query information about a RAM userali_ram_user.py: Create or Delete a RAM userali_oss_bucket_info.py: Query information about an OSS bucketali_oss_bucket.py: Create or Delete an OSS bucketali_oss_object_info.py: Query information about an OSS objectali_oss_object.py: Upload, Delete, or Manage an OSS object
In the module utils directory, the file apsarastack_ecs.py identifies and gains playbook params, and provides this params to modules/*.py. In addition, this file implements connection between ansible and Apsarastack API via footmark.
There are some playbooks to create some apsarastack resource or build infrastructure architecture.
-
Input your apsarastack access key in the playbook or set environment variable:
APSARASTACK_ACCESS_KEYandAPSARASTACK_SECRET_KEY). -
Input others resource params in the playbook.
-
execute ansible-playbook command as follows:
$ ansible-playbook xxx.yml
Ansible Document: https://docs.ansible.com/ansible/latest/
Ansible Apsarastack: Docs Details