如何解决下面运行 ansible 角色的问题?如果远程服务器上不存在用户,ansible 会收到错误消息“无法查找用户 test1:'getpwnam(): name not found: test1”。我需要在多台服务器上管理多个用户。谢谢
vars:
user_list:
- user: test1
state: present
path: /usr/local/test1/.ssh/authoried_keys
keys:
- "ssh-rsa test1"
- user: test2
state: absent
path: /home/test2/.ssh/authoried_keys
keys:
- "ssh-rsa test2"
tasks:
- name: Manage SSH-keys
authorized_key:
user: "{{ item.0.user }}"
key: "{{ item.1 }}"
path: "{{ item.0.path }}"
state: "{{ item.0.state }}"
with_subelements:
- '{{ user_list }}'
- keys
CentOS Linux 7、Ansible 2.4.2.0