无法执行服务重启,无法从非root用户复制文件

时间:2019-02-06 13:57:53

标签: ansible

---
  - hosts: all
    become_user: ansible
    become: yes
    become_method: sudo
    tasks:
      - name: Restart the sshd service
        service: name=sshd state=restarted

### sudoers file entry for user on host ####
ansible ALL=(ALL)   NOPASSWD:ALL


PLAY [all] ***************************************************************************

TASK [Gathering Facts] ***************************************************************
ok: [host2.domain.local]
ok: [host1.domain.local]

TASK [Restart the ssh service] *******************************************************
fatal: [host2.domain.local]: FAILED! => {"changed": false, "msg": "Unable to restart service sshd: Failed to restart sshd.service: Interactive authentication required.\n"}
fatal: [host1.domain.local]: FAILED! => {"changed": false, "msg": "Unable to restart service sshd: Failed to restart sshd.service: Interactive authentication required.\n"}
    to retry, use: --limit @/root/1stplay.retry

PLAY RECAP ***************************************************************************
host1.domain.local         : ok=1    changed=0    unreachable=0    failed=1   
host2.domain.local         : ok=1    changed=0    unreachable=0    failed=1   

1 个答案:

答案 0 :(得分:0)

删除行:

become_user: ansible

大概您以ansible身份登录到目标计算机,并希望成为root用户而不是root?如果未指定,则默认使用become_user根。