Ansible as a Packer provisioner hanging?

177 views
Skip to first unread message

Bob Tanner

unread,
Jul 31, 2019, 9:48:26 PM7/31/19
to Packer
Trying to use ansible as a provisioner in packer. Ansible is hanging during the TASK [Gathering Facts] and I have no idea why

the provisioner snippet is below:

    {
      "type": "ansible",
      "command": "script/ansible.sh",
      "playbook_file": "playbooks/testing_ami.yml",
      "user": "{{ user `ssh_username` }}",
      "groups": [
        "aws_comap_com",
        "linux_servers"
      ],
      "extra_arguments": [
        "-u ubuntu",
        "-vvvv"
      ],
      "only": [
        "amazon-ebs"
      ]
    }


The testing_ami.yml is below:

- hosts: all
  vars:
    keep_deb_src: true
    keep_build_essentials: true
  pre_tasks:
  roles:
    - { role: take-over, become: yes }
  tasks:
  post_tasks:

The script/ansible.sh

#!/bin/bash

ansible-playbook $@

I do not understand why a couple of the ssh calls to the packer AMI work and then last one fails.

I am pretty sure this is a packer problem as invoking the same playbook from the command line
works as expected. BUT the logs show the invocation of ansible-playbook like I would do via the command
line.

When I "telnet 127.0.0.1 port", where port is show in the gist below I see 

$ telnet localhost 58595
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
SSH-2.0-Go

So Packer (Go) is being a proxy to the Packer AMI but I never see any sort of login attempts in /var/log/syslog on the Packer AMI then I try to "ssh 127.0.0.1 port"

gist of the logs

Bob Tanner

unread,
Jul 31, 2019, 10:39:58 PM7/31/19
to Packer
Adding that I can ssh to the public IP of the Packer AMI and my ssh-agent key works fine so I feel the problem is with Packers ssh proxy.

Rickard von Essen

unread,
Aug 1, 2019, 2:01:24 AM8/1/19
to packe...@googlegroups.com
First of all your ansible.sh is broken. It does word spliting of the arguments. Fix that, see 1) (or just remove it since it doesn't add anything). Does it help? 


On Thu, Aug 1, 2019, 04:40 Bob Tanner <b...@tanners.org> wrote:
Adding that I can ssh to the public IP of the Packer AMI and my ssh-agent key works fine so I feel the problem is with Packers ssh proxy.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/48887dee-6d1d-43b1-80ce-c8f991861cf5%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages