From ff289846d3de24ece1603ad1266c5c7ff367c111 Mon Sep 17 00:00:00 2001 From: Seth Kress Date: Tue, 17 Nov 2026 15:01:29 +0000 Subject: [PATCH] Add Deploy/Destroy Storage Stack workflows for FSx ONTAP on AWS Adds workflows that deploy an AAP execution node and an Amazon FSx for NetApp ONTAP file system next to the cloud stack, and remove them again. - Register/deregister a RHEL 9 VM as an execution node (receptor from the AAP repo) - Create, delete, inventory-sync, and endpoint-check playbooks for FSx ONTAP - Storage inventory, FSx ONTAP credential type, and storage label - netapp.ontap and ansible.receptor in the AAP 2.7 execution environment - Documentation pages and demo catalog entries Assisted-by: Claude Code --- cloud/README.md | 18 + cloud/check_fsx_ontap_endpoint.yml | 67 +++ cloud/create_fsx_ontap.yml | 50 ++ cloud/delete_fsx_ontap.yml | 32 ++ cloud/deregister_execution_node.yml | 102 ++++ cloud/docs/README.md | 2 + cloud/docs/cloud-destroy-storage-stack.md | 74 +++ cloud/docs/deploy-storage-stack.md | 119 ++++ cloud/register_execution_node.yml | 362 ++++++++++++ cloud/setup.yml | 528 ++++++++++++++++++ cloud/update_fsx_ontap_inventory.yml | 122 ++++ cloud/vars/controller_api.yml | 27 + .../demo/cloud/roles/aws/defaults/main.yml | 9 + .../roles/aws/tasks/create_fsx_ontap.yml | 104 ++++ .../roles/aws/tasks/delete_fsx_ontap.yml | 36 ++ common/setup.yml | 2 + docs/_data/demos.yml | 73 +++ execution_environments/apd-ee-27.yml | 1 + execution_environments/requirements-27.yml | 4 + 19 files changed, 1732 insertions(+) create mode 100644 cloud/check_fsx_ontap_endpoint.yml create mode 100644 cloud/create_fsx_ontap.yml create mode 100644 cloud/delete_fsx_ontap.yml create mode 100644 cloud/deregister_execution_node.yml create mode 100644 cloud/docs/cloud-destroy-storage-stack.md create mode 100644 cloud/docs/deploy-storage-stack.md create mode 100644 cloud/register_execution_node.yml create mode 100644 cloud/update_fsx_ontap_inventory.yml create mode 100644 cloud/vars/controller_api.yml create mode 100644 collections/ansible_collections/demo/cloud/roles/aws/tasks/create_fsx_ontap.yml create mode 100644 collections/ansible_collections/demo/cloud/roles/aws/tasks/delete_fsx_ontap.yml diff --git a/cloud/README.md b/cloud/README.md index c10af0a93..cc5b79ab8 100644 --- a/cloud/README.md +++ b/cloud/README.md @@ -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 @@ -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). diff --git a/cloud/check_fsx_ontap_endpoint.yml b/cloud/check_fsx_ontap_endpoint.yml new file mode 100644 index 000000000..c850a2a17 --- /dev/null +++ b/cloud/check_fsx_ontap_endpoint.yml @@ -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 }}" +... diff --git a/cloud/create_fsx_ontap.yml b/cloud/create_fsx_ontap.yml new file mode 100644 index 000000000..90a8255e3 --- /dev/null +++ b/cloud/create_fsx_ontap.yml @@ -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 +... diff --git a/cloud/delete_fsx_ontap.yml b/cloud/delete_fsx_ontap.yml new file mode 100644 index 000000000..c2df98c5a --- /dev/null +++ b/cloud/delete_fsx_ontap.yml @@ -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 diff --git a/cloud/deregister_execution_node.yml b/cloud/deregister_execution_node.yml new file mode 100644 index 000000000..67fa2352f --- /dev/null +++ b/cloud/deregister_execution_node.yml @@ -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 +... diff --git a/cloud/docs/README.md b/cloud/docs/README.md index 8a8cccd98..a854a1f0f 100644 --- a/cloud/docs/README.md +++ b/cloud/docs/README.md @@ -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) | diff --git a/cloud/docs/cloud-destroy-storage-stack.md b/cloud/docs/cloud-destroy-storage-stack.md new file mode 100644 index 000000000..903772fc4 --- /dev/null +++ b/cloud/docs/cloud-destroy-storage-stack.md @@ -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 | diff --git a/cloud/docs/deploy-storage-stack.md b/cloud/docs/deploy-storage-stack.md new file mode 100644 index 000000000..2390837bf --- /dev/null +++ b/cloud/docs/deploy-storage-stack.md @@ -0,0 +1,119 @@ +# Deploy a Storage Stack on AWS + + +Adds storage to the cloud demo environment: a RHEL 9 VM registered with AAP as an **execution node**, and an **Amazon FSx for NetApp ONTAP** file system in the same VPC. The file system goes into its own inventory, and jobs that use that inventory run on the new node. That matters because ONTAP's management endpoint is on a private subnet, which AAP's own control plane usually cannot reach. Use it to demo storage automation with the `netapp.ontap` collection. + +> **Cost:** the VM and the file system keep running, and keep costing money, until you run [Destroy a Storage Stack on AWS](./cloud-destroy-storage-stack.md). + +## Prerequisites + +- **Run [Deploy Cloud Stack in AWS](./deploy-cloud-stack.md) first, in the same region.** This workflow reuses its keypair `aws-test-key`, subnet `aws-test-subnet`, and security group `aws-test-sg`. That security group allows TCP 27199, which the automation mesh uses. +- **AAP 2.7.** The 2.5 and 2.6 execution environments do not include the collections this demo needs (`ansible.receptor` and `netapp.ontap`). +- **Setup:** run **APD ǀ Single demo setup** and choose `cloud` (or **APD ǀ Multi-demo setup**). This creates the job templates, the `storage` label, the credentials below, and the **Ansible Product Demos Storage Inventory**. +- **Network:** AAP's control plane must be able to open a connection to the VM's public DNS name on TCP 27199. + +### Credentials + +| Credential | Used for | What to enter | +|------------|----------|---------------| +| **AWS** | All AWS jobs | Access Key and Secret Key | +| **APD Machine Credential** | Creating the VM and installing receptor on it | SSH private key (the same one Deploy Cloud Stack uses) | +| **RHSM Registration** | Giving the VM access to the AAP repository | Red Hat organization ID and an activation key that entitles RHEL and Ansible Automation Platform | +| **FSx ONTAP** | Setting the `fsxadmin` password and logging in to ONTAP | The `fsxadmin` password you want, which must meet FSx's password rules. Setup seeds it with `REPLACEME`, and the jobs stop with a clear message until you replace it | +| **AAP Credential** | Letting playbooks call the AAP API | Created by setup | + +## Survey prompts + +| Prompt | Variable | Type | Default | Description | +|--------|----------|------|---------|-------------| +| AWS Region | `create_vm_aws_region` | multiplechoice | `us-east-2` | Region for the VM and the file system. Must match the region of your cloud stack | +| Owner | `create_vm_aws_owner_tag` | text | `your_name` | `owner` tag on the VM and the file system | +| Environment | `vm_environment` | multiplechoice | `Prod` | `environment` tag on the VM and the file system (`Dev`, `QA`, or `Prod`). Metadata only | +| Email | `email` | text | `your_name@acme.org` | Operator contact; **not** applied as a tag and not used by the playbooks | + +The answers are passed to every job in the workflow, so each job template's own region, owner, and environment prompts are optional when launched from here. + +## Workflow + +```mermaid +graph LR + S["🏠 Start"] + S --> A + S --> F + A["🐧 Deploy Storage Node\n(RHEL 9 VM)"] --> B["🔄 Sync Inventory"] + B --> C["🛰️ Register\nExecution Node"] + F["💾 Create\nFSx ONTAP"] --> G["🔄 Update FSx\nInventory"] + C --> H["✅ Check FSx\nEndpoint"] + G --> H + style S fill:#212427,stroke:#8a8d90,color:#fff +``` + +The VM branch and the file system branch run **in parallel**, because creating the file system takes a while (often 20 minutes or more). Each failure files a **SUBMIT FEEDBACK** ticket. + +1. **Deploy Storage Node** creates the RHEL 9 VM `aws-storage-node` from the `rhel9` blueprint, with deployment tag `storage_stack`. +2. **Sync Inventory** imports the new VM into AAP. +3. **Register Execution Node** turns the VM into an AAP execution node: + - creates the instance in AAP (type `execution`, listener port 27199) and downloads its install bundle; + - registers the VM with Red Hat Subscription Management and enables the AAP repository, named from the AAP platform version, the VM's RHEL major version, and its architecture; + - installs podman, receptor, and ansible-runner, then checks that receptor is running and listening; + - adds the node to the `storage` instance group, attaches that group to the storage inventory, and runs an AAP health check (up to 5 minutes). +4. **Create FSx ONTAP** creates a CloudFormation stack, `aws-ontap-stack`, containing an FSx for NetApp ONTAP file system named `aws-ontap`. The admin password is passed as a `NoEcho` stack parameter and kept out of job output. +5. **Update FSx Inventory** finds the managed ONTAP file systems in the region and adds each one as a host in the storage inventory (group `fsx_ontap`, `ansible_host` set to the management IP). It also removes hosts for file systems that no longer exist. +6. **Check FSx Endpoint** runs on the execution node. It waits for ONTAP's HTTPS port, then reads the cluster version through `netapp.ontap.na_ontap_rest_info` and prints the full version string. A pass proves the node can reach ONTAP and that the collection works from there. + +## What gets created + +| Resource | Name | Notes | +|----------|------|-------| +| VM | `aws-storage-node` | RHEL 9, tagged `apd=true` and `managed-by=aap-product-demos` | +| FSx file system | `aws-ontap` | Single-AZ (`SINGLE_AZ_1`), 1024 GiB, 128 MB/s by default | +| CloudFormation stack | `aws-ontap-stack` | Deleting it deletes the file system | +| Instance group | `storage` | Contains the new execution node | +| Inventory | **Ansible Product Demos Storage Inventory** | Holds the FSx host; jobs using it run on the `storage` group | + +The names are variables at the top of [`cloud/setup.yml`](../setup.yml) (`apd_storage_*`); change them there and the surveys, workflows, and playbooks follow. The file system size, throughput, and deployment type are defaults in the `demo.cloud.aws` role's [`defaults/main.yml`](../../collections/ansible_collections/demo/cloud/roles/aws/defaults/main.yml) and are not survey prompts. + +## Job templates + +| Job template | Playbook | +|--------------|----------| +| Cloud ǀ AWS ǀ Create VM | [`cloud/create_vm.yml`](../create_vm.yml) | +| Cloud ǀ AWS ǀ Register Execution Node | [`cloud/register_execution_node.yml`](../register_execution_node.yml) | +| Cloud ǀ AWS ǀ Create FSx ONTAP | [`cloud/create_fsx_ontap.yml`](../create_fsx_ontap.yml) | +| Cloud ǀ AWS ǀ Update FSx ONTAP Inventory | [`cloud/update_fsx_ontap_inventory.yml`](../update_fsx_ontap_inventory.yml) | +| Cloud ǀ AWS ǀ Check FSx ONTAP Endpoint | [`cloud/check_fsx_ontap_endpoint.yml`](../check_fsx_ontap_endpoint.yml) | + +## Why it matters + +- Shows an automation mesh execution node placed next to the infrastructure it manages, instead of opening network paths into a private subnet. +- A single launch builds both the automation capacity and the storage it will manage. +- Everything is created from playbooks, so the same environment is rebuilt the same way each time. + +## Presenter walkthrough + +1. **Set the scene:** the storage system sits on a private subnet that AAP cannot reach directly. 'To automate it, we put an execution node next to it.' +2. **Launch:** show the four survey fields, then start the workflow. Point out the two parallel branches. +3. **Register Execution Node:** while the file system builds, open the job output and walk through the steps. The repository is picked from the platform version and the VM's own facts, with nothing hard-coded. +4. **Show the node in AAP:** under **Automation Execution → Infrastructure**, open **Instances** and show the new node as ready, then **Instance Groups** to show `storage`. +5. **Update FSx Inventory:** show the FSx host in the **Storage Inventory**. +6. **Check FSx Endpoint:** show the job output. The ONTAP version printed there came back from a job that ran on the new node. 'AAP's own control plane could not have made that call.' +7. **Transition:** use the storage inventory to run `netapp.ontap` content that targets the `fsx_ontap` group. + +## Troubleshooting + +| Symptom | Likely cause | +|---------|--------------| +| A job stops with "No fsxadmin password" | The **FSx ONTAP** credential still contains `REPLACEME`. Enter the real password | +| **Create FSx ONTAP** fails with "No last item, sequence was empty" | The cloud stack's subnet or security group was not found in this region. Run **Deploy Cloud Stack in AWS** there first | +| **Register Execution Node** fails with "not registered with RHSM" | The **RHSM Registration** credential still has placeholder values. Enter an organization ID and activation key | +| The health check fails with "not in the receptor mesh" | AAP cannot reach the VM on TCP 27199. Check the security group and the network path from AAP to the VM's public DNS name | +| **Create FSx ONTAP** fails | The job output lists the failed CloudFormation events. To see the raw module error instead, relaunch with the extra variable `create_fsx_ontap_no_log=false`. This puts the admin password in that job's stored events, so use it sparingly | +| **Check FSx ONTAP Endpoint** times out | The node cannot reach the file system's management IP on TCP 443 (it waits up to 10 minutes). Check the security group rules | + +## Related demos + +| Demo | Description | +|------|-------------| +| 💥 [Destroy a Storage Stack on AWS](./cloud-destroy-storage-stack.md) | Removes what this workflow created | +| 🚀 [Deploy Cloud Stack in AWS](./deploy-cloud-stack.md) | The environment this workflow builds on | +| 💥 [Destroy Cloud Stack in AWS](./cloud-destroy-stack.md) | Tear down the VPC afterwards (run the storage destroy first) | diff --git a/cloud/register_execution_node.yml b/cloud/register_execution_node.yml new file mode 100644 index 000000000..408834ca9 --- /dev/null +++ b/cloud/register_execution_node.yml @@ -0,0 +1,362 @@ +--- +# Registers an EC2 VM (created by create_vm.yml) as an AAP execution node: +# 1. create the instance in AAP (node_type=execution) and download its install bundle +# 2. install receptor on the VM using the bundle's settings (ansible.receptor.setup) +# 3. add the instance to an instance group and wait for it to become ready +# +# Requires: AAP Credential (injects CONTROLLER_*), AWS credential, a machine +# credential that can SSH/sudo on the VM, and network reachability from the AAP +# control/hop nodes to the VM on the receptor listener port (default 27199). + +- name: Register the VM as an AAP execution node (controller side) + hosts: localhost + connection: local + gather_facts: false + vars: + register_execution_node_listener_port: 27199 + # package: install the receptor and ansible-runner RPMs from the AAP repo, + # which needs the VM registered with RHSM (RHSM Registration credential). + # release: download receptor from GitHub; no subscription needed. + register_execution_node_receptor_install_method: package + vars_files: + - vars/controller_api.yml + module_defaults: + ansible.builtin.uri: "{{ apd_controller_api_uri_defaults }}" + tasks: + # Deploy 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: + register_execution_node_aws_region: "{{ create_vm_aws_region }}" + when: + - lookup('ansible.builtin.vars', 'register_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: + - register_execution_node_vm_name is defined + - register_execution_node_aws_region is defined + fail_msg: "register_execution_node_vm_name and register_execution_node_aws_region are required" + + - name: Find the VM + amazon.aws.ec2_instance_info: + region: "{{ register_execution_node_aws_region }}" + filters: + tag:Name: "{{ register_execution_node_vm_name }}" + tag:apd: "true" + instance-state-name: running + register: register_execution_node_vm + + - name: Fail if the VM was not found + ansible.builtin.assert: + that: register_execution_node_vm.instances | length == 1 + fail_msg: "Expected exactly one running VM named {{ register_execution_node_vm_name }}" + + # AAP control nodes must reach this address on the listener port. + - name: Set the node address + ansible.builtin.set_fact: + register_execution_node_hostname: >- + {{ register_execution_node_vm.instances[0].public_dns_name + | default(register_execution_node_vm.instances[0].private_ip_address, true) }} + + # The module returns the instance id whether it created, updated or left it as is. + - name: Create the execution node in AAP + ansible.controller.instance: + hostname: "{{ register_execution_node_hostname }}" + node_type: execution + listener_port: "{{ register_execution_node_listener_port }}" + peers_from_control_nodes: true + register: register_execution_node_instance + + # The AAP repo on the VM is named for the platform version; ask the gateway, + # as install-apd.yml does. Keep major.minor in case a patch number is included. + - name: Get the AAP platform version + ansible.builtin.uri: + url: "{{ apd_gateway_api_url }}/ping/" + register: register_execution_node_gateway_ping + + - name: Set the AAP platform version + ansible.builtin.set_fact: + register_execution_node_aap_version: "{{ register_execution_node_gateway_ping.json.version | default('') | regex_search('^[0-9]+[.][0-9]+') | default('', true) }}" + + - name: Fail if the AAP platform version is unknown + ansible.builtin.assert: + that: register_execution_node_aap_version | length > 0 + fail_msg: >- + Could not read the AAP platform version from {{ apd_gateway_api_url }}/ping/ + (got {{ register_execution_node_gateway_ping.json.version | default('nothing') }}). + + # Everything from here on works in the bundle directory; if any of it fails, + # remove the directory (it holds receptor's TLS private key) and re-raise. + # On success it is kept for play 2, which removes it after the install. + - name: Download and parse the install bundle + block: + - name: Create a working directory for the install bundle + ansible.builtin.tempfile: + state: directory + prefix: exec_node_bundle_ + register: register_execution_node_workdir + + - name: Download the install bundle + ansible.builtin.uri: + url: "{{ apd_controller_api_url }}/instances/{{ register_execution_node_instance.id }}/install_bundle/" + dest: "{{ register_execution_node_workdir.path }}/bundle.tar.gz" + return_content: false + + - name: Extract the install bundle + ansible.builtin.unarchive: + src: "{{ register_execution_node_workdir.path }}/bundle.tar.gz" + dest: "{{ register_execution_node_workdir.path }}" + remote_src: true + + - name: List the install bundle files + ansible.builtin.find: + paths: "{{ register_execution_node_workdir.path }}" + file_type: file + recurse: true + register: register_execution_node_bundle_files + + - name: Show the install bundle files + ansible.builtin.debug: + msg: "{{ register_execution_node_bundle_files.files | map(attribute='path') | map('regex_replace', '^' ~ register_execution_node_workdir.path ~ '/', '') | sort }}" + + - name: Locate the bundle group vars + ansible.builtin.set_fact: + register_execution_node_bundle_group_vars: >- + {{ register_execution_node_bundle_files.files | map(attribute='path') + | select('match', '.*/group_vars/all[.]ya?ml$') | first | default('') }} + + - name: Fail if the bundle has no group vars + ansible.builtin.assert: + that: register_execution_node_bundle_group_vars | length > 0 + fail_msg: >- + group_vars/all.yml was not found in the install bundle; see the file + list above for what the bundle contains. + + # The receptor settings live in the bundle's group_vars/all.yml. + - name: Read the bundle group vars + ansible.builtin.slurp: + src: "{{ register_execution_node_bundle_group_vars }}" + register: register_execution_node_group_vars_raw + + - name: Collect receptor settings from the bundle + ansible.builtin.set_fact: + register_execution_node_bundle_settings: "{{ (register_execution_node_group_vars_raw.content | b64decode | from_yaml) or {} }}" + + # Settings that are file paths (custom_*file) are relative to the bundle + # directory (the parent of group_vars), so make them absolute. + - name: Build receptor settings from the bundle + ansible.builtin.set_fact: + register_execution_node_receptor_vars: >- + {{ register_execution_node_receptor_vars | default({}) | combine({ + item.key: (register_execution_node_bundle_group_vars | dirname | dirname ~ '/' ~ item.value) + if (item.key.startswith('custom_') and item.key.endswith('file') + and item.value is string and not item.value.startswith('/')) + else item.value }) }} + loop: "{{ register_execution_node_bundle_settings | dict2items }}" + loop_control: + label: "{{ item.key }}" + when: not item.key.startswith('ansible_') + + # The bundle's playbook creates receptor_user, and the roles need the group too, so + # both must come from the bundle's settings. + - name: Fail if the bundle did not provide the receptor settings + ansible.builtin.assert: + that: + - register_execution_node_receptor_vars | default({}) | length > 0 + - (register_execution_node_receptor_vars | default({})).receptor_user is defined + - (register_execution_node_receptor_vars | default({})).receptor_group is defined + fail_msg: >- + The install bundle did not provide receptor settings including receptor_user + and receptor_group. Check the bundle file list above and group_vars/all.yml. + + # The port was registered in AAP above; use it unless the bundle sets its own. + - name: Default the receptor port to the registered listener port + ansible.builtin.set_fact: + register_execution_node_receptor_vars: >- + {{ {'receptor_port': register_execution_node_listener_port} + | combine(register_execution_node_receptor_vars) }} + + # package (default): the bundle's receptor RPMs, plus ansible-runner, come + # from the AAP repo that play 2 enables. release: receptor is downloaded and + # receptorctl installed with pip, so ansible-runner is installed with pip too. + - name: Choose how receptor is installed + ansible.builtin.set_fact: + register_execution_node_receptor_vars: >- + {{ register_execution_node_receptor_vars + | combine({'receptor_install_method': register_execution_node_receptor_install_method}) + | combine( + {'additional_system_packages': + (register_execution_node_receptor_vars.additional_system_packages | default([]) + + ['ansible-runner']) | unique} + if register_execution_node_receptor_install_method == 'package' else + {'additional_python_packages': + (register_execution_node_receptor_vars.additional_python_packages | default([]) + + ['ansible-runner']) | unique}) }} + rescue: + - name: Remove the install bundle working directory + ansible.builtin.file: + path: "{{ register_execution_node_workdir.path }}" + state: absent + when: register_execution_node_workdir is defined + + - name: Fail with the original error + ansible.builtin.fail: + msg: "{{ ansible_failed_task.name }}: {{ ansible_failed_result.msg | default('failed') }}" + +- name: Install receptor on the VM + hosts: "{{ register_execution_node_vm_name | default('aws-storage-node') }}" + gather_facts: true + become: true + vars: + # Named for the platform version (from play 1) and this host's RHEL major version and + # architecture, e.g. ansible-automation-platform-2.7-for-rhel-9-x86_64-rpms. + register_execution_node_aap_repo: >- + ansible-automation-platform-{{ hostvars['localhost'].register_execution_node_aap_version }}-for-rhel-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}-rpms + tasks: + - name: Install receptor and remove the install bundle files + block: + - name: Load receptor settings from the bundle + ansible.builtin.set_fact: + "{{ item.key }}": "{{ item.value }}" + loop: "{{ hostvars['localhost'].register_execution_node_receptor_vars | dict2items }}" + loop_control: + label: "{{ item.key }}" + + - name: Check the receptor user and group are valid account names + ansible.builtin.assert: + that: + - receptor_user is match('^[a-z_][a-z0-9_-]*$') + - receptor_group is match('^[a-z_][a-z0-9_-]*$') + fail_msg: >- + receptor_user/receptor_group are not valid account names + (receptor_user={{ receptor_user | to_json }}, receptor_group={{ receptor_group | to_json }}). + + # The receptor and ansible-runner RPMs are in the AAP repo, which a stock + # RHEL VM does not have: register it with RHSM, then enable the repo. + - name: Enable the AAP repo for the receptor packages + when: receptor_install_method == 'package' + block: + - name: Ensure RHSM registration + ansible.builtin.include_tasks: tasks/rhsm_ensure_registered.yml + + - name: Fail if the VM could not be registered + ansible.builtin.assert: + that: rhsm_registered | default(false) + fail_msg: >- + The VM is not registered with RHSM, so the AAP repo cannot be enabled. + Add the RHSM Registration credential (org id and activation key) to + this job template, or set register_execution_node_receptor_install_method + to release to download receptor instead. + + - name: Enable the AAP repo + community.general.rhsm_repository: + name: "{{ register_execution_node_aap_repo }}" + state: enabled + + # The same three steps as the bundle's install_receptor.yml. The podman role reads + # its account from podman_user and podman_group (default "podman"), so pass the + # bundle's receptor account explicitly. + - name: Create the receptor user + ansible.builtin.user: + name: "{{ receptor_user }}" + shell: /bin/bash + + - name: Install podman for receptor + ansible.builtin.include_role: + name: ansible.receptor.podman + vars: + podman_user: "{{ hostvars['localhost'].register_execution_node_receptor_vars.receptor_user }}" + podman_group: "{{ hostvars['localhost'].register_execution_node_receptor_vars.receptor_group }}" + + # The bundle's TLS certificate is issued for the hostname the instance was + # registered under, and the role uses routable_hostname (else ansible_host, + # which is the public IP here) as the receptor node id and certificate file + # name. They must match or receptor refuses to start. + - name: Install and configure receptor + ansible.builtin.include_role: + name: ansible.receptor.setup + vars: + receptor_user: "{{ hostvars['localhost'].register_execution_node_receptor_vars.receptor_user }}" + receptor_group: "{{ hostvars['localhost'].register_execution_node_receptor_vars.receptor_group }}" + routable_hostname: "{{ hostvars['localhost'].register_execution_node_hostname }}" + + - name: Verify ansible-runner is available + ansible.builtin.command: ansible-runner --version + changed_when: false + + - name: Get the receptor service status + ansible.builtin.systemd: + name: receptor + register: register_execution_node_service + + - name: Verify receptor is running + ansible.builtin.assert: + that: register_execution_node_service.status.ActiveState | default('') == 'active' + fail_msg: >- + receptor is not running (state: {{ register_execution_node_service.status.ActiveState | default('unknown') }}); + check the receptor service logs on the node. + + - name: Verify receptor is listening on the mesh port + ansible.builtin.wait_for: + host: 127.0.0.1 + port: "{{ receptor_port }}" + timeout: 60 + # The bundle holds receptor's TLS private key; it is only needed until the + # role has copied it to the VM, so remove it whether or not the install worked. + always: + - name: Remove the install bundle working directory + ansible.builtin.file: + path: "{{ hostvars['localhost'].register_execution_node_workdir.path }}" + state: absent + delegate_to: localhost + become: false + run_once: true + when: hostvars['localhost'].register_execution_node_workdir is defined + +- name: Add the execution node to an instance group and wait for it + hosts: localhost + connection: local + gather_facts: false + vars: + register_execution_node_instance_group: storage + register_execution_node_inventory_name: Ansible Product Demos Storage Inventory + register_execution_node_organization: Ansible Product Demos (APD) + vars_files: + - vars/controller_api.yml + module_defaults: + ansible.builtin.uri: "{{ apd_controller_api_uri_defaults }}" + tasks: + - name: Add the instance to the instance group + ansible.controller.instance_group: + name: "{{ register_execution_node_instance_group }}" + instances: + - "{{ register_execution_node_hostname }}" + state: present + + # Jobs that use this inventory run on the storage instance group. + - name: Run storage inventory jobs on the instance group + ansible.controller.inventory: + name: "{{ register_execution_node_inventory_name }}" + organization: "{{ register_execution_node_organization }}" + instance_groups: + - "{{ register_execution_node_instance_group }}" + + # The control plane dials the node on its listener port, so a failure here + # (for example "not in the receptor mesh") means AAP cannot reach it. + - name: Run an AAP health check on the node + ansible.builtin.uri: + url: "{{ apd_controller_api_url }}/instances/{{ register_execution_node_instance.id }}/health_check/" + method: POST + status_code: [200, 202] + + - name: Wait for the health check to pass + ansible.builtin.uri: + url: "{{ apd_controller_api_url }}/instances/{{ register_execution_node_instance.id }}/health_check/" + register: register_execution_node_health + until: + - register_execution_node_health.json.last_health_check | default(none) is not none + - register_execution_node_health.json.errors | default('') | length == 0 + retries: 30 + delay: 10 +... diff --git a/cloud/setup.yml b/cloud/setup.yml index 6a8b9001f..d34176ff9 100644 --- a/cloud/setup.yml +++ b/cloud/setup.yml @@ -2,11 +2,29 @@ _deployment_id: '{{ lookup("ansible.builtin.password", playbook_dir + "/.deployment_id", chars=["ascii_lowercase", "digits"], length=5) }}' apd_managed_by: aap-product-demos +# Names shared by the storage job templates and the Deploy / Destroy a Storage Stack +# workflows. Change them here only: the surveys, workflow nodes and the playbooks' +# inventory name all read these. The keypair, subnet and security group must match +# what Deploy Cloud Stack in AWS creates. +apd_storage_vm_name: aws-storage-node +apd_storage_fsx_name: aws-ontap +apd_storage_fsx_stack_name: aws-ontap-stack +apd_storage_instance_group: storage +apd_storage_inventory_name: Ansible Product Demos Storage Inventory +apd_storage_aws_keypair_name: aws-test-key +apd_storage_aws_subnet_name: aws-test-subnet +apd_storage_aws_securitygroup_name: aws-test-sg + user_message: - >- To enable automatic RHSM registration on unregistered RHEL hosts, update the 'RHSM Registration' credential in AAP with your org ID and activation key. https://access.redhat.com/management/activation_keys + - >- + To create or manage Amazon FSx for NetApp ONTAP, update the 'FSx ONTAP' + credential in AAP with the password for the fsxadmin account. It is set + as the fsxadmin password when the file system is created, and used to + log in to it afterwards. controller_credential_types: - name: RHSM Activation Key @@ -27,6 +45,25 @@ controller_credential_types: extra_vars: rhsm_org_id: !unsafe '{{ rhsm_org_id }}' rhsm_activation_key: !unsafe '{{ rhsm_activation_key }}' + - name: FSx ONTAP Admin + kind: cloud + inputs: + fields: + - id: fsx_ontap_username + type: string + label: Admin Username + default: fsxadmin + - id: fsx_ontap_password + type: string + label: Admin Password + secret: true + required: + - fsx_ontap_username + - fsx_ontap_password + injectors: + extra_vars: + fsx_ontap_username: !unsafe '{{ fsx_ontap_username }}' + fsx_ontap_password: !unsafe '{{ fsx_ontap_password }}' controller_credentials: - name: RHSM Registration @@ -37,6 +74,14 @@ controller_credentials: inputs: rhsm_org_id: REPLACEME rhsm_activation_key: REPLACEME + - name: FSx ONTAP + credential_type: FSx ONTAP Admin + organization: Ansible Product Demos (APD) + update_secrets: false + state: exists + inputs: + fsx_ontap_username: fsxadmin + fsx_ontap_password: REPLACEME controller_execution_environments: - name: TMM AWS EE @@ -44,6 +89,15 @@ controller_execution_environments: organization: Ansible Product Demos (APD) pull: missing +# Holds the FSx ONTAP systems. The "storage" instance group (the execution +# node registered by Deploy a Storage Stack on AWS) is attached to this +# inventory by cloud/register_execution_node.yml, so jobs run against ONTAP +# hosts execute on that node. +controller_inventories: + - name: "{{ apd_storage_inventory_name }}" + description: Amazon FSx for NetApp ONTAP systems managed from the storage execution node + organization: Ansible Product Demos (APD) + controller_templates: - name: Cloud | AWS | Create Peer Infrastructure labels: @@ -436,6 +490,276 @@ controller_templates: _report_server: reports limit: all + - name: Cloud | AWS | Create FSx ONTAP + labels: + - storage + job_type: run + organization: Ansible Product Demos (APD) + credentials: + - AWS + - FSx ONTAP + project: Ansible Product Demos + playbook: cloud/create_fsx_ontap.yml + inventory: Ansible Product Demos Inventory + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + survey_enabled: true + survey: + name: '' + description: '' + spec: + - question_name: AWS Region + question_description: >- + AWS region where the FSx ONTAP will be created. Optional when + launched from Deploy a Storage Stack on AWS, which supplies the region. + type: multiplechoice + variable: create_fsx_ontap_aws_region + required: false + choices: + - us-east-1 + - us-east-2 + - us-west-1 + - us-west-2 + - question_name: FSx ONTAP Name + question_description: >- + Name for the FSx ONTAP file system. Will be used as the value for + the EC2 tag key "Name" on the FSx ONTAP file system. + type: text + variable: create_fsx_ontap_aws_name + required: true + default: "{{ apd_storage_fsx_name }}" + - question_name: FSx ONTAP Stack Name + question_description: >- + Name for the collection of ONTAP nodes. This dominates the + FSx ONTAP Name + type: text + variable: create_fsx_ontap_stack_name + required: true + default: "{{ apd_storage_fsx_stack_name }}" + - question_name: Owner + question_description: >- + Value for the EC2 tag key "owner" on all resources this workflow + creates. Use your name or team for cost attribution; appears in + inventory keyed groups as owner_*. + type: text + variable: create_fsx_ontap_aws_owner_tag + required: false + - question_name: Environment + question_description: >- + Value for the EC2 tag key "environment" on FSx ONTAP (Dev, QA, or + Prod). Metadata only—it does not change settings. + type: multiplechoice + variable: create_fsx_ontap_aws_environment + required: false + choices: + - Dev + - QA + - Prod + - question_name: Subnet + type: text + variable: create_fsx_ontap_aws_vpc_subnet_name + required: true + default: "{{ apd_storage_aws_subnet_name }}" + - question_name: Security Group + type: text + variable: create_fsx_ontap_aws_securitygroup_name + required: true + default: "{{ apd_storage_aws_securitygroup_name }}" + + - name: Cloud | AWS | Update FSx ONTAP Inventory + labels: + - storage + job_type: run + organization: Ansible Product Demos (APD) + credentials: + - AWS + - AAP Credential + project: Ansible Product Demos + playbook: cloud/update_fsx_ontap_inventory.yml + inventory: Ansible Product Demos Inventory + extra_vars: + update_fsx_ontap_inventory_name: "{{ apd_storage_inventory_name }}" + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + survey_enabled: true + survey: + name: '' + description: '' + spec: + - question_name: AWS Region + question_description: >- + AWS region to search for FSx ONTAP file systems created by the + Create FSx ONTAP job template. Optional when launched from Deploy + a Storage Stack on AWS, which supplies the region. + type: multiplechoice + variable: update_fsx_ontap_inventory_aws_region + required: false + choices: + - us-east-1 + - us-east-2 + - us-west-1 + - us-west-2 + + - name: Cloud | AWS | Delete FSx ONTAP + labels: + - storage + job_type: run + organization: Ansible Product Demos (APD) + credentials: + - AWS + - AAP Credential + project: Ansible Product Demos + playbook: cloud/delete_fsx_ontap.yml + inventory: Ansible Product Demos Inventory + extra_vars: + delete_fsx_ontap_inventory_name: "{{ apd_storage_inventory_name }}" + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + survey_enabled: true + survey: + name: '' + description: '' + spec: + - question_name: AWS Region + question_description: >- + AWS region where the FSx ONTAP stack was created. Optional when + launched from Destroy a Storage Stack on AWS, which supplies the region. + type: multiplechoice + variable: delete_fsx_ontap_aws_region + required: false + choices: + - us-east-1 + - us-east-2 + - us-west-1 + - us-west-2 + - question_name: FSx ONTAP Stack Name + question_description: >- + Name of the CloudFormation stack to delete. Deleting the stack + also deletes the FSx ONTAP file system and all of its data. + type: text + variable: delete_fsx_ontap_stack_name + required: true + default: "{{ apd_storage_fsx_stack_name }}" + - question_name: FSx ONTAP Name + question_description: >- + Name used when the file system was created. The host with this + name is removed from {{ apd_storage_inventory_name }}. + type: text + variable: delete_fsx_ontap_aws_name + required: false + default: "{{ apd_storage_fsx_name }}" + + - name: Cloud | AWS | Register Execution Node + labels: + - storage + job_type: run + organization: Ansible Product Demos (APD) + credentials: + - AWS + - AAP Credential + - APD Machine Credential + - RHSM Registration + project: Ansible Product Demos + playbook: cloud/register_execution_node.yml + inventory: Ansible Product Demos Inventory + extra_vars: + register_execution_node_inventory_name: "{{ apd_storage_inventory_name }}" + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + survey_enabled: true + survey: + name: '' + description: '' + spec: + - question_name: AWS Region + question_description: >- + AWS region where the VM was created. Optional when launched from + Deploy a Storage Stack on AWS, which supplies the region. + type: multiplechoice + variable: register_execution_node_aws_region + required: false + choices: + - us-east-1 + - us-east-2 + - us-west-1 + - us-west-2 + - question_name: VM Name + question_description: >- + Name tag of the RHEL VM to register as an AAP execution node. It + must already be in Ansible Product Demos Inventory. + type: text + variable: register_execution_node_vm_name + required: true + default: "{{ apd_storage_vm_name }}" + - question_name: Instance Group + question_description: >- + AAP instance group the execution node is added to. + type: text + variable: register_execution_node_instance_group + required: false + default: "{{ apd_storage_instance_group }}" + + - name: Cloud | AWS | Check FSx ONTAP Endpoint + labels: + - storage + job_type: run + organization: Ansible Product Demos (APD) + credentials: + - FSx ONTAP + project: Ansible Product Demos + playbook: cloud/check_fsx_ontap_endpoint.yml + # Must use the storage inventory so the job runs on the execution node. + inventory: "{{ apd_storage_inventory_name }}" + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + + - name: Cloud | AWS | Deregister Execution Node + labels: + - storage + job_type: run + organization: Ansible Product Demos (APD) + credentials: + - AWS + - AAP Credential + project: Ansible Product Demos + playbook: cloud/deregister_execution_node.yml + inventory: Ansible Product Demos Inventory + extra_vars: + deregister_execution_node_inventory_name: "{{ apd_storage_inventory_name }}" + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + survey_enabled: true + survey: + name: '' + description: '' + spec: + - question_name: AWS Region + question_description: >- + AWS region where the VM was created. Optional when launched from + Destroy a Storage Stack on AWS, which supplies the region. + type: multiplechoice + variable: deregister_execution_node_aws_region + required: false + choices: + - us-east-1 + - us-east-2 + - us-west-1 + - us-west-2 + - question_name: VM Name + question_description: >- + Name tag of the RHEL VM registered as an AAP execution node. It + must still be running so AAP can uninstall receptor from it. + type: text + variable: deregister_execution_node_vm_name + required: true + default: "{{ apd_storage_vm_name }}" + controller_workflows: - name: Deploy Cloud Stack in AWS description: A workflow to deploy a cloud stack @@ -776,3 +1100,207 @@ controller_workflows: _report_server: reports limit: all all_parents_must_converge: true + + - name: Deploy a Storage Stack on AWS + description: >- + Deploy a RHEL VM registered as an AAP execution node for managing + storage, and an Amazon FSx for NetApp ONTAP file system that is added + to the storage inventory. Requires the keypair and VPC created by + Deploy Cloud Stack in AWS, so run that workflow first. + labels: + - aws.ec2 + - rhel + - storage + organization: Ansible Product Demos (APD) + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + extra_vars: + create_vm_aws_keypair_name: "{{ apd_storage_aws_keypair_name }}" + create_vm_aws_securitygroup_name: "{{ apd_storage_aws_securitygroup_name }}" + create_vm_aws_vpc_subnet_name: "{{ apd_storage_aws_subnet_name }}" + create_vm_vm_deployment: storage_stack + create_vm_vm_purpose: demo + create_vm_apd_managed_by: aap-product-demos + create_vm_apd_demo_tag: "true" + survey_enabled: true + survey: + name: '' + description: '' + spec: + - question_name: AWS Region + question_description: >- + AWS region where the VPC, keypair, VM, and FSx ONTAP will be created. + type: multiplechoice + variable: create_vm_aws_region + required: true + default: us-east-2 + choices: + - us-east-1 + - us-east-2 + - us-west-1 + - us-west-2 + - question_name: Owner + question_description: >- + Value for the EC2 tag key "owner" on the VM. + type: text + variable: create_vm_aws_owner_tag + required: true + default: your_name + - question_name: Environment + question_description: >- + Value for the EC2 tag key "environment" on the VM (Dev, QA, or Prod). + type: multiplechoice + variable: vm_environment + required: true + default: Prod + choices: + - Dev + - QA + - Prod + - question_name: Email + question_description: >- + Operator contact at launch. Not written to EC2 tags. + type: text + variable: email + required: true + default: your_name@acme.org + simplified_workflow_nodes: + - identifier: Deploy Storage Node + unified_job_template: Cloud | AWS | Create VM + extra_data: + create_vm_vm_name: "{{ apd_storage_vm_name }}" + vm_blueprint: rhel9 + success_nodes: + - Update Inventory + failure_nodes: + - Ticket - Instance Failed + - identifier: Update Inventory + unified_job_template: AWS Inventory + success_nodes: + - Register Execution Node + - identifier: Register Execution Node + unified_job_template: Cloud | AWS | Register Execution Node + extra_data: + register_execution_node_vm_name: "{{ apd_storage_vm_name }}" + register_execution_node_instance_group: "{{ apd_storage_instance_group }}" + success_nodes: + - Check FSx Endpoint + failure_nodes: + - Ticket - Execution Node Failed + - identifier: Create FSx ONTAP + unified_job_template: Cloud | AWS | Create FSx ONTAP + extra_data: + create_fsx_ontap_aws_name: "{{ apd_storage_fsx_name }}" + create_fsx_ontap_stack_name: "{{ apd_storage_fsx_stack_name }}" + create_fsx_ontap_aws_vpc_subnet_name: "{{ apd_storage_aws_subnet_name }}" + create_fsx_ontap_aws_securitygroup_name: "{{ apd_storage_aws_securitygroup_name }}" + success_nodes: + - Update FSx Inventory + failure_nodes: + - Ticket - FSx Failed + - identifier: Update FSx Inventory + unified_job_template: Cloud | AWS | Update FSx ONTAP Inventory + success_nodes: + - Check FSx Endpoint + failure_nodes: + - Ticket - FSx Inventory Failed + # Runs on the execution node, so it only starts once the node is + # registered and the FSx system is in the storage inventory. + - identifier: Check FSx Endpoint + unified_job_template: Cloud | AWS | Check FSx ONTAP Endpoint + all_parents_must_converge: true + failure_nodes: + - Ticket - FSx Endpoint Failed + - identifier: Ticket - FSx Endpoint Failed + unified_job_template: 'SUBMIT FEEDBACK' + extra_data: + feedback: FSx ONTAP management endpoint is not reachable from the execution node + - identifier: Ticket - FSx Inventory Failed + unified_job_template: 'SUBMIT FEEDBACK' + extra_data: + feedback: Failed to add FSx ONTAP to the storage inventory + - identifier: Ticket - Instance Failed + unified_job_template: 'SUBMIT FEEDBACK' + extra_data: + feedback: Failed to create AWS storage node instance + - identifier: Ticket - Execution Node Failed + unified_job_template: 'SUBMIT FEEDBACK' + extra_data: + feedback: Failed to register execution node + - identifier: Ticket - FSx Failed + unified_job_template: 'SUBMIT FEEDBACK' + extra_data: + feedback: Failed to create FSx ONTAP + + - name: Destroy a Storage Stack on AWS + description: >- + Tear down what Deploy a Storage Stack on AWS created: the FSx ONTAP + file system and its inventory host, and the storage execution node + (deregistered from AAP, then its VM deleted). The keypair and VPC from + Deploy Cloud Stack in AWS are left in place; use Destroy Cloud Stack in + AWS for those. + labels: + - aws.ec2 + - rhel + - storage + organization: Ansible Product Demos (APD) + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + survey_enabled: true + survey: + name: '' + description: '' + spec: + - question_name: AWS Region + question_description: >- + AWS region where the storage stack was deployed. + type: multiplechoice + variable: create_vm_aws_region + required: true + default: us-east-2 + choices: + - us-east-1 + - us-east-2 + - us-west-1 + - us-west-2 + simplified_workflow_nodes: + - identifier: Delete FSx ONTAP + unified_job_template: Cloud | AWS | Delete FSx ONTAP + extra_data: + delete_fsx_ontap_stack_name: "{{ apd_storage_fsx_stack_name }}" + delete_fsx_ontap_aws_name: "{{ apd_storage_fsx_name }}" + failure_nodes: + - Ticket - FSx Delete Failed + # The node must be deregistered while its VM is still running. + - identifier: Deregister Execution Node + unified_job_template: Cloud | AWS | Deregister Execution Node + extra_data: + deregister_execution_node_vm_name: "{{ apd_storage_vm_name }}" + success_nodes: + - Delete Storage Node + failure_nodes: + - Ticket - Deregister Failed + - identifier: Delete Storage Node + unified_job_template: Cloud | AWS | Delete Stack VM + extra_data: + create_vm_vm_name: "{{ apd_storage_vm_name }}" + success_nodes: + - Update Inventory + failure_nodes: + - Ticket - VM Delete Failed + - identifier: Update Inventory + unified_job_template: AWS Inventory + - identifier: Ticket - FSx Delete Failed + unified_job_template: 'SUBMIT FEEDBACK' + extra_data: + feedback: Failed to delete FSx ONTAP + - identifier: Ticket - Deregister Failed + unified_job_template: 'SUBMIT FEEDBACK' + extra_data: + feedback: Failed to deregister the storage execution node + - identifier: Ticket - VM Delete Failed + unified_job_template: 'SUBMIT FEEDBACK' + extra_data: + feedback: Failed to delete the storage node instance diff --git a/cloud/update_fsx_ontap_inventory.yml b/cloud/update_fsx_ontap_inventory.yml new file mode 100644 index 000000000..92fa41c95 --- /dev/null +++ b/cloud/update_fsx_ontap_inventory.yml @@ -0,0 +1,122 @@ +--- +- name: Add or update Amazon FSx for NetApp ONTAP systems in the AAP inventory + hosts: localhost + gather_facts: false + + vars_files: + - vars/controller_api.yml + module_defaults: + ansible.builtin.uri: "{{ apd_controller_api_uri_defaults }}" + + vars: + update_fsx_ontap_inventory_name: Ansible Product Demos Storage Inventory + update_fsx_ontap_inventory_group: fsx_ontap + # Only FSx file systems carrying this tag are added (set by create_fsx_ontap.yml) + update_fsx_ontap_inventory_managed_by: aap-product-demos + + tasks: + # Deploy 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: + update_fsx_ontap_inventory_aws_region: "{{ create_vm_aws_region }}" + when: + - lookup('ansible.builtin.vars', 'update_fsx_ontap_inventory_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: + - update_fsx_ontap_inventory_aws_region is defined + fail_msg: "update_fsx_ontap_inventory_aws_region must be set" + + - name: Discover FSx ONTAP file systems + ansible.builtin.command: + argv: + - "{{ ansible_playbook_python }}" + - -c + - | + import boto3, json, sys + region, managed_by = sys.argv[1], sys.argv[2] + fsx = boto3.client("fsx", region_name=region) + available, present = [], [] + for page in fsx.get_paginator("describe_file_systems").paginate(): + for fs in page["FileSystems"]: + if fs["FileSystemType"] != "ONTAP": + continue + tags = {t["Key"]: t["Value"] for t in fs.get("Tags", [])} + name = tags.get("Name", fs["FileSystemId"]) + present.append(name) # exists in AWS, whatever its state or tags + if fs["Lifecycle"] == "AVAILABLE" and tags.get("managed-by") == managed_by: + mgmt = fs["OntapConfiguration"]["Endpoints"]["Management"] + available.append({ + "name": name, + "file_system_id": fs["FileSystemId"], + "mgmt_ip": mgmt["IpAddresses"][0], + }) + print(json.dumps({"available": available, "present": present})) + - "{{ update_fsx_ontap_inventory_aws_region }}" + - "{{ update_fsx_ontap_inventory_managed_by }}" + register: update_fsx_ontap_inventory_discovered + changed_when: false + + - name: Set FSx ONTAP facts + ansible.builtin.set_fact: + update_fsx_ontap_inventory_systems: "{{ (update_fsx_ontap_inventory_discovered.stdout | from_json).available }}" + update_fsx_ontap_inventory_present_names: "{{ (update_fsx_ontap_inventory_discovered.stdout | from_json).present }}" + + - name: Report discovered systems + ansible.builtin.debug: + msg: "Found {{ update_fsx_ontap_inventory_systems | length }} FSx ONTAP system(s) in {{ update_fsx_ontap_inventory_aws_region }}" + + - name: Add or update FSx ONTAP hosts in inventory + ansible.controller.host: + name: "{{ item.name }}" + inventory: "{{ update_fsx_ontap_inventory_name }}" + state: present + enabled: true + description: "Amazon FSx for NetApp ONTAP ({{ item.file_system_id }})" + variables: + ansible_host: "{{ item.mgmt_ip }}" + fsx_ontap_file_system_id: "{{ item.file_system_id }}" + fsx_ontap_aws_region: "{{ update_fsx_ontap_inventory_aws_region }}" + loop: "{{ update_fsx_ontap_inventory_systems }}" + loop_control: + label: "{{ item.name }}" + + # Remove hosts for systems that were deleted outside this demo. Only hosts recorded for + # this region are considered (a run covers one region), and a system counts as gone only + # if it no longer exists in AWS at all, so one that is updating keeps its host. + - name: Get the FSx ONTAP hosts already in the inventory + ansible.builtin.uri: + url: "{{ apd_controller_api_url }}/hosts/?inventory__name={{ update_fsx_ontap_inventory_name | urlencode }}&groups__name={{ update_fsx_ontap_inventory_group }}&page_size=200" + register: update_fsx_ontap_inventory_existing + + - name: Work out which of them no longer exist in AWS + ansible.builtin.set_fact: + update_fsx_ontap_inventory_stale: "{{ update_fsx_ontap_inventory_stale | default([]) + [item.name] }}" + loop: "{{ update_fsx_ontap_inventory_existing.json.results }}" + loop_control: + label: "{{ item.name }}" + when: + - (item.variables | from_yaml | default({}, true)).fsx_ontap_aws_region | default('') == update_fsx_ontap_inventory_aws_region + - item.name not in update_fsx_ontap_inventory_present_names + + - name: Remove FSx ONTAP hosts that no longer exist in AWS + ansible.controller.host: + name: "{{ item }}" + inventory: "{{ update_fsx_ontap_inventory_name }}" + state: absent + loop: "{{ update_fsx_ontap_inventory_stale | default([]) }}" + + - name: Ensure FSx ONTAP inventory group contains the hosts + ansible.controller.group: + name: "{{ update_fsx_ontap_inventory_group }}" + inventory: "{{ update_fsx_ontap_inventory_name }}" + state: present + # ONTAP is managed through its REST API, not SSH, so tasks for these + # hosts run on the execution node itself. + variables: + ansible_connection: local + preserve_existing_hosts: true + hosts: "{{ update_fsx_ontap_inventory_systems | map(attribute='name') | list }}" + when: update_fsx_ontap_inventory_systems | length > 0 diff --git a/cloud/vars/controller_api.yml b/cloud/vars/controller_api.yml new file mode 100644 index 000000000..8a19da32d --- /dev/null +++ b/cloud/vars/controller_api.yml @@ -0,0 +1,27 @@ +--- +# How playbooks call the AAP controller API with ansible.builtin.uri: the calls +# the ansible.controller modules cannot make (downloading an install bundle, +# running a health check) and the checks around them (is the instance +# registered, has it been removed). A plain uri call shows exactly which request +# is made, which keeps the playbooks easy to follow. +# +# Authentication comes from the environment variables AAP injects with the +# "Red Hat Ansible Automation Platform" credential: an OAuth token if there is +# one, otherwise username and password. +# +# Load it with: +# vars_files: +# - vars/controller_api.yml +# module_defaults: +# ansible.builtin.uri: "{{ apd_controller_api_uri_defaults }}" +# then call the API with: url: "{{ apd_controller_api_url }}/instances/" +apd_controller_api_url: "{{ lookup('ansible.builtin.env', 'CONTROLLER_HOST') }}/api/controller/v2" +# The platform gateway, for platform-level facts such as the AAP version (/ping/). +apd_gateway_api_url: "{{ lookup('ansible.builtin.env', 'CONTROLLER_HOST') }}/api/gateway/v1" +apd_controller_api_token: "{{ lookup('ansible.builtin.env', 'CONTROLLER_OAUTH_TOKEN') }}" +apd_controller_api_uri_defaults: + headers: "{{ {'Authorization': 'Bearer ' ~ apd_controller_api_token} if apd_controller_api_token | length > 0 else {} }}" + url_username: "{{ lookup('ansible.builtin.env', 'CONTROLLER_USERNAME') if apd_controller_api_token | length == 0 else omit }}" + url_password: "{{ lookup('ansible.builtin.env', 'CONTROLLER_PASSWORD') if apd_controller_api_token | length == 0 else omit }}" + force_basic_auth: "{{ apd_controller_api_token | length == 0 }}" + validate_certs: "{{ (lookup('ansible.builtin.env', 'CONTROLLER_VERIFY_SSL') | default('true', true)) | bool }}" diff --git a/collections/ansible_collections/demo/cloud/roles/aws/defaults/main.yml b/collections/ansible_collections/demo/cloud/roles/aws/defaults/main.yml index c1df4cd97..96cd60550 100644 --- a/collections/ansible_collections/demo/cloud/roles/aws/defaults/main.yml +++ b/collections/ansible_collections/demo/cloud/roles/aws/defaults/main.yml @@ -41,3 +41,12 @@ create_vm_apd_managed_by: aap-product-demos create_vm_apd_demo_tag: "true" create_vm_aws_image_filter: 'RHEL-9*HVM-*Hourly*' create_vm_aws_image_architecture: x86_64 + +####### +# CREATE FSX ONTAP VARS +####### +create_fsx_ontap_storage_capacity: 1024 # GiB +create_fsx_ontap_throughput_capacity: 128 # MB/s +create_fsx_ontap_deployment_type: SINGLE_AZ_1 +create_fsx_ontap_deployment: demo # value of the "deployment" stack tag +create_fsx_ontap_purpose: demo # value of the "purpose" stack tag diff --git a/collections/ansible_collections/demo/cloud/roles/aws/tasks/create_fsx_ontap.yml b/collections/ansible_collections/demo/cloud/roles/aws/tasks/create_fsx_ontap.yml new file mode 100644 index 000000000..b5e293f2d --- /dev/null +++ b/collections/ansible_collections/demo/cloud/roles/aws/tasks/create_fsx_ontap.yml @@ -0,0 +1,104 @@ +--- +- name: Force APD inventory tag strings + ansible.builtin.set_fact: + create_fsx_ontap_aws_apd_managed_by: aap-product-demos + create_fsx_ontap_apd_demo_tag: "true" + +- name: Get subnet info + amazon.aws.ec2_vpc_subnet_info: + region: "{{ create_fsx_ontap_aws_region }}" + filters: + "tag:Name": "{{ create_fsx_ontap_aws_vpc_subnet_name }}" + register: create_fsx_ontap_aws_subnet + when: create_fsx_ontap_aws_subnet_id is not defined + +- name: Save subnet id + ansible.builtin.set_fact: + create_fsx_ontap_aws_subnet_id: "{{ create_fsx_ontap_aws_subnet.subnets | map(attribute='id') | list | last }}" + when: create_fsx_ontap_aws_subnet_id is not defined + +- name: Get Security Group info + amazon.aws.ec2_security_group_info: + region: "{{ create_fsx_ontap_aws_region }}" + filters: + "tag:Name": "{{ create_fsx_ontap_aws_securitygroup_name }}" + register: create_fsx_ontap_aws_securitygroup + when: create_fsx_ontap_aws_securitygroup_id is not defined + +- name: Save Security Group id + ansible.builtin.set_fact: + create_fsx_ontap_aws_securitygroup_id: "{{ create_fsx_ontap_aws_securitygroup.security_groups | map(attribute='group_id') | list | last }}" + when: create_fsx_ontap_aws_securitygroup_id is not defined + +# The admin password is a NoEcho stack parameter and the task is no_log so it +# never appears in job output or stored job events. no_log also hides the +# module's own error text, so on failure show the stack's failed events instead +# (set create_fsx_ontap_no_log=false to see the raw module error while debugging). +- name: Create the FSx ONTAP stack and report failures + block: + - name: Deploy FSx ONTAP CloudFormation Stack + amazon.aws.cloudformation: + stack_name: "{{ create_fsx_ontap_stack_name }}" + state: present + region: "{{ create_fsx_ontap_aws_region }}" + template_parameters: + FsxAdminPassword: "{{ create_fsx_ontap_admin_password | default(fsx_ontap_password) }}" + template_body: | + AWSTemplateFormatVersion: '2010-09-09' + Parameters: + FsxAdminPassword: + Type: String + NoEcho: true + Resources: + FSxFileSystem: + Type: AWS::FSx::FileSystem + Properties: + FileSystemType: ONTAP + SecurityGroupIds: + - "{{ create_fsx_ontap_aws_securitygroup_id }}" + StorageCapacity: {{ create_fsx_ontap_storage_capacity | int }} + SubnetIds: + - "{{ create_fsx_ontap_aws_subnet_id }}" + OntapConfiguration: + DeploymentType: "{{ create_fsx_ontap_deployment_type }}" + ThroughputCapacity: {{ create_fsx_ontap_throughput_capacity | int }} + PreferredSubnetId: "{{ create_fsx_ontap_aws_subnet_id }}" + FsxAdminPassword: !Ref FsxAdminPassword + Tags: + - Key: Name + Value: "{{ create_fsx_ontap_aws_name }}" + Outputs: + FileSystemId: + Description: "FSx file system ID" + Value: !Ref FSxFileSystem + tags: + environment: "{{ create_fsx_ontap_aws_environment }}" + deployment: "{{ create_fsx_ontap_deployment }}" + owner: "{{ create_fsx_ontap_aws_owner_tag }}" + purpose: "{{ create_fsx_ontap_purpose }}" + managed-by: "{{ create_fsx_ontap_aws_apd_managed_by }}" + apd: "{{ create_fsx_ontap_apd_demo_tag }}" + no_log: "{{ create_fsx_ontap_no_log | default(true) }}" + rescue: + - name: Get the FSx ONTAP stack events + amazon.aws.cloudformation_info: + stack_name: "{{ create_fsx_ontap_stack_name }}" + region: "{{ create_fsx_ontap_aws_region }}" + stack_events: true + register: create_fsx_ontap_stack_events + failed_when: false + + - name: Show the failed stack events + ansible.builtin.debug: + msg: "{{ item.logical_resource_id }} {{ item.resource_status }}: {{ item.resource_status_reason | default('no reason given') }}" + loop: >- + {{ (create_fsx_ontap_stack_events.cloudformation | default({})).get(create_fsx_ontap_stack_name, {}) + .get('stack_events', []) | selectattr('resource_status', 'search', 'FAILED') | list }} + loop_control: + label: "{{ item.logical_resource_id }}" + + - name: Fail with the stack name + ansible.builtin.fail: + msg: >- + FSx ONTAP stack {{ create_fsx_ontap_stack_name }} failed; see the failed + stack events above or the CloudFormation console. diff --git a/collections/ansible_collections/demo/cloud/roles/aws/tasks/delete_fsx_ontap.yml b/collections/ansible_collections/demo/cloud/roles/aws/tasks/delete_fsx_ontap.yml new file mode 100644 index 000000000..0ab45e9b4 --- /dev/null +++ b/collections/ansible_collections/demo/cloud/roles/aws/tasks/delete_fsx_ontap.yml @@ -0,0 +1,36 @@ +--- +- name: Look up FSx ONTAP CloudFormation stack + amazon.aws.cloudformation_info: + stack_name: "{{ delete_fsx_ontap_stack_name }}" + region: "{{ delete_fsx_ontap_aws_region }}" + all_facts: true + register: delete_fsx_ontap_stack_info + +- name: Set stack facts + ansible.builtin.set_fact: + delete_fsx_ontap_stack_found: >- + {{ delete_fsx_ontap_stack_info.cloudformation[delete_fsx_ontap_stack_name] is defined }} + +- name: Delete the stack if it exists + when: delete_fsx_ontap_stack_found | bool + block: + - name: Refuse to delete stacks not created by this demo + ansible.builtin.assert: + that: + - >- + (delete_fsx_ontap_stack_info.cloudformation[delete_fsx_ontap_stack_name].stack_tags + | default({})).get('managed-by') == 'aap-product-demos' + fail_msg: >- + Stack {{ delete_fsx_ontap_stack_name }} is not tagged managed-by=aap-product-demos; + refusing to delete it. + + - name: Delete FSx ONTAP CloudFormation stack (also deletes the file system) + amazon.aws.cloudformation: + stack_name: "{{ delete_fsx_ontap_stack_name }}" + state: absent + region: "{{ delete_fsx_ontap_aws_region }}" + +- name: Report missing stack + ansible.builtin.debug: + msg: "Stack {{ delete_fsx_ontap_stack_name }} not found in {{ delete_fsx_ontap_aws_region }}; nothing to delete in AWS." + when: not (delete_fsx_ontap_stack_found | bool) diff --git a/common/setup.yml b/common/setup.yml index eda0fd65b..70afaf2e0 100644 --- a/common/setup.yml +++ b/common/setup.yml @@ -151,6 +151,8 @@ controller_labels: organization: Ansible Product Demos (APD) - name: satellite organization: Ansible Product Demos (APD) + - name: storage + organization: Ansible Product Demos (APD) - name: windows organization: Ansible Product Demos (APD) diff --git a/docs/_data/demos.yml b/docs/_data/demos.yml index c1842c1fc..9456f45c6 100644 --- a/docs/_data/demos.yml +++ b/docs/_data/demos.yml @@ -173,6 +173,79 @@ style H fill:#1e3a5f,stroke:#4a90d9,color:#fff style S fill:#212427,stroke:#8a8d90,color:#fff +- slug: deploy-storage-stack + readme_path: cloud/docs/deploy-storage-stack.md + title: "Deploy a Storage Stack on AWS" + subtitle: "An execution node and Amazon FSx for NetApp ONTAP, wired into AAP" + category: cloud + status: active + author: "Seth Kress " + is_workflow: true + tags: + - Workflow + - Survey + - AWS + thumbnail: + gradient: "linear-gradient(135deg, #2563eb 0%, #1e3a8a 100%)" + icon: "💾" + blurb: "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." + stats: + workflows: 1 + playbooks: 5 + url: /demos/deploy-storage-stack/ + github_path: cloud/setup.yml + workflow_mermaid: | + graph LR + S["🏠 Start"] + S --> A + S --> F + A["🐧 Deploy Storage Node
RHEL 9 VM"] --> B["🔄 Sync Inventory"] + B --> C["🛰️ Register
Execution Node"] + F["💾 Create
FSx ONTAP"] --> G["🔄 Update FSx
Inventory"] + C --> H["✅ Check FSx
Endpoint"] + G --> H + style A fill:#3d1a1a,stroke:#cc0000,color:#fff + style B fill:#162c46,stroke:#58a6ff,color:#fff + style C fill:#1e3a5f,stroke:#4a90d9,color:#fff + style F fill:#1a2744,stroke:#2b88d8,color:#fff + style G fill:#162c46,stroke:#58a6ff,color:#fff + style H fill:#2d1f4e,stroke:#a78bfa,color:#fff + style S fill:#212427,stroke:#8a8d90,color:#fff + +- slug: cloud-destroy-storage-stack + readme_path: cloud/docs/cloud-destroy-storage-stack.md + title: "Destroy a Storage Stack on AWS" + category: cloud + status: active + author: "Seth Kress " + is_workflow: true + tags: + - Workflow + - Survey + - AWS + thumbnail: + gradient: "linear-gradient(135deg, #dc2626 0%, #7f1d1d 100%)" + icon: "💥" + blurb: "Delete the FSx ONTAP file system, deregister the execution node, and terminate its VM." + stats: + workflows: 1 + playbooks: 3 + url: /demos/cloud-destroy-storage-stack/ + github_path: cloud/setup.yml + workflow_mermaid: | + graph LR + S["🏠 Start"] + S --> A + S --> B + A["💥 Delete
FSx ONTAP"] + B["🛰️ Deregister
Execution Node"] --> C["💥 Delete
Storage Node"] + C --> D["🔄 Sync Inventory"] + style A fill:#4a1a1a,stroke:#ef4444,color:#fff + style B fill:#1e3a5f,stroke:#4a90d9,color:#fff + style C fill:#4a1a1a,stroke:#ef4444,color:#fff + style D fill:#2d1f4e,stroke:#a78bfa,color:#fff + style S fill:#212427,stroke:#8a8d90,color:#fff + - slug: cloud-create-vpc readme_path: cloud/docs/cloud-create-vpc.md url: /demos/cloud-create-vpc/ diff --git a/execution_environments/apd-ee-27.yml b/execution_environments/apd-ee-27.yml index 5352f8216..35ef6637a 100644 --- a/execution_environments/apd-ee-27.yml +++ b/execution_environments/apd-ee-27.yml @@ -13,6 +13,7 @@ dependencies: - pywinrm>=0.4.3 - ncclient>=0.7.0 - passlib>=1.7.4 + - requests>=2.20.0 python_interpreter: python_path: /usr/bin/python3.12 diff --git a/execution_environments/requirements-27.yml b/execution_environments/requirements-27.yml index 94338cf62..a6524d4df 100644 --- a/execution_environments/requirements-27.yml +++ b/execution_environments/requirements-27.yml @@ -37,6 +37,10 @@ collections: version: "<11.6.0" - name: community.aws version: "<11.2.0" + - name: ansible.receptor + version: ">=2.0.10" + - name: netapp.ontap + version: ">=21.0.0" # satellite demos - name: redhat.satellite version: "<5.12.0"