0

I am currently experimenting with deploying using Packer’s Ansible local provisioning and for some odd reason, it doesn’t appear to be executing the tasks in the playbook. Packer, after installing the pre-requiresites for Ansible, uploads the following:

Inventory file (“hosts”)

[localhost]
localhost ansible_connection=local

And the playbook file (“local.yml”):

---
- hosts: localhost
  connection: local
  become: yes
  become_method: sudo
  tasks:
  - name: Making sure that ansible is actually executing this playbook
    shell: echo "hello world"
  - name: install packages
    package: name={{ item }} state=present
    with_items: 
      - nginx
      - git
      - curl
      - libmysqlclient-dev
      - libmysqlclient18
      - mysql-common
      - nodejs
      - tcpdump

The output is as follows (running Ansible against a Ubuntu 14.04 instance):

    amazon-ebs: Executing Ansible: cd /tmp/packer-provisioner-ansible-local && ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 ansible-playbook /tmp/packer-provisioner-ansible-local/local.yml -c local -i /tmp/packer-provisioner-ansible-local/hosts
==> amazon-ebs: Stopping the source instance...
==> amazon-ebs: Waiting for the instance to stop.

As you can see, there is no Ansible output, which I assume I should get (somebody correct me if I am wrong).

I did manual run of the playbook, which worked successfully. At this point, I am not sure if I missing something or not.

Rilindo
  • 5,078
  • 5
  • 28
  • 46

1 Answers1

0

As it turns out, the problem was that I had a reboot command execute prior to running ansible.

  "sudo apt-get -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' -y upgrade",
  "sudo chmod -R o+rx /usr/local/lib/python2.7/dist-packages",
  "sudo shutdown -r now"
]
}, {
  "type": "ansible-local",
  "inventory_file": "hosts",
  "playbook_file": "local.yml"
}]

Which meant that the instance was reboot right when Ansible was executed.

Rilindo
  • 5,078
  • 5
  • 28
  • 46