From 22f38d6091ceeca697e8a629b8679da58c75ffeb Mon Sep 17 00:00:00 2001 From: Mike Graves Date: Fri, 22 Nov 2024 14:04:01 -0500 Subject: [PATCH] Add experience for creating EC2 instance --- .../experiences/ec2_instance_create/README.md | 49 +++++++++++ .../experiences/ec2_instance_create/setup.yml | 35 ++++++++ .../template_surveys/create_ec2_instance.yml | 83 +++++++++++++++++++ 3 files changed, 167 insertions(+) create mode 100644 extensions/experiences/ec2_instance_create/README.md create mode 100644 extensions/experiences/ec2_instance_create/setup.yml create mode 100644 extensions/experiences/ec2_instance_create/template_surveys/create_ec2_instance.yml diff --git a/extensions/experiences/ec2_instance_create/README.md b/extensions/experiences/ec2_instance_create/README.md new file mode 100644 index 00000000..8566957a --- /dev/null +++ b/extensions/experiences/ec2_instance_create/README.md @@ -0,0 +1,49 @@ +# Create EC2 Instance Experience + +## Description + +This experience is designed to help get an EC2 instance up and running. + +## What This Experience Covers + +### Project Templates + +- **Create EC2 Instance Template**: Defined in `setup.yml`, this template helps organize and manage all necessary components for the ec2 creation experience. It ensures that relevant files, roles, and configurations are logically arranged, making it easier to maintain and execute automation tasks. + +### Job Templates + +- **Create EC2 Instance Job Template**: This template is designed to streamline the process of creating and EC2 instance. + +### Playbooks + +- **Playbooks**: + +### Surveys + +- **Create EC2 Instance Survey**: This survey provides an interactive way to specify parameters for creating the EC2 instance. + +## Resources Created by This Experience + +1. **Project Templates** + - Ensure that all relevant files, roles, and configurations are logically arranged, facilitating easier maintenance and execution of automation tasks. + +2. **Job Templates** + - Outline the necessary parameters and configurations to perform network backups using the provided playbooks. + +## How to Use + +1. **Use Seed Red Hat Experience Job** + - Ensure the custom EE is correctly built and available in your Ansible Automation Platform. Execute the "Seed Red Hat Experience" job within the Ansible Automation Platform, and select the "AWS Operations" category to load this experience. + +2. **Use the Job Templates** + - In the `Create EC2 Instance Automation Experience Project` execute the required job template to create the EC2 instance. Monitor the job execution and verify that the instance has been successfully created. + +## Contribution + +Contributions to this project are welcome. Please fork the repository, make your changes, and submit a pull request. + +## License + +GNU General Public License v3.0 or later. + +See [LICENSE](https://www.gnu.org/licenses/gpl-3.0.txt) to see the full text. This project is licensed under the MIT License. See the [LICENSE](https://github.com/redhat-cop/cloud.aws_ops/blob/main/LICENSE) file for details. diff --git a/extensions/experiences/ec2_instance_create/setup.yml b/extensions/experiences/ec2_instance_create/setup.yml new file mode 100644 index 00000000..cd97df5d --- /dev/null +++ b/extensions/experiences/ec2_instance_create/setup.yml @@ -0,0 +1,35 @@ +--- + +controller_labels: + - name: cloud.aws_ops + organization: "{{ organization | default('Default') }}" + - name: ec2_instance_experience + organization: "{{ organization | default('Default') }}" + - name: create_ec2_instance + organization: "{{ organization | default('Default') }}" + +controller_projects: + - name: AWS Operations / Create EC2 Instance + organization: "{{ organization | default('Default') }}" + scm_branch: main + scm_clean: no + scm_delete_on_update: no + scm_type: git + scp_update_on_launch: no + scm_url: https://github.com/redhat-cop/cloud.aws_ops.git + +controller_templates: + - name: AWS Operations / Create EC2 Instance + description: This job template creates an EC2 instance. + ask_inventory_on_launch: true + ask_execution_environment_on_launch: true + project: AWS Operations / Create EC2 Instance + playbook: extensions/experiences/ec2_instance_create/create_ec2_instance.yml + job_type: run + organization: "{{ organization | default('Default') }}" + labels: + - cloud.aws_ops + - ec2_instance_experience + - create_ec2_instance + survey_enabled: true + survey_spec: "{{ lookup('file', experience.path.replace('setup.yml', '') + 'template_surveys/create_ec2_instance.yml') | from_yaml }}" diff --git a/extensions/experiences/ec2_instance_create/template_surveys/create_ec2_instance.yml b/extensions/experiences/ec2_instance_create/template_surveys/create_ec2_instance.yml new file mode 100644 index 00000000..fb9e6ba3 --- /dev/null +++ b/extensions/experiences/ec2_instance_create/template_surveys/create_ec2_instance.yml @@ -0,0 +1,83 @@ +--- +name: Create EC2 Instance Survey +description: Survey to configure the EC2 creation experience +spec: + - type: text + question_name: AWS Region + question_description: Name of AWS region to create instance in + variable: ec2_instance_create_aws_region + required: true + + - type: text + question_name: Instance Name + question_description: Name of EC2 instance + variable: ec2_instance_create_instance_name: + required: true + + - type: text + question_name: Instance Type + question_description: Type of EC2 instance (e.g., t2.micro, m5.large) + variable: ec2_instance_create_instance_type + required: true + + - type: text + question_name: AMI ID + question_description: AMI ID for EC2 instance + variable: ec2_instance_create_ami_id + required: true + + - type: text + question_name: Key Pair Name + question_description: Name of key pair to use for SSH access to the EC2 instance + variable: ec2_instance_create_key_name + required: true + + - type: text + question_name: VPC Subnet ID + question_description: ID of subnet to launch EC2 instance in + variable: ec2_instance_create_vpc_subnet_id + required: true + + - type: multiplechoice + question_name: Create Elastic IP + question_description: Whether to create and associate an Elastic IP with the instance + variable: ec2_instance_create_associate_eip + choices: + - true + - false + required: false + default: false + + - type: multiplechoice + question_name: Create External Security Group + question_description: Whether to create and associate a security group for external access to the instance + variable: ec2_instance_create_associate_external_sg + choices: + - true + - false + required: false + default: false + + - type: text + question_name: External Security Group Name + question_description: Name of the security group for external access to the instance + variable: ec2_instance_create_external_sg_name + required: false + default: ec2_instance_create-default-external-sg + + - type: text + question_name: External Security Group Description + question_description: Description of the security group for external access to the instance + variable: ec2_instance_create_external_sg_description + required: false + default: Security group for external access + + - type: multiplechoice + question_name: Create Internet Gateway + question_description: Whether to create and attach an internet gateway + variable: ec2_instance_create_associate_igw + choices: + - true + - false + required: false + default: false