我正在尝试在Ubuntu20.04上使用ansible创建用户帐户。但是得到了错误:
msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1但同样的剧本在Ubuntu 18.04上运行得很好。下面是我的攻略:
- hosts: abc
remote_user: root
become: true
tasks:
- name: create user account admin with password xyz
user:
name: admin
group: admin
shell: /bin/bash
password: $6$pLkiHBvZOf9/zctp1SlLXC2PsTFfwwcwmE73wuwwXb2g8.
append: yes
- name: ceating .ssh directory for account admin
file:
path: /home/admin/.ssh
state: directory
group: admin
owner: admin
mode: 0755
- name: copy authorized_keys file from root
copy:
src: /root/.ssh/authorized_keys
dest: /home/admin/.ssh
remote_src: yes
group: admin
owner: admin
- name: change the ssh port
lineinfile:
path: /etc/ssh/sshd_config
state: present
insertafter: '#Port 22'
line: "Port 811"
backup: yes
- name: disable the root login
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^PermitRootLogin yes'
line: 'PermitRootLogin no'
- name: Restart ssh
service: name=ssh state=restarted你能告诉我错误的原因是什么吗?
谢谢你
发布于 2020-05-02 13:51:23
您通常可以通过捕获错误并发出错误来从ansible获取更多信息:
- name: create user account admin with password xyz
user:
name: admin
group: admin
shell: /bin/bash
password: $6$pLkiHBvZOf9/zctp1SlLXC2PsTFfwwcwmE73wuwwXb2g8.
append: yes
ignore_errors: yes
register: kaboom
- debug: var=kaboom
- fail: msg=yup您还可以通过使用env ANSIBLE_DEBUG=1 ansible-playbook -vvvv运行ansible来获得最多的信息,尽管通常情况下,额外的冗长仍然不足以使其显示出实际的异常文本,所以首先尝试使用register:技巧
https://stackoverflow.com/questions/61554310
复制相似问题