· 7 years ago · Jan 03, 2019, 06:06 AM
1{
2 "variables": {
3 "aws_access_key": "",
4 "aws_secret_key": ""
5 },
6
7 "provisioners": [
8 {
9 "type": "shell",
10 "execute_command": "echo 'ubuntu' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'",
11 "inline": [
12 "sleep 30",
13 "apt-add-repository ppa:ansible/ansible -y",
14 "/usr/bin/apt-get update",
15 "/usr/bin/apt-get -y install ansible",
16 "mkdir /home/ubuntu/node-app",
17 "chown ubuntu:ubuntu /home/ubuntu/node-app"
18 ]
19 },
20 {
21 "type": "file",
22 "source": ".",
23 "destination": "/home/ubuntu/node-app/"
24 },
25 {
26 "type": "ansible-local",
27 "playbook_file": "packer/ansible-playbook.yml"
28 }
29 ],
30
31 "builders": [{
32 "type": "amazon-ebs",
33 "access_key": "{{user `aws_access_key`}}",
34 "secret_key": "{{user `aws_secret_key`}}",
35 "region": "ap-south-1",
36 "source_ami_filter": {
37 "filters": {
38 "virtualization-type": "hvm",
39 "name": "ubuntu/images/*ubuntu-trusty-14.04-amd64-server-*",
40 "root-device-type": "ebs"
41 },
42 "owners": ["099720109477"],
43 "most_recent": true
44 },
45 "instance_type": "t2.micro",
46 "ssh_username": "ubuntu",
47 "ami_name": "packer-example {{timestamp}}",
48 "launch_block_device_mappings": [{
49 "device_name": "/dev/sda1",
50 "volume_size": 8,
51 "volume_type": "gp2",
52 "delete_on_termination": true
53 }]
54 }]
55}