如何修复Ansible中的“不正确的su密码”?

时间:2019-07-27 02:45:46

标签: ansible

使用Ansible,我试图将文件从一台主机复制到另一台主机。我使用synchronize模块并使用delegate_to完成此操作。但是,我相信这是我问题的根源。

- hosts: hosts       
  tasks:

  - name: Synchronization using rsync protocol (pull)
    synchronize:
      mode: pull
      src: /tmp/file.tar
      dest: /tmp
    delegate_to: 10.x.x.1
    become_user: root
    become_method: su
    become: yes

我的代码以获取root密码

- name: Set root password for host
  set_fact:
    ansible_become_password: password

我的包含主机的清单文件:

[hosts]
 10.x.x.2

现在我遇到以下错误:

  致命:[主持人]:失败! => {“ msg”:“ su密码不正确”}

剧本:

- name: Fetch root password for host from CA PAM
  shell: ./grabPassword.ksh
  args:
        chdir: /home/virgil
  register: password
  delegate_to: "{{ delegate_host }}"
  become_user: "{{ root_user }}"
  become_method: su


- debug:
    msg: "{{ password.stdout }}"


- name: Set root password for host
  set_fact:
    ansible_become_password: "{{ password.stdout }}"


- name: Copying tar file over (Never existed)
  synchronize: 
    src: /tmp/emcgrab_Linux_v4.8.3.tar 
    dest: /tmp
  delegate_to: "{{ delegate_host }}"
  register: test
  become: yes

0 个答案:

没有答案