判断添加用户
- hosts: all
vars:
- username: test1
tasks:
- name: detect whether the user exists
shell:
id {{ username }}
register: result
ignore_errors: true
- name: debug
debug:
msg: "{{ username }} exsist,nothing to do"
when: result.rc == 0
- name: user add {{ username }}
user:
name: "{{ username }}"
state: present
when: result.rc != 0
遗留问题,如何通知判断添加多个用户
标签:语句,username,判断,name,示例,when,result,user From: https://www.cnblogs.com/wangend/p/17064314.html