Created
November 14, 2018 06:03
-
-
Save pserrano/64848ade22f506178af09ddc87157a3d to your computer and use it in GitHub Desktop.
Packer with ansible solution for AWS
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": { | |
"profile": "aws1", | |
"region": "eu-east-1", | |
"type":"amazon-ebs", | |
"ssh_keypair_name": "private", | |
"ssh_private_key_file": "$HOME/.ssh/private.pem" | |
}, | |
"provisioners": [ | |
{ | |
"type": "shell", | |
"inline": [ | |
"echo '127.0.0.1 server server.aws' | sudo tee --append /etc/hosts", | |
"sudo hostnamectl set-hostname server", | |
"echo 'PATH=\"/root/bin:/root/.local/bin:$PATH\"' | sudo tee --append /root/.profile", | |
"sudo shutdown -r now" | |
], | |
"expect_disconnect": "true" | |
}, | |
{ | |
"type": "ansible", | |
"playbook_file": "../ansible/main.yml", | |
"host_alias": "server", | |
"extra_arguments": [ "--vault-password", "/ansible/vault_password", "--extra-vars" , "target=server env=live" ] | |
} | |
], | |
"builders": [{ | |
"type": "amazon-ebs", | |
"access_key": "{{user `aws_access_key`}}", | |
"secret_key": "{{user `aws_secret_key`}}", | |
"region": "eu-west-1", | |
"source_ami": "(put your ami base)", | |
"instance_type": "m4.large", | |
"ssh_username": "admin", | |
"ssh_keypair_name": "{{user `ssh_keypair_name`}}", | |
"ssh_private_key_file": "{{user `ssh_private_key_file`}}", | |
"ami_name": "Server {{timestamp}}", | |
"tags": { | |
"Name": "Server" | |
} | |
}], | |
"post-processors": [ | |
{ | |
"type": "manifest", | |
"output": "manifestserver.json", | |
"strip_path": true | |
}] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment