首页 > 解决方案 > Ansible delegate_to “sudo 密码不正确”

问题描述

使用 ansible,我想为一组主机配置 rsyslog 服务,而不是将这些主机的名称添加到中央主机(不同于主机组),所以我的剧本:

- 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

我的清单文件包含主机组和我的中央主机:

[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=..

现在我面临以下错误:

致命:[host1]:失败!=> {"msg": "sudo 密码错误"}

我尝试从我的清单文件中删除中央主机并使用ssh-copy-id user@x.x.x.x结果我遇到以下错误:

致命:[主机]:无法访问!=> {"changed": false, "msg": "通过 ssh 连接主机失败:权限被拒绝 (publickey,gssapi-with-mic,password)。\r\n", "unreachable": true}

标签: ansible

解决方案


推荐阅读