This topic describes how to use the ali_ros_stack module to update a stack by writing
Ansible playbook code. A VPC is used in the example.
Prerequisites
Ansible is installed on Linux with pip3 and configured.
Procedure
- Create a file named update_vpc.yml and open it in the visual editor.
- In edit mode, copy the following playbook code to the update_vpc.yml file:
Note For more information about the ali_ros_stack module parameters, see
Parameters.
- hosts: localhost
remote_user: root
tasks:
- name: Changed. Update Ros Stack
ali_ros_stack:
state: present
stack_name: vpc_2020-04-08_test
template: update_vpc.json
timeout_in_minutes: 60
template_parameters:
CidrBlock: 192.168.XX.XX/16
VpcName: UpdateVpc
- Save the file and exit the edit mode.
- Create a file named update_vpc.json and open it in the visual editor.
- In edit mode, copy the following playbook code to the update_vpc.json file:
{
"ROSTemplateFormatVersion": "2015-09-01",
"Parameters": {
"VpcName": {
"Type": "String",
"Description": "Vpc Name",
"Label": "Vpc Name"
},
"CidrBlock": {
"Type": "String",
"Description": "Vpc CidrBlock",
"Label": "Vpc CidrBlock"
}
},
"Resources": {
"Vpc": {
"Type": "ALIYUN::ECS::VPC",
"Properties": {
"CidrBlock": {
"Ref": "CidrBlock"
},
"VpcName": {
"Ref": "VpcName"
}
}
}
}
}
- Save the file and exit the edit mode.
- Run the Ansible playbook to update a VPC.
ansible-playbook update_vpc.yml -v