Things I wish they'd told me
When you try to debug something in packer by making a change in the Ansible role
you want to see the effect immediately. To do that just symlink your project
in ~/.ansible/roles
with whatever name you are referencing it with.
So, for example, a project refered to as rhythmic.jetty
which is locally in ansible-role-jetty
:
`ln -s $(pwd)/ansible-role-jetty ~/.ansible/roles/rhythmic.jetty`
If you do this IT WILL ASK YOU FOR INPUT BETWEEN EVERY STEP. This is perhaps one of the most annoying debug behavior ever.
Now packer will run until an error and then ask you what to do:
==> my-jetty-ami: [c] Clean up and exit, [a] abort without cleanup, or [r] retry step (build may fail even if retry succeeds)?
By specifying the keypair you can use a key you already have in AWS to SSH in:
"builders": [{
"ssh_keypair_name": "the_key_is_automation",
"ssh_private_key_file": "~/.ssh/tempKeys/the_key_is_automation.pem",
"name": "my-jetty-ami",
"type": "amazon-ebs",
...
Taking a look at what's wrong becomes as easy as SSH:
ssh -i ~/.ssh/tempkeys/the_key_is_automation.pem ec2-user@54.175.220.128
If you've got a box set up (maybe from running packer with -on-error=ask
) you can run the ansible debugger. It's a lot like pdb
for Ansible.