IT袋

当前位置:主页 > 经验教程 > 系统教程 >

Ansible如何创建用户

Ansible如何创建用户?(2)

时间:2023-09-17 20:12:56 来源:IT袋 作者:苏晓敏
导读:Ansible如何创建用户,说明:在 Password 后输入我们的密码xxxxx,然后再按enter键 python -c 'from passlib.hash import sha512_crypt; import getpass; print (sha512_crypt.encrypt(getpass.getpass()))' PS F:\各组

Ansible如何创建用户

说明:在 Password 后输入我们的密码”xxxxx”,然后再按enter键

 python -c 'from passlib.hash import sha512_crypt; import getpass; print (sha512_crypt.encrypt(getpass.getpass()))'
PS F:\各组件相关说明\ansible相关> pip  install  passlib
Collecting passlib
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3b/a4/ab6b7589382ca3df236e03faa71deac88cae040af60c071a78d254a62172/passlib-1.7.4-py2.py3-none-any.whl (525 kB)      
     |████████████████████████████████| 525 kB 1.3 MB/s 
Installing collected packages: passlib
Successfully installed passlib-1.7.4
WARNING: You are using pip version 20.2.4; however, version 20.3.3 is available.
You should consider upgrading via the 'c:\users\administrator\appdata\local\programs\python\python37\python.exe -m pip install --upgrade pip' command.
PS F:\各组件相关说明\ansible相关> python -c 'from  passlib.hash  import sha512_crypt;  import  getpass;  print (sha512_crypt.encrypt(getpass.getpass()))'
Password:
-c:1: DeprecationWarning: the method passlib.handlers.sha2_crypt.sha512_crypt.encrypt() is deprecated as of Passlib 1.7, and will be removed in Passlib 2.0, use .hash() instead.
$6$rounds=656000$fkskseDMlRAr7..8$./zCF2UbGiO7RrtyILeIckqK1ZU78wVwhWFeSrh2Qki604dG3apeF7BCwynu1HcnBp1g.LaFmZsjRCzJYjvzp/
  1. 创建带加密码bunian用户
[root@localhost ansible]# ansible redis -m user -a 'name=bunian shell=/bin/bash password=$6$rounds=656000$fkskseDMlRAr7..8$./zCF2UbGiO7RrtyILeIckqK1ZU78wVwhWFeSrh2Qki604dG3apeF7BCwynu1HcnBp1g.LaFmZsjRCzJYjvzp/ update_password=always'
docker125 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "comment": "", 
    "create_home": true, 
    "group": 1001, 
    "home": "/home/bunian", 
    "name": "bunian", 
    "password": "NOT_LOGGING_PASSWORD", 
    "shell": "/bin/bash", 
    "state": "present", 
    "system": false, 
    "uid": 1001
}
docker124 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "comment": "", 
    "create_home": true, 
    "group": 1001, 
    "home": "/home/bunian", 
    "name": "bunian", 
    "password": "NOT_LOGGING_PASSWORD", 
    "shell": "/bin/bash", 
    "state": "present", 
    "system": false, 
    "uid": 1001
}
docker123 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "comment": "", 
    "create_home": true, 
    "group": 1001, 
    "home": "/home/bunian", 
    "name": "bunian", 
    "password": "NOT_LOGGING_PASSWORD", 
    "shell": "/bin/bash", 
    "state": "present", 
    "system": false, 
    "uid": 1001
}

验证

[root@33a870725069 home]# ll
total 0
drwx------ 2 bunian1 bunian1 62 Apr 11  2018 bunian1
drwx------ 2 bunian      bunian      62 Dec 23 07:29 bunian
[root@33a870725069 home]# su bunian1
[bunian1@33a870725069 home]$ su bunian
Password: 
[bunian@33a870725069 home]$ 

上述就是Ansible如何创建用户?的电脑IT小方法,供您全面了解参考!

相关阅读

  • 微软windows10下载 微软win10专业版下载地址

    微软windows10下载 微软win10专业版下载地址

    这些知识你了解吗?微软win10专业版下载地址的IT小经验,关于微软windows10下载 微软win10专业版下载地址,下面来一起了解一下吧。 微软win10专业版系统以其稳定性和良好的兼容性一直深受大家

  • win10锁屏密码怎么设置 win10系统怎么设置锁屏密码

    win10锁屏密码怎么设置 win10系统怎么设置锁屏密码

    IT袋网小编为你介绍win10锁屏密码怎么设置的电脑小知识,win10设置锁屏密码一共有三步,需要在账户中进行设置,以下是具体的操作步骤:

  • win7如何查看隐藏文件 win7如何查看隐藏文件?

    win7如何查看隐藏文件 win7如何查看隐藏文件?

    为大家介绍win7如何查看隐藏文件方面的内容,关于win7如何查看隐藏文件 win7如何查看隐藏文件?,接下来小编为网友介绍。 win7系统是不可错过的优秀系统。最近很多的win7系统用户们都在问为什

  • win11键盘设置教程 win11轻松使用键盘默认设置

    win11键盘设置教程 win11轻松使用键盘默认设置

    今天分享:win11键盘设置教程的相关知识,关于win11键盘设置教程 ,下面为详细的介绍。 键盘是我们在使用电脑时非常重要的外部设备,但是在最新的win11系统中,用户难免会遇到一些键盘相关