Problem with ansible and packer

319 views
Skip to first unread message

Frédéric Cuza

unread,
Apr 12, 2019, 6:06:52 AM4/12/19
to Packer
Hi everyone,

I have a problem with Packer and the ansible provisioner (not local).
I am trying to build Vmware templates with vsphere-iso (2.3) and packer (1.3.5).
I can build a template but when ansible is executing the playbook all is set to "ok" and there are no "changed"...

When I start the template on a VM I can see that nothing that was supposed to be done is in fact done.
It seems that the playbook is not "applied" on the host started by Packer.

My ansible part of my json :

"provisioners": [
    {
      "type": "ansible",
      "playbook_file": "/etc/ansible/playbook/playbook.yml",
      "ansible_env_vars": [ "ANSIBLE_HOST_KEY_CHECKING=False", "ANSIBLE_STDOUT_CALLBACK=full_skip"],
      "user": "infra",
      "extra_arguments": [
        "--extra-vars", "ansible_become_pass=apassword"
      ]
    }
  ]

It is a Ubuntu 18.04.

As I'm writing for a problem I can mention that with Ubuntu18.04 with netplan the IP address affected by packer is not removed when the VM is converted to a template so anytime you use this template you find your new vm with the new IP and the one that was
assigns by packer to the VM used to build the template (If anyone as a way to resolv this too...)

Thanks in advance for you help.

Regards,

Frédéric Cuza

unread,
Apr 12, 2019, 8:21:31 AM4/12/19
to Packer

My bad :

==> vsphere-iso: Executing Ansible: ansible-playbook --extra-vars packer_build_name=vsphere-iso packer_builder_type=vsphere-iso -o IdentitiesOnly=yes -i /tmp/packer-provisioner-ansible331074660 /etc/ansible/playbook/playbook.yml -e ansible_ssh_private_key_file=/tmp/ansible-key078745817 --extra-vars ansible_become_pass=passwd
    vsphere-iso:
    vsphere-iso: PLAY [all] *********************************************************************
    vsphere-iso:
    vsphere-iso: TASK [Gathering Facts] *********************************************************
    vsphere-iso: ok: [default]
    vsphere-iso:
    vsphere-iso: TASK [/usr/local/ansible-roles/mirror : Set internal mirror Ubuntu.] ***
    vsphere-iso: ok: [default]
    vsphere-iso:
    vsphere-iso: TASK [/usr/local/ansible-roles/ntp : Uninstall chrony] *************************
    vsphere-iso: ok: [default]
    vsphere-iso:
    vsphere-iso: TASK [/usr/local/ansible-roles/ntp : install the latest version of NTP] ********
    vsphere-iso: ok: [default]
    vsphere-iso:
    vsphere-iso: TASK [/usr/local/ansible-roles/ntp : Ntp configuration] ************************
    vsphere-iso: ok: [default]
    vsphere-iso:
    vsphere-iso: TASK [/usr/local/ansible-roles/ntp : Remove useless packages from the cache / Remove dependencies that are no longer required] ***
    vsphere-iso: ok: [default]
    vsphere-iso:
    vsphere-iso: PLAY RECAP *********************************************************************
    vsphere-iso: default                    : ok=6    changed=0    unreachable=0    failed=0
    vsphere-iso:
==> vsphere-iso: Shut down VM..

d...@linder.org

unread,
Apr 13, 2019, 9:51:19 AM4/13/19
to Packer
Agreed that the Ansible output looks like it should be making the changes as desired.

Please post your playbook as well as your full packer JSON file.

Frédéric Cuza

unread,
Apr 15, 2019, 2:49:42 AM4/15/19
to Packer
Here is my full.json and the first part of my ansible playbook.

Thanks for you help.

I won't past all my roles but basicly it upload templates / create dir and install and/or remove package (chrony, ntp)
ubuntu_1804.json
playbook.yml

Frédéric Cuza

unread,
Apr 24, 2019, 9:19:33 AM4/24/19
to Packer
Still stuck on this problem will post here a solution asap.

Regards,
Reply all
Reply to author
Forward
0 new messages