Skip to content

Instantly share code, notes, and snippets.

@ru-rocker
Last active September 26, 2021 07:53
Show Gist options
  • Save ru-rocker/9a0eda3c469029d6f92c005ccf714201 to your computer and use it in GitHub Desktop.
Save ru-rocker/9a0eda3c469029d6f92c005ccf714201 to your computer and use it in GitHub Desktop.
packer {
required_plugins {
amazon = {
version = ">= 0.0.2"
source = "github.com/hashicorp/amazon"
}
}
}
source "amazon-ebs" "centos7" {
ami_name = "packer-centos7-aws"
instance_type = "t2.micro"
region = "ap-southeast-1"
associate_public_ip_address = true
source_ami_filter {
filters = {
name = "your-company-base-centos7-image*"
architecture = "x86_64"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["XXXXXXXX"]
}
ssh_username = "centos"
}
build {
name = "packer-centos7-aws"
sources = [
"source.amazon-ebs.centos7"
]
provisioner "shell" {
environment_vars = [
"https_proxy=http://yourproxyserver:port",
]
inline = [
"echo update yum",
"sudo yum update -y",
"echo Installing JDK",
"sudo yum install -y java-11-openjdk-devel",
]
}
}
inline = [
"sudo echo proxy='http://yourproxyserver:port' >> /etc/yum.conf",
# and the rest
]
inline = [
"sudo bash -c \"echo proxy='http://yourproxyserver:port' >> /etc/yum.conf\"",
# and the rest
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment