1

With ansible i want to configure rsyslog service for a group of hosts than add the name those hosts to a central host (different from the group of hosts) so my playbook:

- hosts: gourp_of_hosts       
  tasks:

    - name: set rsyslog configuration
      lineinfile:
        path: /etc/rsyslog.conf
        line: '{{item}}'
      with_items:
        - some items....
      become: yes

    - name: add host to rsyslog central
      blockinfile:
        path: /etc/rsyslog.conf
        block: |
          {{ansible_hostname}}....
      delegate_to: x.x.x.x (my central host)
      become: yes

My inventory file contains both the group of hosts and my central host:

[gourp_of_hosts]
host1 ansible_user=.... ansible_user_pass=.. ansible_sudo_pass=..
host2 ansible_user=.... ansible_user_pass=.. ansible_sudo_pass=..
[central]
x.x.x.x ansible_user=... ansible_user_pass=.. ansible_sudo_pass=..

Now i'm facing the following error:

fatal: [host1]: FAILED! => {"msg": "Incorrect sudo password"}

I tried removing central host from my inventory file and used ssh-copy-id user@x.x.x.x in result i'm having the following error:

fatal: [host]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-with-mic,password).\r\n", "unreachable": true}

BOUKANDOURA Mhamed
  • 941
  • 1
  • 9
  • 25
  • 1
    There is a big messup in ansible with delegate_to and different ssh credentials. Try to play with delegate_facts, and defining custom `vars: ansible_ssh_host (etc)` variables. – George Shuklin Oct 23 '18 at 15:11
  • Indeed you were right, somehow `delegate_to` was using my inventory host password, i tired using the same sudo password for both servers and it works, now i added to my task `delegate_facts` with the variable `ansible_sudo_pass` and it works. but still i need to hide the password from my playbook with some encryption.. Thank you. – BOUKANDOURA Mhamed Oct 24 '18 at 07:15
  • I think we're seeing this same bug...what version of Ansible were you using? – Duke Robillard Mar 04 '19 at 19:28

0 Answers0