Skip to content

Instantly share code, notes, and snippets.

@amaudy
Created April 10, 2021 06:19
Show Gist options
  • Save amaudy/5004ae82e147d9e40e7e58c77c589617 to your computer and use it in GitHub Desktop.
Save amaudy/5004ae82e147d9e40e7e58c77c589617 to your computer and use it in GitHub Desktop.

Revisions

  1. amaudy created this gist Apr 10, 2021.
    48 changes: 48 additions & 0 deletions packer.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    {
    "variables": {
    "aws_access_key": "ACCESSKEY",
    "aws_secret_key": "SECRETKEY",
    "aws_subnet_id": "SUBNETID"
    },
    "builders": [
    {
    "type": "amazon-ebs",
    "access_key": "{{user `aws_access_key`}}",
    "secret_key": "{{user `aws_secret_key`}}",
    "subnet_id": "{{user `aws_subnet_id`}}",
    "region": "us-east-1",
    "instance_type": "t3.micro",
    "ami_name": "bookapp-{{timestamp}}",
    "source_ami_filter": {
    "filters": {
    "virtualization-type": "hvm",
    "name": "*ubuntu/images/*ubuntu-focal-20.04-amd64-server-*",
    "root-device-type": "ebs"
    },
    "owners": ["xxx"],
    "most_recent": true
    },
    "security_group_filter": {
    "filters": {
    "tag:Class": "packer"
    }
    },
    "ssh_username": "ubuntu"
    }
    ],
    "provisioners": [
    {
    "type": "shell",
    "max_retries": 5,
    "inline": [
    "sudo apt-get update -y && sudo apt-get upgrade -y",
    "sudo apt install python -y"
    ]
    },
    {
    "type": "ansible",
    "playbook_file": "/home/amaudy/ansible/playbooks/apache.yml",
    "groups": ["web"]
    }
    ]
    }