- 创建用户组,并记录组 ID
- 创建用户,填写所需组 ID
- 是否需要为用户增加 ssh-key,是: 增加 ssh-contens
- 将用户添加到组内,组名与用户名称
- 添加 sudo 规则组
- 删除用户
- 删除组
- 删除组内用户
-
增加用户
- ansible-playbook 07-addaccount.yml --tags 'create_user' --extra-vars '@create_user.json'
-
增加组
- ansible-playbook 07-addaccount.yml --tags 'create_group' --extra-vars '@create_group.json'
-
增加sudo 规则
- ansible-playbook 07-addaccount.yml --tags 'add_sudoroles' --extra-vars '@add_sudoroles.json'
-
增加用户到组
- ansible-playbook 07-addaccount.yml --tags 'exist_group' --extra-vars '@exist_group.json'
-
增加用户 ssh-key 属性
- ansible-playbook 07-addaccount.yml --tags 'add_sshkey' --extra-vars '@add_sshkey.json'
-
删除用户
- ansible-playbook 07-addaccount.yml --tags 'remove_user' --extra-vars '@remove_user.json'
-
删除组
- ansible-playbook 07-addaccount.yml --tags 'remove_group' --extra-vars '@remove_group.json'
-
删除组内成员
- ansible-playbook 07-addaccount.yml --tags 'remove_user_from_group' --extra-vars '@remove_user_from_group.json'
create_user.json
{
"user_name": ["lyl_test"],
"user_passwd": "1qazxsw2",
"user_id": "150",
"group_id": "501",
"comment": "userid 在创建的时候需要配置不同的开头 ID, gid 需要配置不同的组 id 从创建组时指定 jqbkj_manager=150, jqbkj_dev_team-leader=151,jqbkj_operations=152, jqbkj_dev=153, jqbkj_test=154"
}
create_group.json
{
"ou_name": "jenkins",
"create_type": "cn",
"group_name": "Linux_users",
"level": "1",
"group_id": 504
}
add_sudoroles
{
"group_name": "test"
}
exist_group.json
{
"ou_name": "jenkins",
"group_name": "jenkins-users",
"user_name": ["test"],
"level": "2"
}
add_sshkey.json
{
"user_name": "test2",
"key_conents": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLtUWPMLPIgMTsgLL9ee1TXkqNjeK0yWwQpnj7b7Z1jcpck+DNzeR/qPM9r/t66UuBa8zxudxVPgZV6YfvsOGHM0NpAbVGBGMOj7MSzqeUyvd8vbkS/lZ+uxYmPz22gcVnT406PPqPimixu2I6YoFN/B4Qkt0gszThv7rYKgZGiQG8RenafQUOEf7CB+Oak4rMSQFjYJPeDghTmQXYlQlMhY5GT8bTot1NglHftOloN2dyYjcbZUVtH7KxI3LDXjGFtC77msmjBpJgAagVBhUzY9/VT2pL/VYXREDVzGejZ2TLJTcCidaP7lMin+99sBSpwH/5aL5FynsRUDfhAD1D [email protected]",
"add_sshkey": true
}
remove_user.json
{
"user_name": "username"
}
remove_group.json
{
"ou_name": "JQB_USERS",
"create_type": "cn",
"group_name": "Cash-Now_Group",
"level": "2"
}
remove_user_from_group.json
{
"ou_name": "jenkins",
"group_name": "Linux_Users",
"user_name": ["user1","user2"],
"level": "1"
}