0

I am trying to install packages in ansible using playbook. For that i need to install some packages in yum and some in apt. The version of ansible i am using is:

root@server:~# ansible --version
ansible 2.6.0

when i try to run this playbook for yum, i get this error:

fatal: [centos]: FAILED! => {"changed": false, "module_stderr": "Shared connection to centos closed.\r\n", 
"module_stdout": "sudo: a password is required\r\n", 
"msg": "MODULE FAILURE", "rc": 1}
to retry, use: --limit @/root/test.retry

when i try to run this playbook for apt, i get this error:

fatal: [server]: FAILED! => {"changed": false, "module_stderr": "Shared connection to server closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/ansible_t9NeHG/ansible_module_apt.py\", line 269, in \r\n from ansible.module_utils.urls import fetch_url\r\n File \"/tmp/ansible_t9NeHG/ansible_modlib.zip/ansible/module_utils/urls.py\", line 95, in \r\n File \"/usr/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py\", line 54, in \r\n import OpenSSL.SSL\r\n File \"/usr/lib/python2.7/dist-packages/OpenSSL/init.py\", line 8, in \r\n from OpenSSL import rand, crypto, SSL\r\n File \"/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py\", line 118, in \r\n SSL_ST_INIT = _lib.SSL_ST_INIT\r\nAttributeError: 'module' object has no attribute 'SSL_ST_INIT'\r\n", "msg": "MODULE FAILURE", "rc": 1}

enter image description here

I have gone through various help posts, but this is the way they have suggested to run the playbook. Where am i making the mistakes? Could you please specify. Thank you in advance

2
  • 1
    module_stdout": "sudo: a password is required\r\n", - the account you use for Ansible to log into your server is not configured to allow sudo to be used without a password (or at all?) when you need to run commands that require root privileges. Either configure the required password in Ansible docs.ansible.com/ansible/latest/user_guide/… or set up sudo on that machine with the NOPASSWD option
    – HBruijn
    Jul 16, 2018 at 10:20
  • yes, you were right. Could ssh into my centos by just using ssh centos but the same in case of ubuntu server asked for password. ssh ubuntu and the password doesn't work. i need to do user@ubuntu then it does not ask for password. But again, in case of running playbook, it states "sudo: a password is required". Is there different mechanism for ubuntu only
    – rackwadi
    Jul 17, 2018 at 5:31

1 Answer 1

0

I really did lot of work out to solve this issue. The reason was simple. We need to install Python in the remote machine.

For that, use

# apt-get install python-pip

check the version of python installed on remote machine:

# python --version

Next on the remote machine make sure that we can access them without password. For that, edit sudoers file:

# visudo or #nano /etc/sudoers

then at the end of the file, add

user ALL=(ALL) NOPASSWD: ALL

and save it.

This will do the trick and should work on every installation steps for yum as well as apt.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .