Skip to content

Instantly share code, notes, and snippets.

@simonw7034
Created November 18, 2020 13:58
Show Gist options
  • Save simonw7034/a27d68b2eddf4cd6c030f19d62870793 to your computer and use it in GitHub Desktop.
Save simonw7034/a27d68b2eddf4cd6c030f19d62870793 to your computer and use it in GitHub Desktop.
bf_packer.json Packer build file
{
"variables": {
"bf_sde_version": "9.1.1",
"bf_sde_package": "bf-sde-{{user `bf_sde_version`}}.tar",
"build_jobs": "6",
"aws_src_ami": "ami-0e169fa5b2b2f88ae",
"aws_iam_inst_profile": "simonw-EC2-SSM",
"aws_inst_user": "ubuntu",
"aws_storage_size": "30",
"aws_kernel_version": "4.15.0-47-generic"
},
"builders": [
{
"communicator": "ssh",
"source_path": "ubuntu/bionic64",
"provider": "virtualbox",
"add_force": true,
"type": "vagrant",
"synced_folder": ".",
"template": "./base-box-vagrantfile-template"
},
{
"type": "amazon-ebs",
"region": "eu-west-2",
"ami_name": "simonw-bf-sde-{{ user `bf_sde_version` }}-ami-{{timestamp}}",
"source_ami": "{{ user `aws_src_ami` }}",
"instance_type": "t3.2xlarge",
"iam_instance_profile": "{{ user `aws_iam_inst_profile` }}",
"ssh_interface": "session_manager",
"ssh_username": "{{ user `aws_inst_user` }}",
"tags": {
"UserName": "simonw",
"Owner": "simonw",
"Description": "Packer AMI build test"
},
"launch_block_device_mappings": [
{
"device_name": "/dev/sda1",
"encrypted": false,
"volume_size": "{{ user `aws_storage_size` }}",
"delete_on_termination": true
}
]
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"sleep 10",
"sudo apt update",
"sudo apt install -y python2.7 python3-pip python-pip linux-image-{{ user `aws_kernel_version`}}",
"sudo pip3 install --upgrade pip",
"sudo pip3 install ansible",
"sudo pip2 install --upgrade pip",
"sudo pip2 install pyyaml six"
]
},
{
"type": "shell",
"script": "downgrade-kernel.sh",
"environment_vars": [
"KERNEL_VERSION={{ user `aws_kernel_version` }}"
],
"execute_command": "chmod +x {{ .Path }}; sudo sh -c '{{ .Vars }} {{ .Path }}'",
"expect_disconnect": true,
"pause_after": "2m"
},
{
"type": "shell",
"inline": [
"sleep 10",
"uname -a",
"cat /etc/default/grub",
"echo finished downgrading kernel",
"# OTHER PROVISIONERS WOULD RUN AFTER THIS"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment