Discussion:
changing inventory_hostname when working with chroot connector
Matthew Hollick
2013-10-17 12:11:23 UTC
Permalink
I am probably doing this completely wrong...

The playbook is for a system running openvz.
It tries to clone a openvz container from an existing template then setup
ssh using the chroot connector.
The container is then booted.
Finally it attempts to ssh to the container to make sure that everything
has worked.


my vars file:

vzhome: /vz
veprivate: $vzhome/private/$veid

my hosts file:

[container_deploy]
scratch248.example.com veid=248 suite=wheezy arch=amd64


some of my playbook:

- hosts: container_deploy
gather_facts: no
connection: local
vars_files:
- vars/setup.yml
....
- include: tasks/clone.yml
- name: Clean existing known_hosts entry
command: ssh-keygen -R $inventory_hostname
- include: tasks/initialconfig.yml ansible_connection=chroot
inventory_hostname=$veprivate
- include: tasks/verify.yml ansible_connection=ssh

The variable inventory_hostname is not passed through to the included
initialconfig.yml playbook like ansible_connection is. I assume that it is
a bit special. I get the following error:

TASK: [Create Openvz configuration] *******************
changed: [scratch248.example.com]

TASK: [Rebuild locales]
*******************************************************
fatal: [scratch248.example.com] => scratch248.example.com is not a directory

FATAL: all hosts have already failed -- aborting

PLAY RECAP
********************************************************************
to retry, use: --limit @/var/tmp/ansible/deploy.retry

scratch248.example.com : ok=6 changed=4 unreachable=1 failed=0



Any suggestions for how to do this in a more elegant manner, or at least
one that will work? :-D


Thanks.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Michael DeHaan
2013-10-17 17:58:10 UTC
Permalink
inventory_hostname is indeed a magic variable and cannot be set.

I'm trying to understand a little bit but it sounds like you want to
configure it chroot and then talk to it normally?

I would do better if I understood the use case a little bit.

If you want to do that the "add_host" module can mangle inventory but you
might be better served by putting it into inventory twice and having the
"build_image" be one record and the host be another?
Post by Matthew Hollick
I am probably doing this completely wrong...
The playbook is for a system running openvz.
It tries to clone a openvz container from an existing template then setup
ssh using the chroot connector.
The container is then booted.
Finally it attempts to ssh to the container to make sure that everything
has worked.
vzhome: /vz
veprivate: $vzhome/private/$veid
[container_deploy]
scratch248.example.com veid=248 suite=wheezy arch=amd64
- hosts: container_deploy
gather_facts: no
connection: local
- vars/setup.yml
....
- include: tasks/clone.yml
- name: Clean existing known_hosts entry
command: ssh-keygen -R $inventory_hostname
- include: tasks/initialconfig.yml ansible_connection=chroot
inventory_hostname=$veprivate
- include: tasks/verify.yml ansible_connection=ssh
The variable inventory_hostname is not passed through to the included
initialconfig.yml playbook like ansible_connection is. I assume that it is
TASK: [Create Openvz configuration] *******************
changed: [scratch248.example.com]
TASK: [Rebuild locales]
*******************************************************
fatal: [scratch248.example.com] => scratch248.example.com is not a directory
FATAL: all hosts have already failed -- aborting
PLAY RECAP
********************************************************************
scratch248.example.com : ok=6 changed=4 unreachable=1 failed=0
Any suggestions for how to do this in a more elegant manner, or at least
one that will work? :-D
Thanks.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/groups/opt_out.
--
Michael DeHaan <***@ansibleworks.com>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Loading...