Created
January 23, 2020 18:34
-
-
Save csiens/b80a296a381a1b196806a31413ef4c5a to your computer and use it in GitHub Desktop.
AWS Ubuntu Nginx Packer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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