Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cloud/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ This category of demos shows examples of multi-cloud provisioning and management
| [**Patch Cloud Stack in AWS**](docs/patch-cloud-stack.md) | Enterprise-grade patching workflow with EBS snapshots, parallel RHEL and Windows paths, automatic rollback on failure, and a consolidated compliance report. |
| [**Deploy Cloud Stack in AWS**](docs/deploy-cloud-stack.md) | One-click workflow to provision a full demo stack — VPC, keypair, and five VMs (2 Windows, 2 RHEL, 1 report server) — with inventory sync and VPC report. |
| [**Destroy Cloud Stack in AWS**](docs/cloud-destroy-stack.md) | Tear down all five stack VMs, VPC, and keypair created by Deploy Cloud Stack, then sync inventory. |
| [**Deploy a Storage Stack on AWS**](docs/deploy-storage-stack.md) | Build on the cloud stack with a RHEL 9 execution node and an Amazon FSx for NetApp ONTAP file system, wired into AAP so jobs run next to the storage. |
| [**Destroy a Storage Stack on AWS**](docs/cloud-destroy-storage-stack.md) | Delete the FSx ONTAP file system, deregister the execution node, and terminate its VM. |

### Jobs

Expand Down Expand Up @@ -106,6 +108,22 @@ The workflow:

**Note:** S3 report buckets created during deploy (`reports-pd-*`) are not deleted by this workflow.

### Deploy a Storage Stack on AWS

Run this after **Deploy Cloud Stack in AWS**, in the same region. It reuses that stack's keypair, subnet, and security group. Complete the survey (**AWS Region**, **Owner**, **Environment**, **Email**).

The workflow runs two branches in parallel:

1. Creates a RHEL 9 VM `aws-storage-node`, syncs inventory, and registers the VM as an AAP **execution node** in the `storage` instance group
2. Creates an Amazon FSx for NetApp ONTAP file system and adds it to **Ansible Product Demos Storage Inventory**
3. Checks, from the new node, that ONTAP answers and prints its version

**Prerequisites:** the **AWS**, **APD Machine Credential**, and **RHSM Registration** credentials configured, and the **FSx ONTAP** credential set to the `fsxadmin` password you want (setup seeds it with `REPLACEME`). See [Deploy a Storage Stack on AWS](docs/deploy-storage-stack.md) for details and troubleshooting.

### Destroy a Storage Stack on AWS

Use this workflow to remove a storage stack. Select the **same AWS Region** used for deploy. It deletes the FSx file system (and the data on it), deregisters the execution node, terminates the VM, and syncs inventory. Run **Destroy Cloud Stack in AWS** afterwards to remove the VPC. See [Destroy a Storage Stack on AWS](docs/cloud-destroy-storage-stack.md).

### Patch Cloud Stack in AWS

This workflow demonstrates enterprise-grade patching with snapshot safety, parallel RHEL/Windows paths, automatic rollback on failure, and a consolidated compliance report. It is designed to run against the VMs deployed by **Deploy Cloud Stack in AWS** and covers both operating systems in a single execution. Based on [jopaik/patch_demo](https://github.com/jopaik/patch_demo).
Expand Down
67 changes: 67 additions & 0 deletions cloud/check_fsx_ontap_endpoint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
# Verifies the FSx ONTAP management endpoints answer on HTTPS. Run it with
# "Ansible Product Demos Storage Inventory" so the job runs on the storage
# execution node, which can reach the VPC subnet (the AAP controller cannot).

- name: Check FSx ONTAP hosts exist in the inventory
hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Fail if there are no FSx ONTAP hosts
ansible.builtin.assert:
that: groups['fsx_ontap'] | default([]) | length > 0
fail_msg: >-
No hosts in the fsx_ontap group. Run Update FSx ONTAP Inventory first
and launch this job with Ansible Product Demos Storage Inventory.

- name: Wait for the FSx ONTAP management endpoints to respond
hosts: fsx_ontap
gather_facts: false
vars:
# From the FSx ONTAP credential, the same password create_fsx_ontap.yml set.
check_fsx_ontap_endpoint_user: "{{ fsx_ontap_username | default('fsxadmin', true) }}"
check_fsx_ontap_endpoint_password: "{{ fsx_ontap_password | default('', true) }}"
tasks:
- name: Fail if there is no usable password to query ONTAP with
ansible.builtin.assert:
that:
- check_fsx_ontap_endpoint_password | length > 0
- check_fsx_ontap_endpoint_password != 'REPLACEME'
fail_msg: >-
No fsxadmin password. Update the FSx ONTAP credential in AAP and attach it
to this job template.

- name: Wait for the management endpoint to answer on HTTPS
ansible.builtin.wait_for:
host: "{{ ansible_host }}"
port: 443
state: started
timeout: "{{ check_fsx_ontap_endpoint_timeout | default(600) }}"
delay: 10

# Uses the netapp.ontap collection, so a successful run also proves the
# collection works from this execution node. FSx ONTAP uses a self-signed
# certificate, hence validate_certs: false. The fsxadmin account is
# restricted: it may read the cluster version, but not cluster/software.
- name: Get the ONTAP version
netapp.ontap.na_ontap_rest_info:
hostname: "{{ ansible_host }}"
username: "{{ check_fsx_ontap_endpoint_user }}"
password: "{{ check_fsx_ontap_endpoint_password }}"
use_rest: always
https: true
validate_certs: false
gather_subset:
- cluster
fields:
- version
register: check_fsx_ontap_endpoint_cluster
until: check_fsx_ontap_endpoint_cluster is not failed
retries: 6
delay: 10

- name: Show the ONTAP version
ansible.builtin.debug:
msg: "{{ check_fsx_ontap_endpoint_cluster.ontap_info['cluster'].version.full }}"
...
50 changes: 50 additions & 0 deletions cloud/create_fsx_ontap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
- name: Create Amazon FSx for NetApp ONTAP File System
hosts: localhost
gather_facts: false

tasks:
# Deploy a Storage Stack on AWS asks for these once, using the Create VM
# variable names; use them when the FSx-specific ones are not set.
- name: Default variables from the shared workflow survey answers
ansible.builtin.set_fact:
"{{ item.key }}": "{{ lookup('ansible.builtin.vars', item.value) }}"
loop: "{{ _shared_defaults | dict2items }}"
when:
- lookup('ansible.builtin.vars', item.key, default='') | length == 0
- lookup('ansible.builtin.vars', item.value, default='') | length > 0
vars:
_shared_defaults:
create_fsx_ontap_aws_region: create_vm_aws_region
create_fsx_ontap_aws_owner_tag: create_vm_aws_owner_tag
create_fsx_ontap_aws_environment: vm_environment

- name: Fail if variables not defined
ansible.builtin.assert:
that:
- create_fsx_ontap_aws_vpc_subnet_name is defined
- create_fsx_ontap_aws_securitygroup_name is defined
- create_fsx_ontap_aws_name is defined
- create_fsx_ontap_aws_region is defined
- create_fsx_ontap_stack_name is defined
- create_fsx_ontap_aws_owner_tag is defined
- create_fsx_ontap_aws_environment is defined
fail_msg: "Required variables not set"

# The password comes from the FSx ONTAP credential (fsx_ontap_password), or
# create_fsx_ontap_admin_password. The credential is seeded with REPLACEME.
- name: Fail if there is no usable fsxadmin password
ansible.builtin.assert:
that:
- (create_fsx_ontap_admin_password | default(fsx_ontap_password | default('', true), true)) | length > 0
- (create_fsx_ontap_admin_password | default(fsx_ontap_password | default('', true), true)) != 'REPLACEME'
fail_msg: >-
No fsxadmin password. Update the FSx ONTAP credential in AAP with the
password to set (and attach it to this job template), or set
create_fsx_ontap_admin_password.

- name: Include create fsx ontap role
ansible.builtin.include_role:
name: demo.cloud.aws
tasks_from: create_fsx_ontap
...
32 changes: 32 additions & 0 deletions cloud/delete_fsx_ontap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
- name: Delete Amazon FSx for NetApp ONTAP File System
hosts: localhost
gather_facts: false

tasks:
# Destroy a Storage Stack on AWS supplies the region as create_vm_aws_region.
- name: Default the region from the shared workflow survey answer
ansible.builtin.set_fact:
delete_fsx_ontap_aws_region: "{{ create_vm_aws_region }}"
when:
- lookup('ansible.builtin.vars', 'delete_fsx_ontap_aws_region', default='') | length == 0
- lookup('ansible.builtin.vars', 'create_vm_aws_region', default='') | length > 0

- name: Fail if variables not defined
ansible.builtin.assert:
that:
- delete_fsx_ontap_aws_region is defined
- delete_fsx_ontap_stack_name is defined
fail_msg: "delete_fsx_ontap_aws_region and delete_fsx_ontap_stack_name are required"

- name: Include delete fsx ontap role
ansible.builtin.include_role:
name: demo.cloud.aws
tasks_from: delete_fsx_ontap

- name: Remove FSx ONTAP host from the AAP inventory
ansible.controller.host:
name: "{{ delete_fsx_ontap_aws_name }}"
inventory: "{{ delete_fsx_ontap_inventory_name | default('Ansible Product Demos Storage Inventory') }}"
state: absent
when: delete_fsx_ontap_aws_name is defined
102 changes: 102 additions & 0 deletions cloud/deregister_execution_node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
# Reverses register_execution_node.yml. Run it BEFORE deleting the VM: AAP
# deprovisions an execution node by uninstalling receptor over the mesh, so
# the VM must still be running.
# 1. detach the instance group from the storage inventory
# 2. set the AAP instance to deprovisioning
# 3. wait for AAP to finish and remove the instance
# The instance group itself is left in place (it is empty afterwards).

- name: Deregister the AAP execution node
hosts: localhost
connection: local
gather_facts: false
vars:
deregister_execution_node_inventory_name: Ansible Product Demos Storage Inventory
deregister_execution_node_organization: Ansible Product Demos (APD)
vars_files:
- vars/controller_api.yml
module_defaults:
ansible.builtin.uri: "{{ apd_controller_api_uri_defaults }}"
tasks:
# Destroy a Storage Stack on AWS supplies the region as create_vm_aws_region.
- name: Default the region from the shared workflow survey answer
ansible.builtin.set_fact:
deregister_execution_node_aws_region: "{{ create_vm_aws_region }}"
when:
- lookup('ansible.builtin.vars', 'deregister_execution_node_aws_region', default='') | length == 0
- lookup('ansible.builtin.vars', 'create_vm_aws_region', default='') | length > 0

- name: Fail if variables not defined
ansible.builtin.assert:
that:
- deregister_execution_node_vm_name is defined
- deregister_execution_node_aws_region is defined
fail_msg: "deregister_execution_node_vm_name and deregister_execution_node_aws_region are required"

- name: Find the VM
amazon.aws.ec2_instance_info:
region: "{{ deregister_execution_node_aws_region }}"
filters:
tag:Name: "{{ deregister_execution_node_vm_name }}"
tag:apd: "true"
instance-state-name:
- running
- stopped
register: deregister_execution_node_vm

- name: Nothing to do if the VM is already gone
ansible.builtin.debug:
msg: "No VM named {{ deregister_execution_node_vm_name }}; nothing to deregister."
when: deregister_execution_node_vm.instances | length == 0

- name: Stop if the VM is already gone
ansible.builtin.meta: end_play
when: deregister_execution_node_vm.instances | length == 0

# Same address register_execution_node.yml used when it created the instance.
- name: Set the node address
ansible.builtin.set_fact:
deregister_execution_node_hostname: >-
{{ deregister_execution_node_vm.instances[0].public_dns_name
| default(deregister_execution_node_vm.instances[0].private_ip_address, true) }}

# ansible.controller.instance creates a missing instance rather than skipping
# it, so only deprovision a node that is actually registered.
- name: Look up the AAP instance
ansible.builtin.uri:
url: "{{ apd_controller_api_url }}/instances/?hostname={{ deregister_execution_node_hostname }}"
register: deregister_execution_node_lookup

- name: Nothing to do if the node is not registered
ansible.builtin.debug:
msg: "{{ deregister_execution_node_hostname }} is not registered in AAP."
when: deregister_execution_node_lookup.json.count == 0

- name: Stop if the node is not registered
ansible.builtin.meta: end_play
when: deregister_execution_node_lookup.json.count == 0

# Stop new storage jobs being scheduled onto a node that is going away.
- name: Detach the instance groups from the storage inventory
ansible.controller.inventory:
name: "{{ deregister_execution_node_inventory_name }}"
organization: "{{ deregister_execution_node_organization }}"
instance_groups: []

- name: Deprovision the execution node
ansible.controller.instance:
hostname: "{{ deregister_execution_node_hostname }}"
node_state: deprovisioning

# Deprovisioning is asynchronous (AAP uninstalls receptor over the mesh, then
# deletes the instance). Wait for that, because the next workflow step deletes
# the VM and would otherwise strand the uninstall.
- name: Wait for AAP to remove the instance
ansible.builtin.uri:
url: "{{ apd_controller_api_url }}/instances/?hostname={{ deregister_execution_node_hostname }}"
register: deregister_execution_node_removed
until: deregister_execution_node_removed.json.count == 0
retries: 30
delay: 10
...
2 changes: 2 additions & 0 deletions cloud/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Each file in this folder documents a corresponding cloud demo playbook or workfl
| Patch Cloud Stack in AWS | [patch-cloud-stack.md](patch-cloud-stack.md) | [`cloud/setup.yml`](../setup.yml) |
| Deploy Cloud Stack in AWS | [deploy-cloud-stack.md](deploy-cloud-stack.md) | [`cloud/setup.yml`](../setup.yml) |
| Destroy Cloud Stack in AWS | [cloud-destroy-stack.md](cloud-destroy-stack.md) | [`cloud/setup.yml`](../setup.yml) |
| Deploy a Storage Stack on AWS | [deploy-storage-stack.md](deploy-storage-stack.md) | [`cloud/setup.yml`](../setup.yml) |
| Destroy a Storage Stack on AWS | [cloud-destroy-storage-stack.md](cloud-destroy-storage-stack.md) | [`cloud/setup.yml`](../setup.yml) |
| AWS — Create VPC | [cloud-create-vpc.md](cloud-create-vpc.md) | [`cloud/create_vpc.yml`](../create_vpc.yml) |
| AWS — Create Keypair | [cloud-create-keypair.md](cloud-create-keypair.md) | [`cloud/aws_key.yml`](../aws_key.yml) |
| AWS — Create VM | [cloud-create-vm.md](cloud-create-vm.md) | [`cloud/create_vm.yml`](../create_vm.yml) |
Expand Down
74 changes: 74 additions & 0 deletions cloud/docs/cloud-destroy-storage-stack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Destroy a Storage Stack on AWS


Tears down what [Deploy a Storage Stack on AWS](./deploy-storage-stack.md) created: deletes the Amazon FSx for NetApp ONTAP file system and its inventory host, removes the execution node from AAP, terminates its VM, and re-syncs the AWS inventory.

> **Data loss:** deleting the file system deletes the data on it. The workflow does not ask for confirmation.

## Prerequisites

- A storage stack previously deployed with **Deploy a Storage Stack on AWS**
- **AWS** and **AAP Credential** configured (both come from setup)

## Survey prompts

| Prompt | Variable | Type | Required | Default |
|--------|----------|------|----------|---------|
| AWS Region | `create_vm_aws_region` | multiplechoice | Yes | `us-east-2` |

Select the region used for deploy. Everything else, including the VM, stack, and file system names, is read from the same shared names as the deploy workflow.

## Workflow

```mermaid
graph LR
S["🏠 Start"]
S --> A
S --> B
A["💥 Delete\nFSx ONTAP"]
B["🛰️ Deregister\nExecution Node"] --> C["💥 Delete\nStorage Node"]
C --> D["🔄 Sync Inventory"]
style S fill:#212427,stroke:#8a8d90,color:#fff
```

The two branches run **in parallel**. Each failure files a **SUBMIT FEEDBACK** ticket.

1. **Delete FSx ONTAP** looks up the CloudFormation stack `aws-ontap-stack` and **refuses to delete it unless it is tagged `managed-by=aap-product-demos`**, so a mistyped name cannot remove someone else's stack. It then deletes the stack, which deletes the file system, and removes the `aws-ontap` host from the storage inventory. If the stack does not exist, it reports that and carries on.
2. **Deregister Execution Node** detaches the instance group from the storage inventory, so no new storage jobs are scheduled onto a node that is going away. It then sets the node to deprovisioning and waits (up to 5 minutes) until AAP has removed the instance.
3. **Delete Storage Node** terminates the VM `aws-storage-node`. It only starts after the node is deregistered, so AAP can still reach the VM while it deprovisions the node.
4. **Sync Inventory** removes the VM from AAP's AWS inventory.

## What is not removed

| Left behind | What to do |
|-------------|------------|
| The keypair, VPC, subnet, and security group | Run [Destroy Cloud Stack in AWS](./cloud-destroy-stack.md) **after** this workflow. The VPC cannot be deleted while the file system and the VM still use it |
| The empty `storage` instance group and the empty storage inventory | Harmless; the next deploy reuses them |
| The VM's Red Hat Subscription Management registration | This workflow does not unregister the VM. Remove the system from your Red Hat subscription management account if you want it gone |

## Known limits

- If the VM is already gone but AAP still lists its instance, **Deregister Execution Node** cannot find the node and stops without changing anything. Remove the instance by hand under **Automation Execution → Infrastructure → Instances**.
- Re-running is safe: a missing stack, a missing VM, or a node that is not registered is reported and skipped.

## Job templates

| Job template | Playbook |
|--------------|----------|
| Cloud ǀ AWS ǀ Delete FSx ONTAP | [`cloud/delete_fsx_ontap.yml`](../delete_fsx_ontap.yml) |
| Cloud ǀ AWS ǀ Deregister Execution Node | [`cloud/deregister_execution_node.yml`](../deregister_execution_node.yml) |
| Cloud ǀ AWS ǀ Delete Stack VM | [`cloud/delete_vm_by_name.yml`](../delete_vm_by_name.yml) |

## Presenter walkthrough

1. **When to use:** at the end of a storage demo, or to start over. Remind the audience that it deletes the data on the file system.
2. **Launch:** select the same region used for deploy. That is the only prompt.
3. **Watch the order:** the file system is deleted in one branch while the node is deregistered in the other. Point out that the VM is only terminated once AAP has removed the node.
4. **Clean up the rest:** run **Destroy Cloud Stack in AWS** to remove the VPC and keypair.

## Related demos

| Demo | Description |
|------|-------------|
| 🚀 [Deploy a Storage Stack on AWS](./deploy-storage-stack.md) | The matching provisioning workflow |
| 💥 [Destroy Cloud Stack in AWS](./cloud-destroy-stack.md) | Removes the VPC and keypair afterwards |
Loading