Skip to content

Instantly share code, notes, and snippets.

@bensojona
Last active November 13, 2015 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bensojona/aeb5976ae4e756e35518 to your computer and use it in GitHub Desktop.
Save bensojona/aeb5976ae4e756e35518 to your computer and use it in GitHub Desktop.
{
"variables": {
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
"atlas_username": "{{env `ATLAS_USERNAME`}}",
"us_east_1_ami": "ami-9a562df2",
"us_west_2_ami": "ami-8ee605bd",
"name": "aws-ubuntu-base",
"us_east_1_name": "aws-us-east-1-ubuntu-base",
"us_west_2_name": "aws-us-west-2-ubuntu-base",
"ssh_username": "ubuntu",
"scripts_dir": "packer/scripts/ubuntu",
"config_dir": "packer/config",
"dns_listen_addr": "127.0.0.1"
},
"push": {
"name": "{{user `atlas_username`}}/{{user `name`}}",
"base_dir": "../../../.",
"include": [
"{{user `scripts_dir`}}/*",
"{{user `scripts_dir`}}/upstart/*",
"{{user `config_dir`}}/*",
"{{user `config_dir`}}/consul/*",
"{{user `config_dir`}}/consul_template/*",
"{{user `config_dir`}}/consul_template/templates/*",
"{{user `config_dir`}}/vault/*",
"{{user `config_dir`}}/vault/policies/*"
],
"vcs": false
},
"builders": [
{
"name": "aws-us-east-1-ubuntu-base",
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "us-east-1",
"vpc_id": "",
"subnet_id": "",
"source_ami": "{{user `us_east_1_ami`}}",
"instance_type": "t2.micro",
"ssh_username": "{{user `ssh_username`}}",
"ssh_timeout": "10m",
"ami_name": "{{user `us_east_1_name`}} {{timestamp}}",
"ami_description": "{{user `us_east_1_name`}} AMI",
"run_tags": { "ami-create": "{{user `us_east_1_name`}}" },
"tags": { "ami": "{{user `us_east_1_name`}}" },
"ssh_private_ip": false,
"associate_public_ip_address": true
},
{
"name": "aws-us-west-2-ubuntu-base",
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "us-west-2",
"vpc_id": "",
"subnet_id": "",
"source_ami": "{{user `us_west_2_ami`}}",
"instance_type": "t2.micro",
"ssh_username": "{{user `ssh_username`}}",
"ssh_timeout": "10m",
"ami_name": "{{user `us_west_2_name`}} {{timestamp}}",
"ami_description": "{{user `us_west_2_name`}} AMI",
"run_tags": { "ami-create": "{{user `us_west_2_name`}}" },
"tags": { "ami": "{{user `us_west_2_name`}}" },
"ssh_private_ip": false,
"associate_public_ip_address": true
}
],
"provisioners": [
{
"type": "shell",
"execute_command": "echo {{user `ssh_username`}} | {{ .Vars }} sudo -E -S sh '{{ .Path }}'",
"inline": [
"mkdir -p /ops/{{user `scripts_dir`}}",
"chmod a+w /ops/{{user `scripts_dir`}}",
"mkdir -p /ops/{{user `config_dir`}}",
"chmod a+w /ops/{{user `config_dir`}}"
]
},
{
"type": "file",
"source": "{{user `scripts_dir`}}/.",
"destination": "/ops/{{user `scripts_dir`}}"
},
{
"type": "file",
"source": "{{user `config_dir`}}/.",
"destination": "/ops/{{user `config_dir`}}"
},
{
"type": "shell",
"execute_command": "echo {{user `ssh_username`}} | {{ .Vars }} sudo -E -S sh '{{ .Path }}'",
"inline": [
"sh /ops/{{user `scripts_dir`}}/dependencies.sh",
"sh /ops/{{user `scripts_dir`}}/consul.sh {{user `config_dir`}} {{user `scripts_dir`}}",
"sh /ops/{{user `scripts_dir`}}/consul_template.sh {{user `config_dir`}} {{user `scripts_dir`}}",
"sh /ops/{{user `scripts_dir`}}/dnsmasq.sh {{user `dns_listen_addr`}}",
"sh /ops/{{user `scripts_dir`}}/cleanup.sh"
]
}
],
"post-processors": [
{
"type": "atlas",
"only": ["aws-us-east-1-ubuntu-base"],
"artifact": "{{user `atlas_username`}}/{{user `us_east_1_name`}}",
"artifact_type": "amazon.image",
"metadata": {
"created_at": "{{timestamp}}"
}
},
{
"type": "atlas",
"only": ["aws-us-west-2-ubuntu-base"],
"artifact": "{{user `atlas_username`}}/{{user `us_west_2_name`}}",
"artifact_type": "amazon.image",
"metadata": {
"created_at": "{{timestamp}}"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment