From 5453e29be6ff122c9a2666feddad402fc577a419 Mon Sep 17 00:00:00 2001 From: Scott Harwell <805434+scottharwell@users.noreply.github.com> Date: Mon, 6 Nov 2023 11:44:50 -0500 Subject: [PATCH] Version 3.0.0 (#18) * Update lint and deps * Move playbook vars into playbook dir * Fix include_role * Remove tag * Added create vpc playbook * Correct role paths * Remove unneeded var * Added changelog --- .ansible-lint | 17 ++++-- .ansible-lint-ignore | 3 - CHANGELOG.rst | 28 +++++++++ README.md | 45 +++++++------- changelogs/.plugin-cache.yaml | 19 ++++++ changelogs/changelog.yaml | 16 +++++ changelogs/config.yaml | 32 ++++++++++ galaxy.yml | 10 ++-- .../tasks/direct_peered_networks.yml | 8 +-- .../tasks/peer_transit_networks.yml | 8 +-- .../tasks/transit_peered_networks.yml | 4 +- playbooks/create_peer_network.yml | 4 +- playbooks/create_reports.yml | 2 +- playbooks/create_transit_network.yml | 4 +- playbooks/create_vm.yml | 2 +- playbooks/create_vpc.yml | 58 +++++++++++++++++++ playbooks/delete_peer_network.yml | 4 +- playbooks/delete_transit_network.yml | 4 +- playbooks/delete_vpc.yml | 49 ++++++++++++++++ playbooks/peer_networks.yml | 4 +- playbooks/peer_to_transit_network.yml | 4 +- {vars => playbooks/vars}/create_vm.yml | 2 +- playbooks/vars/create_vpc.yml | 15 +++++ {vars => playbooks/vars}/main.yml | 0 .../vars}/vm_blueprints/al2023.yml | 0 .../vars}/vm_blueprints/rhel7.yml | 0 .../vars}/vm_blueprints/rhel8.yml | 0 .../vars}/vm_blueprints/rhel9.yml | 0 .../vars}/vm_blueprints/windows_core.yml | 0 .../vars}/vm_blueprints/windows_full.yml | 0 roles/create_vm/tasks/main.yml | 4 +- 31 files changed, 283 insertions(+), 63 deletions(-) delete mode 100644 .ansible-lint-ignore create mode 100644 CHANGELOG.rst create mode 100644 changelogs/.plugin-cache.yaml create mode 100644 changelogs/changelog.yaml create mode 100644 changelogs/config.yaml create mode 100644 playbooks/create_vpc.yml create mode 100644 playbooks/delete_vpc.yml rename {vars => playbooks/vars}/create_vm.yml (74%) create mode 100644 playbooks/vars/create_vpc.yml rename {vars => playbooks/vars}/main.yml (100%) rename {vars => playbooks/vars}/vm_blueprints/al2023.yml (100%) rename {vars => playbooks/vars}/vm_blueprints/rhel7.yml (100%) rename {vars => playbooks/vars}/vm_blueprints/rhel8.yml (100%) rename {vars => playbooks/vars}/vm_blueprints/rhel9.yml (100%) rename {vars => playbooks/vars}/vm_blueprints/windows_core.yml (100%) rename {vars => playbooks/vars}/vm_blueprints/windows_full.yml (100%) diff --git a/.ansible-lint b/.ansible-lint index 6007ef5..38b5112 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,14 +1,21 @@ --- +profile: basic +quiet: false +verbosity: 1 + exclude_paths: - .cache/ - .github/ - test + - changelogs enable_list: - - empty-string-compare # opt-in - - no-log-password # opt-in - - no-same-owner # opt-in + - empty-string-compare + - no-log-password + - no-same-owner + - yaml skip_list: - - role-name[path] - - galaxy[no-changelog] + - package-latest + - yaml[line-length] + - var-naming[no-role-prefix] diff --git a/.ansible-lint-ignore b/.ansible-lint-ignore deleted file mode 100644 index 8cef74b..0000000 --- a/.ansible-lint-ignore +++ /dev/null @@ -1,3 +0,0 @@ -roles/reports/tasks/main.yml args[module] -roles/reports/tasks/tags.yml args[module] -roles/reports/tasks/vpc.yml args[module] diff --git a/CHANGELOG.rst b/CHANGELOG.rst new file mode 100644 index 0000000..0024af0 --- /dev/null +++ b/CHANGELOG.rst @@ -0,0 +1,28 @@ +========================================================= +lab.azure.azure_infrastructure_config_demos Release Notes +========================================================= + +.. contents:: Topics + +This changelog describes changes after version 2.0.0. + +v3.0.0 +====== + +Release Summary +--------------- + +Updated the collection to match validated patterns. + +Major Changes +------------- + +- Moved playbooks into playbooks folder so that playbooks may be called from `namespace.collection.playbook` syntax. +- Updated Ansible Lint config. + +Breaking Changes / Porting Guide +-------------------------------- + +- Playbook names have changed. +- Playbook paths have changed. +- Playbooks now reference role by FQRN. diff --git a/README.md b/README.md index fc1665c..495be5c 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -[![Validation CI](https://github.com/ansible-content-lab/aws.infrastructure_config_demos/actions/workflows/validate.yml/badge.svg)](https://github.com/ansible-content-lab/aws.infrastructure_config_demos/actions/workflows/validate.yml) +[![Validation CI](https://github.com/ansible-content-lab/aws.infrastructure_config_demos/actions/workflows/validate.yml/badge.svg)](https://github.com/ansible-content-lab/lab.aws_infrastructure_config_demos/actions/workflows/validate.yml) -# Ansible Collection - aws.infrastructure_config_demos +# Ansible Collection - lab.aws_infrastructure_config_demos -This repository hosts the `aws.infrastructure_config_demos` Ansible Collection. +This repository hosts the `lab.aws_infrastructure_config_demos` Ansible Collection. The collection includes a variety of Ansible roles and playbook to help automate the management of resources on AWS. @@ -10,38 +10,37 @@ This content was developed as part of the [Ansible Content Lab for Cloud Content ## Included Content - ### Roles Click on the role name to be directed to the README specifically for that role. -| Name | Description | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -| [aws.infrastructure_config_demos.create_vm](https://github.com/ansible-content-lab/aws.infrastructure_config_demos/blob/main/roles/create_vm/README.md) | A role to create AWS virtual machines. | -| [aws.infrastructure_config_demos.manage_transit_peered_networks](https://github.com/ansible-content-lab/aws.infrastructure_config_demos/blob/main/roles/manage_transit_peered_networks/README.md) | A role to create a hub-and-spoke VPC networking architecture that includes DMZ and private networks. | -| [aws.infrastructure_config_demos.peer_existing_networks](https://github.com/ansible-content-lab/aws.infrastructure_config_demos/blob/main/roles/peer_existing_networks/README.md) | A role to automate the peering of two or more VPCs through direct peering model. | -| [aws.infrastructure_config_demos.peer_transit_network](https://github.com/ansible-content-lab/aws.infrastructure_config_demos/blob/main/roles/peer_transit_network/README.md) | Peers a VPC into an AWS transit gateway and configures routing rules across all attached VPCs to allow traffic to the newly attached VPC. | +| Name | Description | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | +| [lab.aws_infrastructure_config_demos.create_vm](https://github.com/ansible-content-lab/aws.infrastructure_config_demos/blob/main/roles/create_vm/README.md) | A role to create AWS virtual machines. | +| [lab.aws_infrastructure_config_demos.manage_transit_peered_networks](https://github.com/ansible-content-lab/aws.infrastructure_config_demos/blob/main/roles/manage_transit_peered_networks/README.md) | A role to create a hub-and-spoke VPC networking architecture that includes DMZ and private networks. | +| [aws.infrastructure_config_demos.peer_existing_networks](https://github.com/ansible-content-lab/lab.aws_infrastructure_config_demos/blob/main/roles/peer_existing_networks/README.md) | A role to automate the peering of two or more VPCs through direct peering model. | +| [aws.infrastructure_config_demos.peer_transit_network](https://github.com/ansible-content-lab/lab.aws_infrastructure_config_demos/blob/main/roles/peer_transit_network/README.md) | Peers a VPC into an AWS transit gateway and configures routing rules across all attached VPCs to allow traffic to the newly attached VPC. | ### Playbooks -| Name | Role(s) Used | Description | -| ----------------------------- | -------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | -| `create_peer_network.yml` | `roles.manage_direct_peered_networks` | A playbook to create a multi-VPC peer network configuration with DMZ and private networks. | -| `delete_peer_network.yml` | `roles.manage_direct_peered_networks` | Deletes AWS resources created in the `create_peer_network` playbook. | -| `peer_networks.yml` | `roles.peer_networks` | Peer two or more VPCs with VPC peering. | -| `create_transit_network.yml` | `roles.manage_transit_peered_networks` | A playbook to create a multi-VPC hub-and-spoke network configuration using a transit gateway with DMZ and private networks. | -| `delete_transit_network.yml` | `roles.manage_transit_peered_networks` | Deletes AWS resources created in the `create_transit_network` playbook. | -| `peer_to_transit_network.yml` | `roles.peer_transit_network` | A playbook to execute the Transit Gateway peering operation in the role used. | -| `create_vm.yml` | N/A | Simple playbook to create an AWS VM. | -| `delete_vm.yml` | N/A | Deletes the VM created in the `create_vm` playbook. | +| Name | Role(s) Used | Description | +| ----------------------------- | -------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | +| `create_peer_network.yml` | `lab.aws_infrastructure_config_demos.manage_direct_peered_networks` | A playbook to create a multi-VPC peer network configuration with DMZ and private networks. | +| `delete_peer_network.yml` | `lab.aws_infrastructure_config_demos.manage_direct_peered_networks` | Deletes AWS resources created in the `create_peer_network` playbook. | +| `peer_networks.yml` | `lab.aws_infrastructure_config_demos.peer_networks` | Peer two or more VPCs with VPC peering. | +| `create_transit_network.yml` | `lab.aws_infrastructure_config_demos.manage_transit_peered_networks` | A playbook to create a multi-VPC hub-and-spoke network configuration using a transit gateway with DMZ and private networks. | +| `delete_transit_network.yml` | `lab.aws_infrastructure_config_demos.manage_transit_peered_networks` | Deletes AWS resources created in the `create_transit_network` playbook. | +| `peer_to_transit_network.yml` | `lab.aws_infrastructure_config_demos.peer_transit_network` | A playbook to execute the Transit Gateway peering operation in the role used. | +| `create_vm.yml` | N/A | Simple playbook to create an AWS VM. | +| `delete_vm.yml` | N/A | Deletes the VM created in the `create_vm` playbook. | #### VM Playbooks -The `aws.infrastructure_config_demos.create_vm` and `aws.infrastructure_config_demos.delete_vm` playbooks demonstrate how you can construct automation to deploy AWS resources that have dependencies on others. The more complex networking roles and playbooks automate building all of the resources, but these playbooks assume that you have existing infrastructure (VPCs, security groups, SSH keys, etc.) that you want to leverage to deploy the EC2 instance. The command below shows how you can use Ansible Navigator to deploy the instance with variables being set both in var files and directly in the CLI. +The `lab.aws_infrastructure_config_demos.create_vm` and `aws.infrastructure_config_demos.delete_vm` playbooks demonstrate how you can construct automation to deploy AWS resources that have dependencies on others. The more complex networking roles and playbooks automate building all of the resources, but these playbooks assume that you have existing infrastructure (VPCs, security groups, SSH keys, etc.) that you want to leverage to deploy the EC2 instance. The command below shows how you can use Ansible Navigator to deploy the instance with variables being set both in var files and directly in the CLI. ```yaml -ansible-navigator run aws.infrastructure_config_demos.create_vm \ +ansible-navigator run lab.aws_infrastructure_config_demos.create_vm \ --pae false \ --mode stdout \ --ee true \ @@ -61,7 +60,7 @@ ansible-navigator run aws.infrastructure_config_demos.create_vm \ #### Create Network Playbooks -The `aws.infrastructure_config_demos.create_peer_network` and `aws.infrastructure_config_demos.create_transit_network` playbooks have another tasks block that will attempt to configure the EC2 resources deployed by the roles a bit farther. When the role completes, EC2 instances in the DMZ will still need to be configured with SSH configuration in order to communicate with EC2 instances in the private network(s). +The `lab.aws_infrastructure_config_demos.create_peer_network` and `lab.aws_infrastructure_config_demos.create_transit_network` playbooks have another tasks block that will attempt to configure the EC2 resources deployed by the roles a bit farther. When the role completes, EC2 instances in the DMZ will still need to be configured with SSH configuration in order to communicate with EC2 instances in the private network(s). To connect to the DMZ EC2 instance, the `ansible_ssh_private_key_file` variable needs to be set so that the machine running the playbook can connect to the newly created EC2 instance. You may set this variable in any way that Ansible allows, i.e. extra var, host var, etc. It must be set or the configuration step will be skipped. The `ansible_ssh_user` variable is set automatically to the user `ec2-user` that is standard on AWS AMIs. diff --git a/changelogs/.plugin-cache.yaml b/changelogs/.plugin-cache.yaml new file mode 100644 index 0000000..4c218dd --- /dev/null +++ b/changelogs/.plugin-cache.yaml @@ -0,0 +1,19 @@ +objects: + role: {} +plugins: + become: {} + cache: {} + callback: {} + cliconf: {} + connection: {} + filter: {} + httpapi: {} + inventory: {} + lookup: {} + module: {} + netconf: {} + shell: {} + strategy: {} + test: {} + vars: {} +version: 3.0.0 diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml new file mode 100644 index 0000000..69ad5b6 --- /dev/null +++ b/changelogs/changelog.yaml @@ -0,0 +1,16 @@ +ancestor: 2.0.0 +releases: + 3.0.0: + changes: + breaking_changes: + - Playbook names have changed. + - Playbook paths have changed. + - Playbooks now reference role by FQRN. + major_changes: + - Moved playbooks into playbooks folder so that playbooks may be called from + `namespace.collection.playbook` syntax. + - Updated Ansible Lint config. + release_summary: Updated the collection to match validated patterns. + fragments: + - version-3.yml + release_date: "2023-11-06" diff --git a/changelogs/config.yaml b/changelogs/config.yaml new file mode 100644 index 0000000..3e8d247 --- /dev/null +++ b/changelogs/config.yaml @@ -0,0 +1,32 @@ +changelog_filename_template: ../CHANGELOG.rst +changelog_filename_version_depth: 0 +changes_file: changelog.yaml +changes_format: combined +ignore_other_fragment_extensions: true +keep_fragments: false +mention_ancestor: true +new_plugins_after_name: removed_features +notesdir: fragments +prelude_section_name: release_summary +prelude_section_title: Release Summary +sanitize_changelog: true +sections: + - - major_changes + - Major Changes + - - minor_changes + - Minor Changes + - - breaking_changes + - Breaking Changes / Porting Guide + - - deprecated_features + - Deprecated Features + - - removed_features + - Removed Features (previously deprecated) + - - security_fixes + - Security Fixes + - - bugfixes + - Bugfixes + - - known_issues + - Known Issues +title: lab.azure.azure_infrastructure_config_demos +trivial_section_name: trivial +use_fqcn: true diff --git a/galaxy.yml b/galaxy.yml index 14530c4..c82a17f 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,7 +1,7 @@ --- -namespace: aws -name: infrastructure_config_demos -version: 2.1.0 +namespace: lab +name: aws_infrastructure_config_demos +version: 3.0.0 readme: README.md authors: - Scott Harwell @@ -13,9 +13,9 @@ tags: - "cloud" - "aws" dependencies: - amazon.aws: ">=6.2.0" + amazon.aws: ">=6.5.0" amazon.cloud: ">=0.4.0" - community.aws: ">=6.1.0" + community.aws: ">=6.3.0" repository: https://github.com/ansible-content-lab/aws.infrastructure_config_demos documentation: https://github.com/ansible-content-lab/aws.infrastructure_config_demos homepage: https://github.com/ansible-content-lab/aws.infrastructure_config_demos diff --git a/molecule/direct_peered_networks/tasks/direct_peered_networks.yml b/molecule/direct_peered_networks/tasks/direct_peered_networks.yml index d7b97ce..52a29c4 100644 --- a/molecule/direct_peered_networks/tasks/direct_peered_networks.yml +++ b/molecule/direct_peered_networks/tasks/direct_peered_networks.yml @@ -8,8 +8,8 @@ - name: Test Peer Network Deployment block: - name: Create Peer Network - ansible.builtin.import_role: - name: aws.infrastructure_config_demos.manage_direct_peered_networks + ansible.builtin.include_role: + name: lab.aws_infrastructure_config_demos..manage_direct_peered_networks vars: manage_direct_peered_networks_operation: create @@ -56,7 +56,7 @@ always: - name: Delete Peer Network - ansible.builtin.import_role: - name: aws.infrastructure_config_demos.manage_direct_peered_networks + ansible.builtin.include_role: + name: lab.aws_infrastructure_config_demos..manage_direct_peered_networks vars: manage_direct_peered_networks_operation: delete diff --git a/molecule/peer_transit_networks/tasks/peer_transit_networks.yml b/molecule/peer_transit_networks/tasks/peer_transit_networks.yml index 2c5b1ed..2dfb866 100644 --- a/molecule/peer_transit_networks/tasks/peer_transit_networks.yml +++ b/molecule/peer_transit_networks/tasks/peer_transit_networks.yml @@ -8,8 +8,8 @@ - name: Test Transit Network Deployment block: - name: Create Transit Network - ansible.builtin.import_role: - name: aws.infrastructure_config_demos.manage_transit_peered_networks + ansible.builtin.include_role: + name: lab.aws_infrastructure_config_demos..manage_transit_peered_networks vars: manage_transit_peered_networks_operation: create @@ -72,7 +72,7 @@ always: - name: Delete Transit Network - ansible.builtin.import_role: - name: aws.infrastructure_config_demos.manage_transit_peered_networks + ansible.builtin.include_role: + name: lab.aws_infrastructure_config_demos..manage_transit_peered_networks vars: manage_transit_peered_networks_operation: delete diff --git a/molecule/transit_peered_networks/tasks/transit_peered_networks.yml b/molecule/transit_peered_networks/tasks/transit_peered_networks.yml index 5a88d7f..cd1f89c 100644 --- a/molecule/transit_peered_networks/tasks/transit_peered_networks.yml +++ b/molecule/transit_peered_networks/tasks/transit_peered_networks.yml @@ -4,8 +4,8 @@ - name: Test Transit Network Deployment block: - name: Create Transit Network - ansible.builtin.import_role: - name: aws.infrastructure_config_demos.peer_transit_networks + ansible.builtin.include_role: + name: lab.aws_infrastructure_config_demos..peer_transit_networks - name: Check VPCs amazon.aws.ec2_vpc_net_info: diff --git a/playbooks/create_peer_network.yml b/playbooks/create_peer_network.yml index 69c9801..958e38a 100644 --- a/playbooks/create_peer_network.yml +++ b/playbooks/create_peer_network.yml @@ -15,8 +15,8 @@ fail_msg: "Required variables not set" - name: Create Peer Networking Model - ansible.builtin.import_role: - name: manage_direct_peered_networks + ansible.builtin.include_role: + name: lab.aws_infrastructure_config_demos.manage_direct_peered_networks vars: manage_direct_peered_networks_operation: create diff --git a/playbooks/create_reports.yml b/playbooks/create_reports.yml index 0133e93..5df6fb5 100644 --- a/playbooks/create_reports.yml +++ b/playbooks/create_reports.yml @@ -8,4 +8,4 @@ tasks: - name: Include reports role ansible.builtin.include_role: - name: reports + name: lab.aws_infrastructure_config_demos.reports diff --git a/playbooks/create_transit_network.yml b/playbooks/create_transit_network.yml index 1cdfb48..f070457 100644 --- a/playbooks/create_transit_network.yml +++ b/playbooks/create_transit_network.yml @@ -15,8 +15,8 @@ fail_msg: "Required variables not set" - name: Create Transit Networking Model - ansible.builtin.import_role: - name: manage_transit_peered_networks + ansible.builtin.include_role: + name: lab.aws_infrastructure_config_demos.manage_transit_peered_networks vars: manage_transit_peered_networks_operation: create diff --git a/playbooks/create_vm.yml b/playbooks/create_vm.yml index 5f60a77..c79d1ce 100644 --- a/playbooks/create_vm.yml +++ b/playbooks/create_vm.yml @@ -17,4 +17,4 @@ - name: Include create vm role ansible.builtin.include_role: - name: create_vm + name: lab.aws_infrastructure_config_demos.create_vm diff --git a/playbooks/create_vpc.yml b/playbooks/create_vpc.yml new file mode 100644 index 0000000..8242e7e --- /dev/null +++ b/playbooks/create_vpc.yml @@ -0,0 +1,58 @@ +--- +- name: Create a VPC and subnets + hosts: localhost + connection: local + gather_facts: false + become: false + vars_files: + - vars/main.yml + - vars/create_vpc.yml + tasks: + - name: Create VPC + block: + - name: Create VPC + amazon.aws.ec2_vpc_net: + name: vpc-demo + cidr_block: "{{ vpc_cidr }}" + purge_tags: false + region: "{{ aws_region }}" + state: present + tags: + Name: vpc-demo + purpose: demo + environment: aap + register: vpc + tags: + - network + + - name: Save VPC id + ansible.builtin.set_fact: + vpc_id: "{{ vpc.vpc.id }}" + when: vpc is defined + tags: + - network + + - name: Create subnets + block: + - name: Create subnets + amazon.aws.ec2_vpc_subnet: + vpc_id: "{{ vpc_id }}" + cidr: "{{ item.cidr }}" + region: "{{ aws_region }}" + az: "{{ item.az }}" + state: present + tags: + Name: "vpc-demo-subnet-{{ item.name }}" + purpose: demo + environment: aap + loop: "{{ vpc_subnets }}" + register: subnets + tags: + - network + + - name: Save subnet ids + ansible.builtin.set_fact: + subnet_ids: "{{ subnets.results | map(attribute='subnet.id') | list }}" + when: subnets is defined + tags: + - network diff --git a/playbooks/delete_peer_network.yml b/playbooks/delete_peer_network.yml index fc7e5ea..1587940 100644 --- a/playbooks/delete_peer_network.yml +++ b/playbooks/delete_peer_network.yml @@ -13,7 +13,7 @@ fail_msg: "Required variables not set" - name: Delete Peer Networking Model - ansible.builtin.import_role: - name: manage_direct_peered_networks + ansible.builtin.include_role: + name: lab.aws_infrastructure_config_demos.manage_direct_peered_networks vars: manage_direct_peered_networks_operation: delete diff --git a/playbooks/delete_transit_network.yml b/playbooks/delete_transit_network.yml index 627de29..2b934b3 100644 --- a/playbooks/delete_transit_network.yml +++ b/playbooks/delete_transit_network.yml @@ -13,7 +13,7 @@ fail_msg: "Required variables not set" - name: Delete Transit Networking Model - ansible.builtin.import_role: - name: manage_transit_peered_networks + ansible.builtin.include_role: + name: lab.aws_infrastructure_config_demos.manage_transit_peered_networks vars: manage_transit_peered_networks_operation: delete diff --git a/playbooks/delete_vpc.yml b/playbooks/delete_vpc.yml new file mode 100644 index 0000000..1717dfd --- /dev/null +++ b/playbooks/delete_vpc.yml @@ -0,0 +1,49 @@ +--- +- name: Delete a VPC and subnets + hosts: localhost + connection: local + gather_facts: false + become: false + vars_files: + - vars/main.yml + tasks: + - name: Get VPC + amazon.aws.ec2_vpc_net_info: + region: "{{ aws_region }}" + filters: + "tag:purpose": demo + "tag:environment": aap + register: vpcs + + - name: Get subnets + amazon.aws.ec2_vpc_subnet_info: + region: "{{ aws_region }}" + filters: + "tag:purpose": demo + "tag:environment": aap + register: subnets + + - name: Delete subnets + when: + - vpcs is defined + - vpcs.vpcs | length > 0 + - subnets is defined + - subnets.subnets | length > 0 + amazon.aws.ec2_vpc_subnet: + region: "{{ aws_region }}" + cidr: "{{ item.cidr_block }}" + vpc_id: "{{ vpcs.vpcs[0].id }}" + state: absent + loop: "{{ subnets.subnets }}" + register: deleted_subnets + + - name: Delete VPC + when: + - vpcs is defined + - vpcs.vpcs | length > 0 + amazon.aws.ec2_vpc_net: + region: "{{ aws_region }}" + vpc_id: "{{ item.vpc_id }}" + state: absent + loop: "{{ vpcs.vpcs }}" + register: deleted_vpcs diff --git a/playbooks/peer_networks.yml b/playbooks/peer_networks.yml index 486dc01..85e071f 100644 --- a/playbooks/peer_networks.yml +++ b/playbooks/peer_networks.yml @@ -13,5 +13,5 @@ fail_msg: "Required variables not set" - name: Create Peer Networking Model - ansible.builtin.import_role: - name: peer_existing_networks + ansible.builtin.include_role: + name: lab.aws_infrastructure_config_demos.peer_existing_networks diff --git a/playbooks/peer_to_transit_network.yml b/playbooks/peer_to_transit_network.yml index 2258bbd..4f8446b 100644 --- a/playbooks/peer_to_transit_network.yml +++ b/playbooks/peer_to_transit_network.yml @@ -12,5 +12,5 @@ fail_msg: "Required variables not set" - name: Create Peer Networking Model - ansible.builtin.import_role: - name: peer_transit_network + ansible.builtin.include_role: + name: lab.aws_infrastructure_config_demos.peer_transit_network diff --git a/vars/create_vm.yml b/playbooks/vars/create_vm.yml similarity index 74% rename from vars/create_vm.yml rename to playbooks/vars/create_vm.yml index 2f1f1d7..bdcb0e9 100644 --- a/vars/create_vm.yml +++ b/playbooks/vars/create_vm.yml @@ -1,5 +1,5 @@ --- create_vm_aws_tenancy: default create_vm_aws_profile: default -create_vm_instance_type: t2.micro +create_vm_instance_type: t3.micro create_vm_instance_name: test_vm diff --git a/playbooks/vars/create_vpc.yml b/playbooks/vars/create_vpc.yml new file mode 100644 index 0000000..a406cf9 --- /dev/null +++ b/playbooks/vars/create_vpc.yml @@ -0,0 +1,15 @@ +--- +vpc_cidr: 172.16.0.0/22 +vpc_subnets: + - name: vnet1 + cidr: 172.16.0.0/24 + az: us-east-1a + - name: vnet2 + cidr: 172.16.1.0/24 + az: us-east-1b + - name: vnet3 + cidr: 172.16.2.0/24 + az: us-east-1c + - name: vnet4 + cidr: 172.16.3.0/24 + az: us-east-1d diff --git a/vars/main.yml b/playbooks/vars/main.yml similarity index 100% rename from vars/main.yml rename to playbooks/vars/main.yml diff --git a/vars/vm_blueprints/al2023.yml b/playbooks/vars/vm_blueprints/al2023.yml similarity index 100% rename from vars/vm_blueprints/al2023.yml rename to playbooks/vars/vm_blueprints/al2023.yml diff --git a/vars/vm_blueprints/rhel7.yml b/playbooks/vars/vm_blueprints/rhel7.yml similarity index 100% rename from vars/vm_blueprints/rhel7.yml rename to playbooks/vars/vm_blueprints/rhel7.yml diff --git a/vars/vm_blueprints/rhel8.yml b/playbooks/vars/vm_blueprints/rhel8.yml similarity index 100% rename from vars/vm_blueprints/rhel8.yml rename to playbooks/vars/vm_blueprints/rhel8.yml diff --git a/vars/vm_blueprints/rhel9.yml b/playbooks/vars/vm_blueprints/rhel9.yml similarity index 100% rename from vars/vm_blueprints/rhel9.yml rename to playbooks/vars/vm_blueprints/rhel9.yml diff --git a/vars/vm_blueprints/windows_core.yml b/playbooks/vars/vm_blueprints/windows_core.yml similarity index 100% rename from vars/vm_blueprints/windows_core.yml rename to playbooks/vars/vm_blueprints/windows_core.yml diff --git a/vars/vm_blueprints/windows_full.yml b/playbooks/vars/vm_blueprints/windows_full.yml similarity index 100% rename from vars/vm_blueprints/windows_full.yml rename to playbooks/vars/vm_blueprints/windows_full.yml diff --git a/roles/create_vm/tasks/main.yml b/roles/create_vm/tasks/main.yml index 9cb542a..a41dc29 100644 --- a/roles/create_vm/tasks/main.yml +++ b/roles/create_vm/tasks/main.yml @@ -9,7 +9,7 @@ "tag:owner": "{{ create_vm_vm_owner }}" "tag:purpose": "{{ create_vm_vm_purpose }}" "tag:ansible-role": create_vm - "tag:ansible-collection": aws.infrastructure_config_demos + "tag:ansible-collection": lab.aws_infrastructure_config_demos instance-state-name: - pending - running @@ -86,7 +86,7 @@ owner: "{{ create_vm_vm_owner }}" purpose: "{{ create_vm_vm_purpose }}" ansible-role: create_vm - ansible-collection: aws.infrastructure_config_demos + ansible-collection: lab.aws_infrastructure_config_demos wait: "{{ create_vm_aws_ec2_wait }}" vpc_subnet_id: "{{ create_vm_aws_subnet_id }}" user_data: "{{ lookup('template', create_vm_aws_userdata_template + '.j2', template_vars=dict(vm_name=create_vm_vm_name)) }}"