From 428d17939854fe1e6cada8c3c3edf557a041dc22 Mon Sep 17 00:00:00 2001 From: Dave Arnold Date: Tue, 28 May 2024 13:28:31 -0400 Subject: [PATCH] updating stuff --- .terraform.lock.hcl | 50 +++++++++++++++++++++--------------------- examples/build.pkr.hcl | 37 +++++++++++++++++++++++++++++++ examples/playbook.yaml | 7 ++++++ main.tf | 49 ++++++++++++++++++++++------------------- 4 files changed, 96 insertions(+), 47 deletions(-) create mode 100644 examples/build.pkr.hcl create mode 100644 examples/playbook.yaml diff --git a/.terraform.lock.hcl b/.terraform.lock.hcl index d3d5dc5..ae2e6e9 100644 --- a/.terraform.lock.hcl +++ b/.terraform.lock.hcl @@ -1,25 +1,25 @@ -# This file is maintained automatically by "terraform init". -# Manual edits may be lost in future updates. - -provider "registry.terraform.io/hashicorp/aws" { - version = "5.49.0" - constraints = ">= 4.20.1" - hashes = [ - "h1:Y3xvYjzBIwYSbcnZDcs6moiy30uxRoY5oT2ExQHKG5A=", - "zh:0979b07cdeffb868ea605e4bbc008adc7cccb5f3ba1d3a0b794ea3e8fff20932", - "zh:2121a0a048a1d9419df69f3561e524b7e8a6b74ba0f57bd8948799f12b6ad3a1", - "zh:573362042ba0bd18e98567a4f45d91b09eb0d223513518ba04f16a646a906403", - "zh:57be7a4d6c362be2fa586d270203f4eac1ee239816239a9503b86ebc8fa1fef0", - "zh:5c72ed211d9234edd70eac9d77c3cafc7bbf819d1c28332a6d77acf227c9a23c", - "zh:7786d1a9781f8e8c0079bf58f4ed4aeddec0caf54ad7ddcf43c47936d545a04f", - "zh:82133e7d39787ee91ed41988da71beecc2ecb900b5da94b3f3d77fbc4d4dc722", - "zh:8cdb1c154dead85be8352afd30eaf41c59249de9e7e0a8eb4ab8e625b90a4922", - "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", - "zh:ac215fd1c3bd647ae38868940651b97a53197688daefcd70b3595c84560e5267", - "zh:c45db22356d20e431639061a72e07da5201f4937c1df6b9f03f32019facf3905", - "zh:c9ba90e62db9a4708ed1a4e094849f88ce9d44c52b49f613b30bb3f7523b8d97", - "zh:d2be3607be2209995c80dc1d66086d527de5d470f73509e813254067e8287106", - "zh:e3fa20090f3cebf3911fc7ef122bd8c0505e3330ab7d541fa945fea861205007", - "zh:ef1b9d5c0b6279323f2ecfc322db8083e141984cfe1bb2f33c0f4934fccb69e3", - ] -} +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "5.50.0" + constraints = ">= 4.20.1" + hashes = [ + "h1:OE1Q924lUL15OytvxwkdIspPsLRe0m2044W55j3lihE=", + "zh:19be42f5a545d6712dee4bdb704b018d23bacf5d902ac3cb061eb1750dfe6a20", + "zh:1d880bdba95ce96efde37e5bcf457a57df2c1effa9b47bc67fa29c1a264ae53b", + "zh:1e9c78e324d7492be5e7744436ed71d66fe4eca3fb6af07a28efd0d1e3bf7640", + "zh:27ac672aa61b3795931561fdbe4a306ad1132af517d7711c14569429b2cc694f", + "zh:3b978423dead02f9a98d25de118adf264a2331acdc4550ea93bed01feabc12e7", + "zh:490d7eb4b922ba1b57e0ab8dec1a08df6517485febcab1e091fd6011281c3472", + "zh:64e7c84e18dac1af5778d6f516e01a46f9c91d710867c39fbc7efa3cd972dc62", + "zh:73867ac2956dcdd377121b3aa8fe2e1085e77fae9b61d018f56a863277ea4b6e", + "zh:7ed899d0d5c49f009b445d7816e4bf702d9c48205c24cf884cd2ae0247160455", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:9b93784b3fb13d08cf95a4131c49b56bf7e1cd35daad6156b3658a89ce6fb58f", + "zh:b29d77eb75de474e46eb47e539c48916628d85599bcf14e5cc500b14a4578e75", + "zh:bbd9cec8ca705452e4a3d21d56474eacb8cc7b1b74b7f310fdea4bdcffebab32", + "zh:c352eb3169efa0e27a29b99a2630e8298710a084453c519caa39e5972ff6d1fc", + "zh:e32f4744b43be1708b309a734e0ac10b5c0f9f92e5849298cf1a90f2b906f6f3", + ] +} diff --git a/examples/build.pkr.hcl b/examples/build.pkr.hcl new file mode 100644 index 0000000..1ec8151 --- /dev/null +++ b/examples/build.pkr.hcl @@ -0,0 +1,37 @@ +packer { + required_plugins { + amazon = { + version = ">= 1.2.8" + source = "github.com/hashicorp/amazon" + } + ansible = { + version = "v1.1.1" + source ="github.com/hashicorp/ansible" + } + } +} + +variable subnet_id {} +variable security_group_id {} + +source "amazon-ebs" "ubuntu" { + ami_name = "learn-packer-linux-aws" + instance_type = "t2.micro" + source_ami = "ami-07e218d88f8f9c4db" + ssh_username = "ec2-user" + subnet_id = var.subnet_id + security_group_ids = [ + var.security_group_id + ] +} + +build { + name = "learn-packer" + sources = [ + "source.amazon-ebs.ubuntu" + ] + provisioner "ansible" { + playbook_file = "./playbook.yml" + roles_path = "./ansible/roles" + } +} diff --git a/examples/playbook.yaml b/examples/playbook.yaml new file mode 100644 index 0000000..d6febaf --- /dev/null +++ b/examples/playbook.yaml @@ -0,0 +1,7 @@ +--- +# playbook.yml +- name: 'Provision Image' + hosts: default + become: true + roles: + - hello_world diff --git a/main.tf b/main.tf index 4032153..78a1aa0 100644 --- a/main.tf +++ b/main.tf @@ -1,22 +1,22 @@ -module "network" { - source = "HappyPathway/network/aws" - network_name = "csvd-infra-automation" - region = "us-gov-west-1" - key_name = "csvd-dev-ew-public-network" - private_subnet_cidrs = [ - "10.0.5.0/24", - "10.0.6.0/24" - ] - public_subnet_cidrs = [ - "10.0.7.0/24", - "10.0.8.0/24" - ] - availability_zones = [ - "us-gov-west-1a", - "us-gov-west-1b", - "us-gov-west-1c" - ] -} +#module "network" { +# source = "HappyPathway/network/aws" +# network_name = "csvd-infra-automation" +# region = "us-gov-west-1" +# key_name = "csvd-dev-ew-public-network" +# private_subnet_cidrs = [ +# "10.0.5.0/24", +# "10.0.6.0/24" +# ] +# public_subnet_cidrs = [ +# "10.0.7.0/24", +# "10.0.8.0/24" +# ] +# availability_zones = [ +# "us-gov-west-1a", +# "us-gov-west-1b", +# "us-gov-west-1c" +# ] +#} #locals { # proxy_env_vars = { @@ -36,7 +36,7 @@ data "aws_iam_policy_document" "s3_access" { locals { - vpc_id = module.network.vpc_id + vpc_id = "vpc-00576a396ec570b94" } resource "aws_codecommit_repository" "ansible" { @@ -67,8 +67,13 @@ module "main" { ansible_repo = aws_codecommit_repository.ansible vpc_config = { vpc_id = local.vpc_id - security_group_ids = module.network.admin_sgs - subnets = module.network.private_subnets + security_group_ids = [ + "sg-0d828d223df9834a6", + "sg-098633a3b32ea82f4" + ] + subnets = [ + "subnet-062189d742937204e" + ] } }