Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delagate_to ignores --user parameter #359

kustodian opened this issue Sep 11, 2018 · 1 comment

delagate_to ignores --user parameter #359

kustodian opened this issue Sep 11, 2018 · 1 comment


Copy link

@kustodian kustodian commented Sep 11, 2018

I'm using the latest master version from Git on Archlinux (Python 3.7.0) and CentOS 6 (Python 2.6.6) as target host.

I have the following task:

- name: 'Create Postgres user for zabbix-server'
    name: '{{ zabbix_server_dbuser }}'
    password: '{{ zabbix_server_dbpassword }}'
    role_attr_flags: 'LOGIN'
    port: '{{ zabbix_server_dbport }}'
  delegate_to: '{{ zabbix_server_db_hostname }}'

which fails like this:

TASK [zabbix_server : Create Postgres user for zabbix-server] *****************************************************************************************************************
task path: /home/myuser/git/ansible-infrastructure/roles/zabbix_server/tasks/main.yml:52
[pid 19942] 12:15:01.323449 D mitogen: unix.connect(path='/tmp/mitogen_unix_m9rj7lun')
[pid 19942] 12:15:01.324116 D mitogen: unix.connect(): local ID is 2033, remote is 0
[pid 19756] 12:15:01.354110 D mitogen: mitogen.ssh.Stream('default').connect()
[pid 19756] 12:15:01.365419 D mitogen: create_child() child 19945 fd 66, parent 19756, cmd: ssh -o "LogLevel ERROR" -o "Compression yes" -o "ServerAliveInterval 15" -o "ServerAliveCountMax 3" -o "BatchMode yes" -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -o "GlobalKnownHostsFile /dev/null" -o ControlMaster=auto -o ControlPersist=60s python -c "'import codecs,os,sys;_=codecs.decode;exec(_(_(\"eNqFkFFLwzAUhZ/XX9G3JBi3ZOKGhYCyB/FBhCLuQYekTerCuiSk7br5673rhLXzwbf7cc+953BSuhSuGnv.........q9ULf/qf+m5IOUPx8QruM=\".encode(),\"base64\"),\"zip\"))'"
[pid 19756] 12:15:01.366173 D mitogen: mitogen.ssh.Stream('local.19945').connect(): child process stdin/stdout=66
[pid 19756] 12:15:01.429592 D mitogen: mitogen.ssh.Stream('local.19945'): received b' Permission denied (publickey).\r\n'
[pid 19756] 12:15:01.430046 D mitogen: mitogen.ssh.Stream('local.19945'): child process exit status was 65280
[pid 19942] 12:15:01.431139 D mitogen: mitogen.core.Stream('unix_listener.19756').on_disconnect()
[pid 19942] 12:15:01.431532 D mitogen: Waker(Broker(0x7f1bed704390) rfd=12, wfd=13).on_disconnect()
[pid 19756] 12:15:01.431536 D mitogen: mitogen.core.Stream('unix_client.19942').on_disconnect()
fatal: []: UNREACHABLE! => changed=false 
  msg: 'EOF on stream; last 300 bytes received: '' Permission denied (publickey).\r\n'''
  unreachable: true

zabbix_server_db_hostname is set like this:

zabbix_server_db_hostname: "{{ inventory_hostname }}"

I run the playbook with:

[myuser@host] $ ansible-playbook -i hosts.ini zabbix.yml -u root

As you can see from the error, it uses myuser to ssh into delegate_to host, instead of root.

If I set ansible_user=root in inventory for the zabbix host, everything works fine.

Here is the ansible configuration diff if you need it:

ANSIBLE_NOCOWS(/home/myuser/git/ansible-infrastructure/ansible.cfg) = True
ANSIBLE_PIPELINING(/home/myuser/git/ansible-infrastructure/ansible.cfg) = True
ANSIBLE_SSH_ARGS(/home/myuser/git/ansible-infrastructure/ansible.cfg) = -o ControlMaster=auto -o ControlPersist=60s
ANSIBLE_SSH_RETRIES(/home/myuser/git/ansible-infrastructure/ansible.cfg) = 1
DEFAULT_BECOME_USER(/home/myuser/git/ansible-infrastructure/ansible.cfg) = root
DEFAULT_FORKS(/home/myuser/git/ansible-infrastructure/ansible.cfg) = 50
DEFAULT_GATHERING(/home/myuser/git/ansible-infrastructure/ansible.cfg) = smart
DEFAULT_JINJA2_EXTENSIONS(/home/myuser/git/ansible-infrastructure/ansible.cfg) =,jinja2.ext.i18n
DEFAULT_MODULE_PATH(/home/myuser/git/ansible-infrastructure/ansible.cfg) = ['/home/myuser/git/ansible-infrastructure/library', '/home/myuser/git/ansible-infrastructure/galaxy_roles/nordeus_modules/library']
DEFAULT_ROLES_PATH(/home/myuser/git/ansible-infrastructure/ansible.cfg) = ['/home/myuser/git/ansible-infrastructure/galaxy_roles', '/home/myuser/git/ansible-infrastructure/roles']
DEFAULT_STDOUT_CALLBACK(/home/myuser/git/ansible-infrastructure/ansible.cfg) = yaml
DEFAULT_STRATEGY(/home/myuser/git/ansible-infrastructure/ansible.cfg) = mitogen_linear
DEFAULT_STRATEGY_PLUGIN_PATH(/home/myuser/git/ansible-infrastructure/ansible.cfg) = ['/home/myuser/git/github/mitogen/ansible_mitogen/plugins/strategy']
DEFAULT_TIMEOUT(/home/myuser/git/ansible-infrastructure/ansible.cfg) = 10
HOST_KEY_CHECKING(/home/myuser/git/ansible-infrastructure/ansible.cfg) = False
INVENTORY_UNPARSED_IS_FAILED(/home/myuser/git/ansible-infrastructure/ansible.cfg) = True
RETRY_FILES_ENABLED(/home/myuser/git/ansible-infrastructure/ansible.cfg) = False
Copy link

@dw dw commented Jan 22, 2019

Hi there, sorry for the crazy delay. There was a huge delegate_to bug introduced mid last year that made it into 0.2.3. It seems to have caused all these problems.

This should now be fixed on the master branch and will make it into the next release. To be updated when a new release is made, subscribe to

If you are still experiencing the problem on the current master branch, please do not hesitate to reopen this issue.

Thanks for reporting this!

@dw dw closed this Jan 22, 2019
dw added a commit that referenced this issue Jan 22, 2019
dw added a commit that referenced this issue Jan 22, 2019
* origin/dmw:
  docs: Changelog typo.
  docs: s/doffers/differs/
  issue #434: add to Changelog.
  issue #401: add to Changelog.
  issue #359: add to Changelog.
  issue #396: add to Changelog.
  docs: add thanks entry
  issue #436: add to Changelog.
  issue #465: add to Changelog.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants