Skip to content

Instantly share code, notes, and snippets.

@brianknight10
Created December 1, 2016 21:28
Show Gist options
  • Save brianknight10/8d7f0cb354b439b0f7633c7c7ebf9e7d to your computer and use it in GitHub Desktop.
Save brianknight10/8d7f0cb354b439b0f7633c7c7ebf9e7d to your computer and use it in GitHub Desktop.
Packer template
{
"variables": {
"aws_access_key": "{{env `AWS_ACCESS_KEY`}}",
"aws_secret_key": "{{env `AWS_SECRET_KEY`}}",
"source_ami": "{{env `AWS_SOURCE_AMI`}}"
},
"builders": [
{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "us-east-1",
"source_ami": "{{user `source_ami`}}",
"instance_type": "t2.medium",
"ssh_username": "ubuntu",
"ami_name": "consul-{{timestamp}}",
"communicator": "ssh",
"ssh_pty": true,
"ami_description": "Consul server image",
"ami_virtualization_type": "hvm",
"tags": {
"os": "ubuntu16",
"storage": "ebs",
"image": "consul"
}
}
],
"push": {
"name": "saj/consul",
"base_dir": "../../",
"vcs": false,
"exclude": [
"packer_cache",
"output-virtualbox-iso",
".git"
]
},
"provisioners": [
{
"type": "shell",
"scripts": [
"build/scripts/apt_upgrade.sh",
"build/scripts/install_ansible.sh"
]
},
{
"type": "ansible-local",
"playbook_file": "ansible/playbooks/consul.yml",
"inventory_groups": "consul",
"playbook_dir": "ansible/playbooks/"
}
],
"post-processors": [
{
"type": "atlas",
"artifact": "saj/consul",
"artifact_type": "aws.ami",
"metadata": {
"created_at": "{{timestamp}}"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment