· 7 years ago · Jan 26, 2019, 02:42 AM
1⟩ cat packer/sl-email/main.json
2{
3 "variables": {
4 "aws_access_key": "",
5 "aws_secret_key": ""
6 },
7 "builders": [
8 {
9 "type": "amazon-ebs",
10 "access_key": "{{user `aws_access_key`}}",
11 "secret_key": "{{user `aws_secret_key`}}",
12 "region": "us-east-1",
13 "source_ami_filter": {
14 "filters": {
15 "virtualization-type": "hvm",
16 "name": "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*",
17 "root-device-type": "ebs"
18 },
19 "owners": [
20 "099720109477"
21 ],
22 "most_recent": true
23 },
24 "instance_type": "t2.xlarge",
25 "ssh_username": "ubuntu",
26 "ami_name": "sl-email-{{timestamp}}",
27 "iam_instance_profile": "adh-deploy",
28 "subnet_id": "subnet-96999fbe"
29 }
30 ],
31 "provisioners": [
32 {
33 "type": "shell",
34 "inline": [
35 "while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done"
36 ]
37 },
38 {
39 "type": "shell",
40 "inline": [
41 "sudo apt -qqy update && sudo apt install -qy python python-pip"
42 ]
43 },
44 {
45 "type": "ansible",
46 "groups": [
47 "template"
48 ],
49 "inventory_directory": "./inventory",
50 "playbook_file": "playbooks/sl-email/main.yml"
51 }
52 ]
53}