Ansible

Ansible playbook with packer in Jenkins

Quick one. While working on a build chain in order to register home-baked AMIs, I wanted to use the ansible-local packer provisioner to setup the instance with a very basic playbook. I needed to provide ansible a playbook but didn’t find immediately how to achieve this within the Jenkins-packer module. Turns out it’s tricky, in the JSON Template Text (or the template file), declare the playbook_file like this: [{ "type": "ansible-local", "playbook_file": "{{ user `test_yml` }}", "command": "PYTHONUNBUFFERED=1 ansible-playbook" }] Then in the File Entries field, the Variable Name must be test_yml and File Contents filled with the playbook.

Ansible and AWS ASG, a (really) dynamic inventory

I found myself searching ridiculously too long to achieve what I believed was a simple task: to apply an Ansible role to newly created instances… started by an Auto Scaling Group. If you’re used to Ansible you know that it relies on an inventory to apply a playbook, but obviously, when you’re firing up EC2 instances with the same playbook, you are not able to know what will be your virtual machines IP addresses, nor can ec2.