GROG.user
用户
一个用于管理用户的角色。
以下角色设计用来与此角色紧密协作:
- authorized-key,用于管理授权密钥。
- sudo,用于管理sudo权限。
management-user 角色将所有这些角色组合在一个易于使用的角色中。
要求
- 主机应已为 Ansible 使用准备好(必须安装 Python 等)。
- 需要管理员权限,例如
become: yes
。 - 主机上应可用
useradd
、userdel
和usermod
。
角色变量
变量 | 描述 | 默认值 |
---|---|---|
user_list |
用户列表 (见详细信息!) | [] |
user_list_host |
用户列表 (见详细信息!) | [] |
user_list_group |
用户列表 (见详细信息!) | [] |
user_append |
append 的默认值 |
no |
user_createhome |
createhome 的默认值 |
yes |
user_force |
force 的默认值 |
no |
user_generate_ssh_key |
generate_ssh_key 的默认值 |
no |
user_move_home |
move_home 的默认值 |
no |
user_none_unique |
none_unique 的默认值 |
no |
user_remove |
remove 的默认值 |
no |
user_shell |
shell 的默认值 |
'/bin/sh' |
user_ssh_key_bits |
ssh_key_bits 的默认值 |
4096 |
user_ssh_key_file |
ssh_key_file 的默认值 |
'.ssh/id_rsa' |
user_system |
system 的默认值 |
no |
user_update_password |
update_password 的默认值 |
always |
user_list
详细信息
user_list
、user_list_host
和 user_list_group
在管理用户时会合并。您可以使用主机和组列表来指定每个主机或主机组的用户。
用户列表允许您定义必须管理的用户。列表中的每一项可以具有以下属性:
变量 | 描述 | 是否必需 | 默认值 |
---|---|---|---|
append |
仅将用户添加到组中? | no | user_append |
comment |
用户描述(即 GECOS) | no | / |
createhome |
创建家目录? | no | user_createhome |
expires |
过期日期 | no | / |
force |
删除用户时使用 --force 选项 | no | user_force |
generate_ssh_key |
生成 SSH 密钥? | no | user_generate_ssh_key |
group |
用户的主组 | no | / |
groups |
用户的组列表 | no | / |
home |
用户的家目录 | no | / |
login_class |
BSD 系统的登录类 | no | / |
move_home |
移动家目录 | no | user_move_home |
name |
用户名 | yes | / |
non_unique |
允许非唯一 UID | no | user_none_unique |
password |
用户密码 | no | / |
remove |
删除用户时使用 --remove 选项 | no | user_remove |
shell |
用户的 shell | no | user_shell |
ssh_key_bits |
SSH 密钥大小 | no | user_ssh_key_bits |
ssh_key_comment |
SSH 密钥注释 | no | / |
ssh_key_file |
SSH 密钥文件 | no | user_ssh_key_file |
ssh_key_passphrase |
SSH 密钥密码短语 | no | / |
ssh_key_type |
SSH 密钥类型 | no | rsa |
state |
用户状态 | no | 'present' |
system |
系统帐户? | no | user_system |
uid |
用户 ID | no | / |
update_password |
如果更改则更新密码? | no | user_update_password |
示例 user_list
user_list:
- name: user1
- name: user2
uid: 1001
groups:
- test
- sudo
- name: user3
uid: 1002
state: absent
依赖
无。
示例剧本
---
- hosts: servers
roles:
- { role: GROG.user, become: yes }
在 group_vars/servers.yml
中:
user_list_group:
- name: user
uid: 1001
- name: test
state: absent
贡献
欢迎所有帮助、修改或想法 欢迎!
作者
作者 G. Roggemans
许可证
MIT