forked from alessfg/nginx-controller-automation-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx-controller.pkr.hcl
71 lines (64 loc) · 1.68 KB
/
nginx-controller.pkr.hcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
variable "ami_name" {
default = "NGINX Controller"
description = "Name of AMI to be created"
type = string
}
variable "nginx_controller_tarball_location" {
description = "Tarball location of NGINX Controller"
type = string
}
variable "instance_type" {
default = "t3.medium"
description = "The instance type for the AMI build"
type = string
}
variable "owner" {
default = ""
description = "Owner of resources being created (included as a tag)"
type = string
}
variable "region" {
default = "us-west-1"
description = "Your target AWS region"
type = string
}
variable "source_ami" {
default = "ami-0a741b782c2c8632d"
description = "Source AMI ID to base this build on"
type = string
}
source "amazon-ebs" "controller" {
# AMI configuration
ami_name = var.ami_name
ami_description = "${var.ami_name} AMI"
force_deregister = true
force_delete_snapshot = true
ssh_username = "ubuntu"
tags = {
Name = "${var.ami_name} AMI"
Owner = var.owner != "" ? var.owner : "Packer"
}
# Access configuration
region = var.region
# Run configuration
instance_type = var.instance_type
source_ami = var.source_ami
}
build {
description = "Install NGINX Controller prerequisites"
sources = [
"source.amazon-ebs.controller"
]
provisioner "file" {
source = "${path.root}/${var.nginx_controller_tarball_location}"
destination = "/home/ubuntu/"
max_retries = 2
pause_before = "10s"
}
provisioner "ansible" {
playbook_file = "${path.root}/nginx-controller.yml"
# Global parameters
max_retries = 2
pause_before = "10s"
}
}