Skip to content

Instantly share code, notes, and snippets.

@annaken
Created July 28, 2017 12:03
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 annaken/fc07089ad285bc007033c25eb7245230 to your computer and use it in GitHub Desktop.
Save annaken/fc07089ad285bc007033c25eb7245230 to your computer and use it in GitHub Desktop.
{
"_comment": ["2006-01-02 15:04:05 is a magic reference date for isotime",
"more info at https://www.packer.io/docs/templates/configuration-templates.html"],
"variables": {
"ami_type": "{{env `AMI_TYPE`}}",
"ami_prefix": "{{env `AMI_PREFIX`}}",
"source_ami": "{{env `SOURCE_AMI`}}",
"ssh_keypair_name": "{{env `SSH_KEYPAIR_NAME`}}",
"ssh_private_key_file": "{{env `SSH_PRIVATE_KEY_FILE`}}",
"git_hash": ""
},
"builders": [
{
"ami_name": "{{user `ami_prefix`}}-{{user `ami_type`}}-{{isotime \"2006-01-02-1504\"}}-{{user `git_hash`}}",
"iam_instance_profile": "ami-generate",
"instance_type": "m4.large",
"region": "{{user `region`}}",
"source_ami": "{{user `source_ami`}}",
"ssh_keypair_name": "{{user `ssh_keypair_name`}}",
"ssh_private_key_file": "{{user `ssh_private_key_file`}}",
"ssh_username": "ubuntu",
"subnet_id": "{{user `subnet_id`}}",
"type": "amazon-ebs",
"vpc_id": "{{user `vpc_id`}}",
"tags": {
"Name": "{{user `ami_type`}}-ami",
"OS": "ubuntu-1604",
"TestStatus": "Pass"
},
"run_tags": {
"Name": "{{user `ami_prefix`}}-{{user `ami_type`}}-packer-instance",
}
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"sudo apt-get update",
"sudo apt-get install -y python-minimal aptitude",
"sudo systemctl mask apt-daily.service"
]
},
{
"type": "ansible",
"playbook_file": "./{{user `ami_type`}}-ami.yml",
"user": "ubuntu",
"ansible_env_vars": ["ANSIBLE_ROLES_PATH=../roles/"]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment