All Products
Search
Document Center

Resource Orchestration Service:Delete a stack using the ali_ros_stack module

Last Updated:Jun 16, 2026

You can write an Ansible playbook that uses the ali_ros_stack module to automatically delete a stack. This example demonstrates how to delete a virtual private cloud (VPC).

Prerequisites

The Ansible module is installed and configured on Linux using pip3.

Procedure

  1. Create a file named delete_vpc.yml and open it in the VI editor.
    vi delete_vpc.yml
  2. In edit mode, paste the following sample playbook into the delete_vpc.yml
    Note For more information about the parameters of the ali_ros_stack module, see Parameter description.
    - hosts: localhost
      remote_user: root
      tasks:
        - name: Changed. Delete the ROS stack
          ali_ros_stack:
            state: absent
            stack_name: vpc_2020-04-08_test
  3. Save the file and exit edit mode.
  4. Run the Ansible playbook to delete the VPC-connected instance.
    ansible-playbook delete_vpc.yml -v