play-book + template hangs up.

I'm running ansible with virtualenv.

$ yolk -l
Jinja2 - 2.6 - active
PyYAML - 3.10 - active
Python - 2.6.6 - active development (/opt/local/
Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-
dynload)
paramiko - 1.7.7.1 - active
pip - 0.6.3 - active
pycrypto - 2.5 - active
setuptools - 0.6c12dev-r88846 - active
wsgiref - 0.1.2 - active development (/opt/local/
Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6)
yolk - 0.4.3 - active

$ cat sample-template.yml

$ ansible all -m setup -u ubuntu

Now, host file has a single server running Ubuntu Oneiric.
[web-servers]
xx.xx.xx.xx

$ ansible-playbook sample-template.yml -T 30 --debug

If setup didn’t hang in your above test execution from /usr/bin/ansible, that is interesting. What happens if you do something like:

ansible -m template -a “template src=templates/foo.j2 dest=/etc/some_random_foo.conf” -D ?

-D will show the standard output of the module.

(You can also use -D with playbooks).

Since the regular CLI worked to execute setup it doesn’t look like it’s an issue with logging in or SSH.

Depending on the answer to that I should have some other things for you to try.

I should also add that templates work differently on the integration branch, but we’re working on those. I assume
you are running off the master branch? If so, lots of people have been using those and I wouldn’t expect
the hang.

Anyway, let me know. Thanks!

SSH Agent are running ok.

ansible)ubuntu@testbox:~/my-github/ansible/examples/playbooks$ ansible
web-servers -m setup -u ubuntu
192.168.2.140 | success >> {
    "changed": false,
    "md5sum": "c226357c730f7b88bd8d3167b9b6f65e",
    "metadata": "/home/ubuntu/.ansible/setup",
    "written": "/home/ubuntu/.ansible/setup"
}

(ansible)ubuntu@testbox:~/my-github/ansible/examples/playbooks$
ansible 192.168.2.140 -m setup -u ubuntu
192.168.2.140 | success >> {
    "changed": false,
    "md5sum": "c226357c730f7b88bd8d3167b9b6f65e",
    "metadata": "/home/ubuntu/.ansible/setup",
    "written": "/home/ubuntu/.ansible/setup"
}

(ansible)ubuntu@testbox:~/my-github/ansible/examples/playbooks$
ansible 192.168.2.140 -m template -a "template src=templates/foo.j2
dest=/etc/some_random_foo.conf" --debug
192.168.2.140 | FAILED => FAILED: Authentication failed.
(ansible)ubuntu@testbox:~/my-github/ansible/examples/playbooks$
ansible web-servers -m template -a "template src=templates/foo.j2
dest=/etc/some_random_foo.conf" --debug
192.168.2.140 | FAILED => FAILED: Authentication failed.
(ansible)ubuntu@testbox:~/my-github/ansible/examples/playbooks$

Seems will be starting to debug on this part.. btw, this is the master
branch. I believe the integration branch will process templates
locally.

Opps..seems the command using "ansible" only requires -u option and -
s (sudo) for that file to be on /etc

ansible)ubuntu@testbox:~/my-github/ansible/examples/playbooks$ ansible
192.168.2.140 -m template -a "template src=templates/foo.j2 dest=/etc/
some_random_foo.conf -u ubuntu -s -D

And it hang's up there, let me check writing the template file to /tmp
first.

Looking at what you posted below, you are invoking setup with “-u ubuntu”, but not when running the template module.
This would explain the problem as that would mean, without a “-u”, it is trying root.

For each play in a playbook, make sure you have the following:

user: ubuntu

And similarly, when you run templates from /usr/bin/ansible, don’t forget the -u either.

So I don’t think it’s hanging, it’s just an SSH timeout thing, most likely. -T 30 is 30 seconds, which is a long time.
I would think it would fail immediately though versus waiting the 30, but… that could be the case.

Currently the “-D” is all about showing errors from the remote modules (for when modules crash), so it’s not going to give you any more information
about authentication. (This will probably change in the future to also remind you about what user is it is connecting as,
what ports it is trying to use, etc.)

–Michael

Opps…seems the command using “ansible” only requires -u option and -
s (sudo) for that file to be on /etc

ansible)ubuntu@testbox:~/my-github/ansible/examples/playbooks$ ansible
192.168.2.140 -m template -a "template src=templates/foo.j2 dest=/etc/
some_random_foo.conf -u ubuntu -s -D

And it hang’s up there, let me check writing the template file to /tmp
first.

Beat me to it.

Yeah, I don’t think anything should be hanging.

It should basically fail with an appropriate error.

If you can figure out why it’s hanging (not sure of your Python experience) it would be nice to eliminate
that glitch. I may also be able to investigate why this error path is acting weird for you later tonight, but
offhand I haven’t seen it.

There’s nothing in the template module that has any retry logic, so it shouldn’t keep trying to do things.

While figuring out the error, I found one:
https://github.com/ansible/ansible/issues/178

Anyways, I think it's on the sudo or something on ssh.

(ansible)Cocoys-MacBook-Pro:playbooks cocoy$ ansible web-servers -m
template -a "template src=templates/foo.j2 dest=/tmp/
some_random_foo.conf" -u ubuntu
192.168.2.140 | success >> {
    "changed": false,
    "group": "ubuntu",
    "md5sum": "7f340d5391bbb20d631c9dbf11900f1b",
    "mode": 420,
    "path": "/tmp/some_random_foo.conf",
    "state": "file",
    "user": "ubuntu"
}

(ansible)Cocoys-MacBook-Pro:playbooks cocoy$ ansible web-servers -m
template -a "template src=templates/foo.j2 dest=/etc/
some_random_foo.conf" -u ubuntu -s -D

.. now it hangs up here...

Any guys using "sudo" here? :slight_smile:

I was having a hang on sudo also (on Ubuntu Oneiric). I did not have time to investigate, so I have not been using sudo for the moment.

Yeah, this should use os.path.expanduser around that path.

Easy fix.

If your sudo requires a password and you do not supply one or it is wrong, that will happen. I have some notes that we need to fix things up in connection.py.
If you get the password right (or it does not require one) it should not cause any problems.

(Sudo password is specified with --ask-sudo-pass)

I prefer and suggest using passwordless sudo where possible, but the password stuff seems to work fine. If you think you’re supplying the correct password
and it’s still hanging, we may have some issues there where the app really needs to parse what is coming back from sudo so it can fail versus wait at the prompt.

(Sudo password is specified with --ask-sudo-pass)

On Ubuntu, its setup as passwordless sudo.

Hi,

I am experiencing the same thing. I just have localhost set up in my hosts file on Ubuntu, and when I try:

$ ansible local -a “/usr/bin/whoami” -u ubuntu -s -D

It hangs until I CTRL-C and get the following output:

^CTraceback (most recent call last):
File “/home/ubuntu/ansible/bin/ansible”, line 170, in
(runner, results) = cli.run(options, args)
File “/home/ubuntu/ansible/bin/ansible”, line 102, in run
return (runner, runner.run())
File “/home/ubuntu/ansible/lib/ansible/runner.py”, line 715, in run
results = self._parallel_exec(hosts)
File “/home/ubuntu/ansible/lib/ansible/runner.py”, line 673, in _parallel_exec
while not result_queue.empty():
File “”, line 2, in empty
File “/usr/lib/python2.7/multiprocessing/managers.py”, line 755, in _callmethod
self._connect()
File “/usr/lib/python2.7/multiprocessing/managers.py”, line 742, in _connect
conn = self._Client(self._token.address, authkey=self._authkey)
File “/usr/lib/python2.7/multiprocessing/connection.py”, line 169, in Client
c = SocketClient(address)
File “/usr/lib/python2.7/multiprocessing/connection.py”, line 289, in SocketClient
s.connect(address)
File “/usr/lib/python2.7/socket.py”, line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 2] No such file or directory

I think ansible is just trying to do this isn’t it?

$ ssh ubuntu@127.0.0.1 sudo whoami
root

Which works fine without password entry.

Any ideas what would be causing the “-s” option to hang?

I really don’t want to allow SSHing as root, so this option needs to work before I can really get into using ansible.

Thanks,
Peter

Peter,

Does your sudo configure require a password for the user running sudo? If
so, you need to specify the -K option which will prompt you for the sudo
password. If not, let's continue to debug...

Dave

Which branch are you using? There have been some recent attempts to upgrade sudo on devel.

Let me know which and try the other :slight_smile:

I really need to read more closely... passwordless sudo, so not the
problem... so excuse my question.... :slight_smile:

I'm running the devel branch and sudo works fine for me with password...
let me see if it breaks when I make it passwordless..

Dave

Hi,

My sudoers file has the following:

ubuntu ALL=(ALL) NOPASSWD:ALL

so no password is needed.

Right now, I am using the master branch in Git. Doing this works without password, so I can confirm that.

$ ssh ubuntu@127.0.0.1 sudo whoami
root

Peter

Ok, I switched from master to the devel branch and it works well. Will probably be in release 0.4.

Peter

I am learning on making 0.4 a shorter release cycle and pushing some features out to 0.5, as this is probably something people want.

That being said, it worked for me previously, but the sudo timing stuff was a rough cut. I can see where it could have problems.

Good deal!