From 40515ac65b8366cd2dc69ac42f27080a256ed7d8 Mon Sep 17 00:00:00 2001 From: Chris Edillon <67980205+jce-redhat@users.noreply.github.com> Date: Fri, 16 Aug 2024 14:07:59 -0400 Subject: [PATCH] Create common prerequisites configuration (#169) --- cloud/create_vpc.yml | 9 ++ cloud/setup.yml | 249 ------------------------------------- common/README.md | 3 + common/setup.yml | 283 +++++++++++++++++++++++++++++++++++++++++++ setup_demo.yml | 68 +++-------- 5 files changed, 315 insertions(+), 297 deletions(-) create mode 100644 common/README.md create mode 100644 common/setup.yml diff --git a/cloud/create_vpc.yml b/cloud/create_vpc.yml index 4afd4e704..5fd25e8ff 100644 --- a/cloud/create_vpc.yml +++ b/cloud/create_vpc.yml @@ -122,3 +122,12 @@ Name: "{{ aws_rt_name }}" owner: "{{ aws_owner_tag }}" purpose: "{{ aws_purpose_tag }}" + + - name: Set VPC stats + ansible.builtin.set_stats: + data: + __aws_region: '{{ create_vm_aws_region }}' + __aws_vpc_id: '{{ aws_vpc.vpc.id }}' + __aws_vpc_cidr: '{{ aws_vpc_cidr_block }}' + __aws_subnet_id: '{{ aws_subnet.subnet.id }}' + __aws_subnet_cidr: '{{ aws_subnet_cidr }}' diff --git a/cloud/setup.yml b/cloud/setup.yml index 7c9c08be8..e04653f50 100644 --- a/cloud/setup.yml +++ b/cloud/setup.yml @@ -3,82 +3,6 @@ _deployment_id: "{{ lookup('file', playbook_dir + '/.deployment_id') }}" user_message: -controller_execution_environments: - - name: Cloud Services Execution Environment - image: quay.io/scottharwell/cloud-ee:latest - -controller_projects: - - name: Ansible Cloud Content Lab - AWS - organization: Default - scm_type: git - wait: true - scm_url: https://github.com/ansible-content-lab/aws.infrastructure_config_demos.git - default_environment: Cloud Services Execution Environment - -controller_credentials: - - name: AWS - credential_type: Amazon Web Services - organization: Default - update_secrets: false - state: exists - inputs: - username: REPLACEME - password: REPLACEME - -# - name: Azure -# credential_type: Microsoft Azure Resource Manager -# organization: Default -# update_secrets: false -# inputs: -# subscription: REPLACEME - -controller_inventory_sources: - - name: AWS Inventory - organization: Default - source: ec2 - inventory: Demo Inventory - credential: AWS - overwrite: true - source_vars: - hostnames: - - tag:Name - compose: - ansible_host: public_ip_address - ansible_user: 'ec2-user' - groups: - cloud_aws: true - os_linux: tags.blueprint.startswith('rhel') - keyed_groups: - - key: platform - prefix: os - - key: tags.blueprint - prefix: blueprint - - key: tags.owner - prefix: owner - -# - name: Azure Inventory -# organization: Default -# source: azure_rm -# inventory: Demo Inventory -# credential: Azure -# execution_environment: Ansible Engine 2.9 execution environment -# overwrite: true -# source_vars: -# hostnames: -# - tags.Name -# - default -# keyed_groups: -# - key: os_profile.system -# prefix: os -# conditional_groups: -# cloud_azure: true - -controller_groups: - - name: cloud_aws - inventory: Demo Inventory - variables: - ansible_user: ec2-user - controller_templates: - name: Cloud / AWS / Create Peer Infrastructure job_type: run @@ -140,140 +64,6 @@ controller_templates: extra_vars: aws_region: us-east-1 - - name: Cloud / AWS / Create VPC - job_type: run - organization: Default - credentials: - - AWS - project: Ansible official demo project - playbook: cloud/create_vpc.yml - inventory: Demo Inventory - notification_templates_started: Telemetry - notification_templates_success: Telemetry - notification_templates_error: Telemetry - survey_enabled: true - survey: - name: '' - description: '' - spec: - - question_name: AWS Region - type: multiplechoice - variable: create_vm_aws_region - required: true - choices: - - us-east-1 - - us-east-2 - - us-west-1 - - us-west-2 - - question_name: Owner - type: text - variable: aws_owner_tag - required: true - - - name: Cloud / AWS / Create VM - job_type: run - organization: Default - credentials: - - AWS - - Demo Credential - project: Ansible Cloud Content Lab - AWS - playbook: playbooks/create_vm.yml - inventory: Demo Inventory - notification_templates_started: Telemetry - notification_templates_success: Telemetry - notification_templates_error: Telemetry - survey_enabled: true - allow_simultaneous: true - survey: - name: '' - description: '' - spec: - - question_name: AWS Region - type: multiplechoice - variable: create_vm_aws_region - required: true - choices: - - us-east-1 - - us-east-2 - - us-west-1 - - us-west-2 - - question_name: Name - type: text - variable: create_vm_vm_name - required: true - - question_name: Owner - type: text - variable: create_vm_vm_owner - required: true - - question_name: Deployment - type: text - variable: create_vm_vm_deployment - required: true - - question_name: Environment - type: multiplechoice - variable: create_vm_vm_environment - required: true - choices: - - Dev - - QA - - Prod - - question_name: Blueprint - type: multiplechoice - variable: vm_blueprint - required: true - choices: - - windows_core - - windows_full - - rhel9 - - rhel8 - - rhel7 - - al2023 - - question_name: Subnet - type: text - variable: create_vm_aws_vpc_subnet_name - required: true - default: aws-test-subnet - - question_name: Security Group - type: text - variable: create_vm_aws_securitygroup_name - required: true - default: aws-test-sg - - question_name: SSH Keypair - type: text - variable: create_vm_aws_keypair_name - required: true - default: aws-test-key - - question_name: AWS Instance Type (defaults to blueprint value) - type: text - variable: create_vm_aws_instance_size - required: false - - question_name: AWS Image Filter (defaults to blueprint value) - type: text - variable: create_vm_aws_image_filter - required: false - - - name: Cloud / AWS / Delete VM - job_type: run - organization: Default - credentials: - - AWS - - Demo Credential - project: Ansible Cloud Content Lab - AWS - playbook: playbooks/delete_inventory_vm.yml - inventory: Demo Inventory - notification_templates_started: Telemetry - notification_templates_success: Telemetry - notification_templates_error: Telemetry - survey_enabled: true - survey: - name: '' - description: '' - spec: - - question_name: Name or Pattern - type: text - variable: _hosts - required: true - - name: Cloud / AWS / VPC Report job_type: run organization: Default @@ -332,45 +122,6 @@ controller_templates: - us-west-1 - us-west-2 - - name: Cloud / AWS / Create Keypair - job_type: run - organization: Default - credentials: - - AWS - project: Ansible official demo project - playbook: cloud/aws_key.yml - inventory: Demo Inventory - notification_templates_started: Telemetry - notification_templates_success: Telemetry - notification_templates_error: Telemetry - survey_enabled: true - survey: - name: '' - description: '' - spec: - - question_name: AWS Region - type: multiplechoice - variable: create_vm_aws_region - required: true - choices: - - us-east-1 - - us-east-2 - - us-west-1 - - us-west-2 - - question_name: Keypair Name - type: text - variable: aws_key_name - required: true - default: aws-test-key - - question_name: Keypair Public Key - type: textarea - variable: aws_public_key - required: true - - question_name: Owner - type: text - variable: aws_keypair_owner - required: true - - name: Cloud / AWS / Snapshot EC2 job_type: run organization: Default diff --git a/common/README.md b/common/README.md new file mode 100644 index 000000000..f023e319d --- /dev/null +++ b/common/README.md @@ -0,0 +1,3 @@ +# Common Prerequisites + +Demos from some categories (cloud, linux, windows, etc.) have become dependent on controller resources defined in other demo categories. The setup.yml file in this directory is used to configure these common prerequisites so that they are available before setup for a demo category is called. diff --git a/common/setup.yml b/common/setup.yml new file mode 100644 index 000000000..ca88c9530 --- /dev/null +++ b/common/setup.yml @@ -0,0 +1,283 @@ +--- +controller_execution_environments: + - name: product-demos + image: quay.io/acme_corp/product-demos-ee:latest + - name: Cloud Services Execution Environment + image: quay.io/scottharwell/cloud-ee:latest + +controller_organizations: + - name: Default + default_environment: product-demos + +controller_projects: + - name: Ansible Cloud Content Lab - AWS + organization: Default + scm_type: git + wait: true + scm_url: https://github.com/ansible-content-lab/aws.infrastructure_config_demos.git + default_environment: Cloud Services Execution Environment + +controller_credentials: + - name: AWS + credential_type: Amazon Web Services + organization: Default + update_secrets: false + state: exists + inputs: + username: REPLACEME + password: REPLACEME + +controller_inventory_sources: + - name: AWS Inventory + organization: Default + source: ec2 + inventory: Demo Inventory + credential: AWS + overwrite: true + source_vars: + hostnames: + - tag:Name + compose: + ansible_host: public_ip_address + ansible_user: 'ec2-user' + groups: + cloud_aws: true + os_linux: tags.blueprint.startswith('rhel') + os_windows: tags.blueprint.startswith('win') + keyed_groups: + - key: platform + prefix: os + - key: tags.blueprint + prefix: blueprint + - key: tags.owner + prefix: owner + - key: tags.purpose + prefix: purpose + - key: tags.deployment + prefix: deployment + +controller_groups: + - name: cloud_aws + inventory: Demo Inventory + variables: + ansible_user: ec2-user + - name: os_windows + inventory: Demo Inventory + variables: + ansible_connection: winrm + ansible_winrm_transport: credssp + +controller_templates: + - name: SUBMIT FEEDBACK + job_type: run + inventory: Demo Inventory + project: Ansible official demo project + playbook: feedback.yml + execution_environment: Default execution environment + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + survey_enabled: true + survey: + name: '' + description: '' + spec: + - question_name: Name/Email/Contact + type: text + variable: email + required: true + - question_name: Issue or Feedback + type: textarea + variable: feedback + required: true + + - name: Cloud / AWS / Create VPC + job_type: run + organization: Default + credentials: + - AWS + project: Ansible official demo project + playbook: cloud/create_vpc.yml + inventory: Demo Inventory + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + survey_enabled: true + survey: + name: '' + description: '' + spec: + - question_name: AWS Region + type: multiplechoice + variable: create_vm_aws_region + required: true + choices: + - us-east-1 + - us-east-2 + - us-west-1 + - us-west-2 + - question_name: Owner + type: text + variable: aws_owner_tag + required: true + + - name: Cloud / AWS / Create Keypair + job_type: run + organization: Default + credentials: + - AWS + project: Ansible official demo project + playbook: cloud/aws_key.yml + inventory: Demo Inventory + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + survey_enabled: true + survey: + name: '' + description: '' + spec: + - question_name: AWS Region + type: multiplechoice + variable: create_vm_aws_region + required: true + choices: + - us-east-1 + - us-east-2 + - us-west-1 + - us-west-2 + - question_name: Keypair Name + type: text + variable: aws_key_name + required: true + default: aws-test-key + - question_name: Keypair Public Key + type: textarea + variable: aws_public_key + required: true + - question_name: Owner + type: text + variable: aws_keypair_owner + required: true + + - name: Cloud / AWS / Create VM + job_type: run + organization: Default + credentials: + - AWS + - Demo Credential + project: Ansible Cloud Content Lab - AWS + playbook: playbooks/create_vm.yml + inventory: Demo Inventory + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + survey_enabled: true + allow_simultaneous: true + survey: + name: '' + description: '' + spec: + - question_name: AWS Region + type: multiplechoice + variable: create_vm_aws_region + required: true + choices: + - us-east-1 + - us-east-2 + - us-west-1 + - us-west-2 + - question_name: Name + type: text + variable: create_vm_vm_name + required: true + - question_name: Owner + type: text + variable: create_vm_vm_owner + required: true + - question_name: Deployment + type: text + variable: create_vm_vm_deployment + required: true + - question_name: Purpose + type: text + variable: create_vm_vm_purpose + required: true + default: demo + - question_name: Environment + type: multiplechoice + variable: create_vm_vm_environment + required: true + choices: + - Dev + - QA + - Prod + - question_name: Blueprint + type: multiplechoice + variable: vm_blueprint + required: true + choices: + - windows_core + - windows_full + - rhel9 + - rhel8 + - rhel7 + - al2023 + - question_name: Subnet + type: text + variable: create_vm_aws_vpc_subnet_name + required: true + default: aws-test-subnet + - question_name: Security Group + type: text + variable: create_vm_aws_securitygroup_name + required: true + default: aws-test-sg + - question_name: SSH Keypair + type: text + variable: create_vm_aws_keypair_name + required: true + default: aws-test-key + - question_name: AWS Instance Type (defaults to blueprint value) + type: text + variable: create_vm_aws_instance_size + required: false + - question_name: AWS Image Filter (defaults to blueprint value) + type: text + variable: create_vm_aws_image_filter + required: false + + - name: Cloud / AWS / Delete VM + job_type: run + organization: Default + credentials: + - AWS + - Demo Credential + project: Ansible Cloud Content Lab - AWS + playbook: playbooks/delete_inventory_vm.yml + inventory: Demo Inventory + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + survey_enabled: true + survey: + name: '' + description: '' + spec: + - question_name: Name or Pattern + type: text + variable: _hosts + required: true + +controller_notifications: + - name: Telemetry + organization: Default + notification_type: webhook + notification_configuration: + url: https://script.google.com/macros/s/AKfycbzxUObvCJ6ZbzfJyicw4RvxlGE3AZdrK4AR5-TsedCYd7O-rtTOVjvsRvqyb3rx6B0g8g/exec + http_method: POST + headers: {} + +controller_settings: + - name: SESSION_COOKIE_AGE + value: 180000 diff --git a/setup_demo.yml b/setup_demo.yml index 38baa4543..b9fd37d6c 100644 --- a/setup_demo.yml +++ b/setup_demo.yml @@ -1,63 +1,33 @@ --- -- name: Setup demo +- name: Setup common prerequisites hosts: localhost gather_facts: false - tasks: - - name: Default Components - ansible.builtin.include_role: - name: infra.controller_configuration.dispatch - vars: # noqa var-naming[no-role-prefix] - controller_execution_environments: - - name: product-demos - image: quay.io/acme_corp/product-demos-ee:latest - controller_organizations: - - name: Default - default_environment: product-demos - controller_notifications: - - name: Telemetry - organization: Default - notification_type: webhook - notification_configuration: - url: https://script.google.com/macros/s/AKfycbzxUObvCJ6ZbzfJyicw4RvxlGE3AZdrK4AR5-TsedCYd7O-rtTOVjvsRvqyb3rx6B0g8g/exec - http_method: POST - headers: {} - controller_templates: - - name: "SUBMIT FEEDBACK" - job_type: run - inventory: "Demo Inventory" - project: "Ansible official demo project" - playbook: "feedback.yml" - execution_environment: Default execution environment - notification_templates_started: Telemetry - notification_templates_success: Telemetry - notification_templates_error: Telemetry - survey_enabled: true - survey: - name: '' - description: '' - spec: - - question_name: Name/Email/Contact - type: text - variable: email - required: true - - question_name: Issue or Feedback - type: textarea - variable: feedback - required: true - controller_settings: - - name: "SESSION_COOKIE_AGE" - value: 180000 + # vars_files should be scoped to a play so variables defined in the + # files should not be available in subsequent plays, so certain + # resources won't be retried + vars_files: + - common/setup.yml + + tasks: - name: Create reusable deployment ID ansible.builtin.set_fact: _deployment_id: '{{ lookup("ansible.builtin.password", "{{ playbook_dir }}/.deployment_id", chars=["ascii_lowercase", "digits"], length=5) }}' - - name: "Include configuration for {{ demo }}" + - name: Create common demo resources + ansible.builtin.include_role: + name: infra.controller_configuration.dispatch + +- name: Setup demo + hosts: localhost + gather_facts: false + tasks: + - name: Include configuration for {{ demo }} ansible.builtin.include_vars: "{{ demo }}/setup.yml" - name: Demo Components ansible.builtin.include_role: - name: "infra.controller_configuration.dispatch" + name: infra.controller_configuration.dispatch - name: Log Demo ansible.builtin.uri: @@ -70,3 +40,5 @@ ansible.builtin.debug: msg: "{{ user_message }}" when: user_message is defined + +...