aboutsummaryrefslogtreecommitdiff
path: root/packer
diff options
context:
space:
mode:
authorclarkzjw <[email protected]>2023-02-13 17:48:19 -0800
committerclarkzjw <[email protected]>2023-02-13 17:48:19 -0800
commitb3895c6af1f1d57d5fb2fd895f9950b55246a157 (patch)
tree0478d2d2dffd921985b7cc3da276adbedd373e51 /packer
parentdc756af1b57186122874d703821191baefa1aacd (diff)
downloadzjw.social-b3895c6af1f1d57d5fb2fd895f9950b55246a157.tar.gz
packer: add packer ubuntu templatepacker
Diffstat (limited to 'packer')
-rw-r--r--packer/application.pkr.hcl72
-rw-r--r--packer/ubuntu.pkr.hcl72
2 files changed, 144 insertions, 0 deletions
diff --git a/packer/application.pkr.hcl b/packer/application.pkr.hcl
new file mode 100644
index 0000000..4bc7aa8
--- /dev/null
+++ b/packer/application.pkr.hcl
@@ -0,0 +1,72 @@
1packer {
2 required_plugins {
3 amazon = {
4 version = ">= 1.0.1"
5 source = "github.com/hashicorp/amazon"
6 }
7 }
8}
9
10data "hcp-packer-iteration" "ubuntu" {
11 bucket_name = "learn-packer-ubuntu"
12 channel = "production"
13}
14
15data "hcp-packer-image" "ubuntu-east" {
16 bucket_name = "learn-packer-ubuntu"
17 iteration_id = data.hcp-packer-iteration.ubuntu.id
18 cloud_provider = "aws"
19 region = "us-east-2"
20}
21
22data "hcp-packer-image" "ubuntu-west" {
23 bucket_name = "learn-packer-ubuntu"
24 iteration_id = data.hcp-packer-iteration.ubuntu.id
25 cloud_provider = "aws"
26 region = "us-west-1"
27}
28
29source "amazon-ebs" "application-east" {
30 ami_name = "packer_AWS_{{timestamp}}"
31
32 region = "us-east-2"
33 source_ami = data.hcp-packer-image.ubuntu-east.id
34 instance_type = "t2.small"
35 ssh_username = "ubuntu"
36 ssh_agent_auth = false
37
38 tags = {
39 Name = "learn-packer-application"
40 }
41}
42
43source "amazon-ebs" "application-west" {
44 ami_name = "packer_AWS_{{timestamp}}"
45
46 region = "us-west-1"
47 source_ami = data.hcp-packer-image.ubuntu-west.id
48 instance_type = "t2.small"
49 ssh_username = "ubuntu"
50 ssh_agent_auth = false
51
52 tags = {
53 Name = "learn-packer-application"
54 }
55}
56
57build {
58 hcp_packer_registry {
59 bucket_name = "learn-packer-application"
60 description = <<EOT
61Some nice description about the image being published to HCP Packer Registry.
62 EOT
63 bucket_labels = {
64 "foo-version" = "3.4.0",
65 "foo" = "bar",
66 }
67 }
68 sources = [
69 "source.amazon-ebs.application-east",
70 "source.amazon-ebs.application-west"
71 ]
72}
diff --git a/packer/ubuntu.pkr.hcl b/packer/ubuntu.pkr.hcl
new file mode 100644
index 0000000..e7d4f37
--- /dev/null
+++ b/packer/ubuntu.pkr.hcl
@@ -0,0 +1,72 @@
1packer {
2 required_plugins {
3 amazon = {
4 version = ">= 1.0.1"
5 source = "github.com/hashicorp/amazon"
6 }
7 }
8}
9
10variable "version" {
11 type = string
12 default = "1.0.0"
13}
14
15data "amazon-ami" "ubuntu-focal-east" {
16 region = "us-east-2"
17 filters = {
18 name = "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"
19 }
20 most_recent = true
21 owners = ["099720109477"]
22}
23
24source "amazon-ebs" "basic-example-east" {
25 region = "us-east-2"
26 source_ami = data.amazon-ami.ubuntu-focal-east.id
27 instance_type = "t2.small"
28 ssh_username = "ubuntu"
29 ssh_agent_auth = false
30 ami_name = "packer_AWS_{{timestamp}}_v${var.version}"
31}
32
33data "amazon-ami" "ubuntu-focal-west" {
34 region = "us-west-1"
35 filters = {
36 name = "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"
37 }
38 most_recent = true
39 owners = ["099720109477"]
40}
41
42source "amazon-ebs" "basic-example-west" {
43 region = "us-west-1"
44 source_ami = data.amazon-ami.ubuntu-focal-west.id
45 instance_type = "t2.small"
46 ssh_username = "ubuntu"
47 ssh_agent_auth = false
48 ami_name = "packer_AWS_{{timestamp}}_v${var.version}"
49}
50
51build {
52 hcp_packer_registry {
53 bucket_name = "learn-packer-ubuntu"
54 description = <<EOT
55Some nice description about the image being published to HCP Packer Registry.
56 EOT
57 bucket_labels = {
58 "owner" = "platform-team"
59 "os" = "Ubuntu",
60 "ubuntu-version" = "Focal 20.04",
61 }
62
63 build_labels = {
64 "build-time" = timestamp()
65 "build-source" = basename(path.cwd)
66 }
67 }
68 sources = [
69 "source.amazon-ebs.basic-example-east",
70 "source.amazon-ebs.basic-example-west"
71 ]
72}
Powered by cgit v1.2.3 (git 2.41.0)