-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpacker-aws-grinder.json
93 lines (91 loc) · 5.26 KB
/
packer-aws-grinder.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
This is my source version of the packer-aws-grinder build. It contains comments which are stripped out of the file
before it's fed to the Packer.io build process. There should also be an aws-grinder.json file in this directory.
That file should be the same as this one, sans comments. Any changes to the build configuration should be made to
this file and not the aws-grinder.json one.
Author: Kevin S. Clarke <[email protected]>
URL: http://github.com/ksclarke/packer-aws-grinder
*/
{
/* These variables should be defined in the vars.json file */
"variables": {
"grinder_version": "3.11",
/* Below are variables supplied by your vars.json file */
"aws_access_key": "{{env `AWS_ACCESS_KEY`}}",
"aws_secret_key": "{{env `AWS_SECRET_KEY`}}",
"aws_security_group_id": "{{env `AWS_SECURITY_GROUP_ID`}}",
"aws_keypair_name": "{{env `AWS_KEYPAIR_NAME`}}",
"aws_region": "{{env `AWS_REGION`}}",
"aws_instance_type": "{{env `AWS_INSTANCE_TYPE`}}",
"aws_source_ami": "{{env `AWS_SOURCE_AMI`}}",
"aws_virtualization_type": "{{env `AWS_VIRTUALIZATION_TYPE`}}",
"aws_public_ip": "{{env `AWS_PUBLIC_IP`}}",
"packer_build_name": "{{env `PACKER_AWS_GRINDER_BUILD_NAME`}}",
"grinder_type": "{{env `GRINDER_TYPE`}}",
"grinder_console_instance": "{{env `GRINDER_CONSOLE_INSTANCE` }}"
},
"builders": [{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
/* Below should be the actual ID, not the group name */
"security_group_id": "{{user `aws_security_group_id`}}",
"region": "{{user `aws_region`}}",
"associate_public_ip_address": "{{user `aws_public_ip`}}",
/* Make sure the next three values are compatible */
"source_ami": "{{user `aws_source_ami`}}",
"instance_type": "{{user `aws_instance_type`}}",
"ami_virtualization_type": "{{user `aws_virtualization_type`}}",
/* We always use Ubuntu disk images, so the below is constant */
"ssh_username": "ubuntu",
"ami_name": "{{user `packer_build_name`}} AWS Grinder ({{user `grinder_type`}}) [{{timestamp}}]",
"ami_description": "An AWS Grinder {{user `grinder_version`}} deployment built with Packer.io",
"tags": {
"OS_Version": "Ubuntu",
"Release": "Packer AWS Grinder {{user `grinder_version`}}"
}
}],
"provisioners": [{
"type": "shell",
"inline": [
"sleep 30",
/* Update all the Ubuntu packages before we begin */
"sudo apt-get update -y --fix-missing",
/* Upgrade any security issues since AMI release */
"sudo unattended-upgrade",
/* Install some generic systems stuff */
"sudo apt-get install -y nano htop nmap wget lynx-cur unzip jq",
/* Remove landscape-client but keep landscape-common */
"sudo apt-get remove -y --purge landscape-client",
"sudo rm -f /etc/update-motd.d/51-cloudguest",
/* We're going to hack the landscape login message */
"sudo truncate -s 0 `sudo find /usr/lib -name landscapelink.py`",
"wget -O - -q https://raw.githubusercontent.com/ksclarke/packer-aws-grinder/master/scripts/landscape-hack.sh | GRINDER_TYPE={{user `grinder_type`}} bash > /tmp/landscapelink.py",
"sudo mv /tmp/landscapelink.py `sudo find /usr/lib -name landscapelink.py`",
/* Install dependencies needed to install and use Grinder in AWS */
"sudo apt-get install -y openjdk-7-jdk jython python-pip",
"sudo pip install awscli",
/* Download Grinder */
"wget -O - -q http://sourceforge.net/projects/grinder/files/The%20Grinder%203/{{user `grinder_version`}}/grinder-{{user `grinder_version`}}-binary.zip/download > /tmp/grinder-{{user `grinder_version`}}.zip",
"sudo unzip -d /opt /tmp/grinder-{{user `grinder_version`}}.zip",
"sudo ln -s /opt/grinder-{{user `grinder_version`}} /opt/grinder",
"sudo chgrp -R users /opt/grinder*",
"sudo find /opt/grinder -type f -print -exec chmod 644 {} \\;",
"sudo find /opt/grinder -type d -print -exec chmod 755 {} \\;",
/* Change some system defaults to be more Grinder friendly; like, extend ephemera port range */
"echo '32768 65535' | sudo tee /proc/sys/net/ipv4/ip_local_port_range >/dev/null",
/* And enable port recycling */
"echo '1' | sudo tee /proc/sys/net/ipv4/tcp_tw_recycle >/dev/null",
/* And reduce the port timeout */
"echo '10' | sudo tee /proc/sys/net/ipv4/tcp_fin_timeout >/dev/null",
/* Install the Grinder console or agent (depending on which AMI this is) then make sure it works */
"wget -O - -q https://raw.githubusercontent.com/ksclarke/packer-aws-grinder/master/scripts/install-grinder.sh | GRINDER_TYPE={{user `grinder_type`}} GRINDER_CONSOLE_INSTANCE={{user `grinder_console_instance`}} AWS_ACCESS_KEY={{user `aws_access_key`}} AWS_SECRET_KEY={{user `aws_secret_key`}} AWS_REGION={{user `aws_region`}} AWS_SECURITY_GROUP_ID={{user `aws_security_group_id`}} bash",
/* Install the Grinder init.d script and set it to start on reboots */
"wget -O /tmp/grinder -q https://raw.githubusercontent.com/ksclarke/packer-aws-grinder/master/scripts/grinder-initd.sh",
"sudo mv /tmp/grinder /etc/init.d/grinder",
"sudo chown root:root /etc/init.d/grinder",
"sudo chmod 755 /etc/init.d/grinder",
"sudo update-rc.d grinder defaults"
]
}]
}