Home

Awesome

Alibaba Cloud Collection

The Ansible Alibaba Cloud collection includes a variety of Ansible content to help automate the management of Alibaba Cloud instances. This collection is maintained by the Alibaba Cloud team.

<a href="https://shell.aliyun.com/?action=git_open&git_repo=https://code.aliyun.com/labs/tutorial-cli-ansible.git&tutorial=tutorial-zh.md#/" target="try_ansible_in_cloudshell"> <img src="https://img.alicdn.com/tfs/TB1wt1zq9zqK1RjSZFpXXakSXXa-1066-166.png" width="180" /> </a>

Python version compatibility

This collection requires Python 3.6 or greater.

Installing this collection

You can install the Alibaba Cloud collection with the Ansible Galaxy CLI:

  1. create a requirements.txt file with the following:
    collections:
      - name: https://github.com/alibaba/alibaba.alicloud.git
        type: git
        branch: master
    
  2. running the commond to install alibaba.alicloud using requirements.txt file:
    ansible-galaxy collection install -r requirements.txt
    

Using this collection

You can either call modules by their Fully Qualified Collection Namespace (FQCN), such as alibaba.alicloud.ali_vpc, or you can call modules by their short name if you list the alibaba.alicloud collection in the playbook's collections keyword:

---
- 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

plugins/modules

There are several files in the module directory, and these files describe some function that can operate alicloud products.

lib/ansible/module_utils

In the module utils directory, the file alicloud_ecs.py identifies and gains playbook params, and provides this params to modules/*.py. In addition, this file implements connection between ansible and Alicloud API via footmark.

examples

There are some playbooks to create some alicloud resource or build infrastructure architecture.

Execute playbook

Refrence

Ansible Document: https://docs.ansible.com/ansible/latest/

Ansible Alicloud: Docs Details