0
votes

I have problem with ansible. I want to configure sudo from another user:

hosts: testnodes

become: yes

become_user: nadya

become_method: sudo

But when I execute playbook, I have an error:

An exception occurred during task execution. The full traceback is: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 119, in run res = self._execute() File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 490, in _execute result = self._handler.run(task_vars=variables) File "/usr/lib/python2.7/dist-packages/ansible/plugins/action/normal.py", line 33, in run results = merge_hash(results, self._execute_module(tmp=tmp, task_vars=task_vars)) File "/usr/lib/python2.7/dist-packages/ansible/plugins/action/init.py", line 617, in _execute_module self._fixup_perms2(remote_files, remote_user) File "/usr/lib/python2.7/dist-packages/ansible/plugins/action/init.py", line 394, in _fixup_perms2 ' see https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user'.format(res['rc'], res['stderr'])) UnicodeEncodeError: 'ascii' codec can't encode character u'\u2018' in position 29: ordinal not in range(128)

fatal: [192.168.3.99]: FAILED! => { "failed": true, "msg": "Unexpected failure during module execution.", "stdout": "" }

ansible --version ansible 2.2.0.0

If I set become_user: root everything is ok.

On remote host /etc/sudo:

ansible ALL=(nadya) NOPASSWD:ALL

Can anybody help me? Thanks.

1
I'm sure, that I write words using Englishh keyboard. I don't copy this string: "become_user: nadya"user265247

1 Answers

0
votes

The clue is in your traceback output:

File "/usr/lib/python2.7/dist-packages/ansible/plugins/action/init.py", line 394, in _fixup_perms2
' see https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user'.format(res['rc'], res['stderr']))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2018' in position 29: ordinal not in range(128)

Which is basically about the fact that Python can't parse res['rc'] or res['stderr'].
This means that remote system printed something non-ascii into stderr as error message.

As you said, you run Ansible 2.2.0.0, so you can check what this error is about here:

                raise AnsibleError('Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user'
                        ' (rc: {0}, err: {1}). For information on working around this,'
                        ' see https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user'.format(res['rc'], res['stderr']))

To avoid the error, fix permissions or use workarounds from provided link.