Skip to content

Instantly share code, notes, and snippets.

@csiens
Created January 23, 2020 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save csiens/b80a296a381a1b196806a31413ef4c5a to your computer and use it in GitHub Desktop.
Save csiens/b80a296a381a1b196806a31413ef4c5a to your computer and use it in GitHub Desktop.
AWS Ubuntu Nginx Packer
#!/bin/sh
#update and install nginx
sudo apt-get update && sudo apt-get install nginx -y
#enable service
sudo systemctl enable nginx && sudo systemctl start nginx
#create index.html
sudo rm /var/www/html/index.nginx-debian.html ; echo "<h1><strong>Hello!</strong></h1>" | sudo tee -a /var/www/html/index.html
#restart nginx
sudo systemctl restart nginx
{
"variables": {
"ansible_user": "ubuntu",
"name": "ubuntu_nginx_packer",
"source_ami": "ami-0d5d9d301c853a04a",
"access_key":"",
"secret_key":"",
"region":"us-east-2"
},
"builders": [{
"type": "amazon-ebs",
"access_key": "{{user `access_key`}}",
"secret_key":"{{user `secret_key`}}",
"ami_name": "{{user `name`}}",
"region": "{{user `region`}}",
"source_ami": "{{user `source_ami`}}",
"instance_type": "t2.micro",
"communicator": "ssh",
"ssh_username": "ubuntu",
"run_tags":{"Name":"packer-image"}
}],
"provisioners": [
{
"type": "shell",
"script": "AWS_ubuntu_nginx.sh"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment