Open joaocc opened 9 years ago
added the following command before:
- sudo: true
get_url:
url: "http://ppa.launchpad.net/ondrej/php5/ubuntu/dists/trusty/Release.gpg"
dest: /tmp/test-php5-ppa.gpg
force: yes
ansible -vvv
TASK: [ez123-web--php5 | DEBUG-1] *********************************************
<h-lemp-1> THIS IS A LOCAL LXC DIR
<h-lemp-1> REMOTE_MODULE get_url dest=/tmp/test-php5-ppa.gpg url=http://ppa.launchpad.net/ondrej/php5/ubuntu/dists/trusty/Release.gpg
<h-lemp-1> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1437528542.09-225157215014723 && echo $HOME/.ansible/tmp/ansible-tmp-1437528542.09-225157215014723']
<h-lemp-1> PUT /tmp/tmpKr77ig TO /home/vagrant/.ansible/tmp/ansible-tmp-1437528542.09-225157215014723/get_url
<h-lemp-1> EXEC ['/bin/sh', '-c', u'LANG=C LC_CTYPE=C /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1437528542.09-225157215014723/get_url; rm -rf /home/vagrant/.ansible/tmp/ansible-tmp-1437528542.09-225157215014723/ >/dev/null 2>&1']
failed: [h-lemp-1] => {"dest": "/tmp/test-php5-ppa.gpg", "failed": true, "response": "Request failed: <urlopen error [Errno 111] Connection refused>", "state": "absent", "status_code": -1, "url": "http://ppa.launchpad.net/ondrej/php5/ubuntu/dists/trusty/Release.gpg"}
msg: Request failed
FATAL: all hosts have already failed -- aborting
running inside the guest (sudo lxc-console -n h-lemp-1)
ubuntu@h-lemp-1:~$ curl http://ppa.launchpad.net/ondrej/php5/ubuntu/dists/trusty/Release.gpg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
iJwEAAECAAYFAlWmW+MACgkQT06gquUmemx17AP9H05MSi6UAis2u1nOh9nhqEN+
l5I8C5hll/5/2DpeZqxfzJbyJ/Ni7M6hE/aDWC4JhOxkbKgNkFN3dXKGwWM+jVtK
QGG1mhWVoTjoZo6tD5t0NKEH2rv/fti7kvyqoGGDqwd1FKAsxA8qZz85bZU7JGbi
qd8yZ3m6xFr8GBV9Hno=
=wLJS
-----END PGP SIGNATURE-----
I suspect, lxc keeps the current working directory, when entering containers. Does it make a difference, if you change to / or /tmp/ on the host and start ansible from there?
I think (more a hunch) that the problem is that LXC tries to connect with the same name as it has on the "origin" side. Since that user doesn't exist, it doesn't have a home directory (or something similar). We can try with "/tmp" but I would still prefer to be able to configure which user account is used when connecting.
It does not correlate with the user, because in that case it would be root and the directory would be in /root/.ansible. The vagrant user and its home should not exists in lxc container, therefor my idea was, that PWD environment variable is not overwritten, when entering a container.
When running the controller in a vagrant vm with lxc installed locally, lxc creates a "/home/vagrant/.ansible" folder on the guest (chowned as root:root). However, the "vagrant" user is not defined in the guest.
I suspect (but am not sure) that this is leading to some weird behaviours:
executing "shell ssh-import-id" or " authorized_key:" on the lxc guest fails (see ansible.log extract below)
2015-07-21 19:42:35,999 p=23545 u=root | failed: [h-db-mongo] => (item=lp:joaocc) => {"changed": true, "cmd": "ssh-import-id \"lp:joaocc\"", "delta": "0:00:00.424627", "end": "2015-07-21 19:42:35.979886", "item": "lp:joaocc", "rc": 1, "start": "2015-07-21 19:42:35.555259", "warnings": []}
How can I change the account as which ansible connects to the guest?
Thanks