Skip to content

Instantly share code, notes, and snippets.

@rjhornsby rjhornsby/2nd_generation.json Secret
Last active Feb 24, 2020

Embed
What would you like to do?
packer-generations-centos7
{
"variables": {
"version": "1.2",
"aws_access_key": "",
"aws_secret_key": "",
"aws_region": "",
"kms_key_id": "",
"packer_vpc_id": "vpc-1b2b9e7e",
"packer_subnet_id": "subnet-adf478c8",
"manifest": "centos7-manifest.json",
"min_packer_version": "1.5.0",
"build_version": "{{user `version`}}.{{isotime \"20060102T150405\"}}"
},
"builders": [
{
"type": "amazon-ebssurrogate",
"ami_virtualization_type": "hvm",
"shutdown_behavior": "terminate",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"vpc_id": "{{user `packer_vpc_id`}}",
"subnet_id": "{{user `packer_subnet_id`}}",
"ssh_pty": "true",
"instance_type": "t2.micro",
"region": "{{user `aws_region`}}",
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "CentOS Linux 7 x86_64*",
"root-device-type": "ebs"
},
"owners": ["679593333241"],
"most_recent": true
},
"ssh_username": "ec2-user",
"ami_name": "corp-centos-7_{{user `build_version`}}",
"ena_support": true,
"encrypt_boot": true,
"kms_key_id": "{{user `kms_key_id`}}",
"user_data_file": "cloud_config/default_user.cfg",
"launch_block_device_mappings": [
{
"device_name": "/dev/xvdf",
"delete_on_termination": true,
"volume_size": 16,
"volume_type": "gp2"
}
],
"ami_root_device": {
"source_device_name": "/dev/xvdf",
"device_name": "/dev/xvda",
"delete_on_termination": true,
"volume_size": 16,
"volume_type": "gp2"
},
"tags": {
"created-by": "packer",
"packer-build": "{{user `build_version`}}",
"os-image": "CentOS 7"
},
"run_volume_tags": {
"created-by": "packer",
"os-image": "CentOS 7"
},
"run_tags": {
"created-by": "packer",
"os-image": "CentOS 7"
},
"snapshot_tags": {
"created-by": "packer",
"os-image": "CentOS 7"
}
}
],
"provisioners": [
{
"type": "file",
"source": "cloud_config/default_user.cfg",
"destination": "/tmp/default_user.cfg"
},
{
"type": "shell",
"inline": [
"sudo mv -f /tmp/default_user.cfg /etc/cloud/cloud.cfg.d/default_user.cfg",
"sudo yum -y install lvm2",
"sudo yum -y upgrade"
]
},
{
"type": "shell",
"script": "scripts/provisioner/disable_services.sh",
"execute_command": "{{ .Vars }} sudo -E -S sh '{{ .Path }}'"
},
{
"type": "shell",
"script": "scripts/provisioner/lvm_migrate.sh",
"execute_command": "echo 'packer' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'"
}
],
"post-processors": [
{
"type": "manifest",
"output": "{{user `manifest`}}",
"strip_path": true
}
]
}
{
"variables": {
"version": "1.0",
"aws_access_key": "",
"aws_secret_key": "",
"aws_region": "",
"kms_key_id": "",
"packer_vpc_id": "vpc-1b2b9e7e",
"packer_subnet_id": "subnet-adf478c8",
"chef_server": "https://chef.corp.org:443/organizations/corp",
"validation_name": "corp-validator",
"validation_key": "{{env `HOME`}}/.chef/{{user `validation_name`}}.pem",
"manifest": "vault-server-manifest.json",
"min_packer_version": "1.5.0",
"ami_build_version": "{{user `version`}}.{{isotime \"20060102T150405\"}}"
},
"builders": [
{
"type": "amazon-ebs",
"ami_virtualization_type": "hvm",
"shutdown_behavior": "terminate",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"vpc_id": "{{user `packer_vpc_id`}}",
"subnet_id": "{{user `packer_subnet_id`}}",
"ssh_pty": "true",
"instance_type": "t2.micro",
"region": "{{user `aws_region`}}",
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "corp-centos-7_*",
"root-device-type": "ebs"
},
"owners": ["455207486748"],
"most_recent": true
},
"ssh_username": "ec2-user",
"ami_name": "corp-vault-server_{{user `ami_build_version`}}",
"ena_support": true,
"encrypt_boot": true,
"ebs_optimized": true,
"kms_key_id": "{{user `kms_key_id`}}",
"user_data_file": "cloud_config/default_user.cfg",
"tags": {
"created-by": "packer",
"packer_build": "{{user `ami_build_version`}}",
"source_ami": "{{ .SourceAMIName }}"
},
"run_volume_tags": {
"created-by": "packer"
},
"run_tags": {
"created-by": "packer"
},
"snapshot_tags": {
"created-by": "packer",
"corp_description": "CentOS 7 vault server"
}
}
],
"provisioners": [
{
"type": "file",
"source": "cloud_config/cloud.cfg",
"destination": "/tmp/cloud.cfg"
},
{
"type": "shell",
"inline": [
"sudo mv -f /tmp/cloud.cfg /etc/cloud/cloud.cfg"
]
},
{
"type": "chef-client",
"server_url": "{{user `chef_server`}}",
"chef_license": "accept-silent",
"version": "14.7.17",
"validation_client_name": "{{user `validation_name`}}",
"validation_key_path": "{{user `validation_key`}}",
"run_list": [],
"json": {
"corp_spacewalk_client": {
"register": false
}
}
},
{
"type": "shell",
"inline": [
"sudo /bin/cloud-init clean",
"echo cloud-init reset complete"
]
}
],
"post-processors": [
{
"type": "manifest",
"output": "{{user `manifest`}}",
"strip_path": true
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.