Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

provisioner can get SSH connection information?

183 views
Skip to first unread message

Shirou w

unread,
Aug 5, 2013, 8:55:49 PM8/5/13
to packe...@googlegroups.com
Hello,
I'm new to packer and I'm trying to implements Ansible[1] provisioner.

ansible does not require remote command execute because ansible itself run over a ssh-connection.
So, I want to know the IP address, port, username and password of the ssh connection which packer uses from the provisioner.

Would it be possible to get these information from communictor which is passed to the Provision()?



Thanks,
WAKAYAMA Shirou

Mitchell Hashimoto

unread,
Aug 7, 2013, 5:53:06 PM8/7/13
to packe...@googlegroups.com
Hi,

There isn't a way at the moment. The problem is that the communication
is opaque, and may not even be happening over SSH. For example, with
the "amazon-chroot" builder, the provisioning actually just happens
inside a chroot, so the commands are executed locally. I'm not sure
how to portably handle this with Ansible.

Ideas?

Best,
Mitchell
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

shirou

unread,
Aug 8, 2013, 11:08:28 AM8/8/13
to packe...@googlegroups.com
Hi Mitchell,

I understand what is the problem.
In Ansible, if a target host is local, set the variable
(ansible_connection) to local and can run on the localhost.
So, if Communicator provide a connection type and other information
(such as addr, port, user and pass for ssh),
Ansible provisioner can change a behavior.
(I'm not sure whether this is good for other provisioner and/or future
extension)

Regards,
WAKAYAMA Shirou


2013/8/8 Mitchell Hashimoto <xmi...@gmail.com>:

Mitchell Hashimoto

unread,
Aug 8, 2013, 11:12:08 AM8/8/13
to packe...@googlegroups.com
Shirou,

Unfortunately this still wouldn't work well. When I say "local" I mean
it is executed locally but actually executed within the context of a
chroot, I don't think Ansible has any way to "remotely" execute within
a chroot. Also, I'm working on a Docker builder which also runs
"local" but again by local it means it just runs the command within a
docker container. So, again, not SSH, but not a local filesystem
either.

Ansible seems to be lacking this flexibility at the moment.

Best,
Mitchell

shirou

unread,
Aug 8, 2013, 11:45:41 AM8/8/13
to packe...@googlegroups.com
Mitchell,

Actually, Ansible has a chroot connection [1][2]. (I noticed the
lack of the documentation...)
Honestly I have not used yet, but it should work.

[1] https://github.com/ansible/ansible/pull/2106
[2] https://github.com/ansible/ansible/blob/devel/lib/ansible/runner/connection_plugins/chroot.py

Thank you,
WAKAYAMA Shirou


2013/8/9 Mitchell Hashimoto <xmi...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages