【发布时间】:2017-11-08 11:03:42
【问题描述】:
我有一个 Ansible 任务,可确保创建用户列表 (dict) 并在需要时创建它们。
我希望此任务不要更新密码(仅限 on_creation),除非我将全局变量 enforce_config 设置为 true。在这种情况下,我希望所有托管用户都能使用默认密码更新密码(存储在我的用户字典中)。
简而言之,我想根据enforce_config 变量的值更改此user 模块选项:
update_password: on_create
进入:
update_password: always
这是完整的任务:
- name: Manage users and their password
user:
name: "{{ item.key }}"
home: "{{ item.value.home }}"
createhome: yes
shell: "{{ item.value.shell }}"
password: "{{ item.value.password }}"
# IF `enforce_config` == true
# update_password: always
# ELSE
update_password: on_create
with_dict: "{{ users }}"
【问题讨论】:
标签: ansible