Creating a new user and password with Ansible

后端 未结 22 1399
迷失自我
迷失自我 2020-12-22 17:00

I have an ansible task which creates a new user on ubuntu 12.04;

- name: Add deployment user
    action: user name=deployer password=mypassword
22条回答
  •  隐瞒了意图╮
    2020-12-22 17:39

    Mxx's answer is correct but you the python crypt.crypt() method is not safe when different operating systems are involved (related to glibc hash algorithm used on your system.)

    For example, It won't work if your generate your hash from MacOS and run a playbook on linux. In such case , You can use passlib (pip install passlib to install locally).

    from passlib.hash import md5_crypt
    python -c 'import crypt; print md5_crypt.encrypt("This is my Password,salt="SomeSalt")'
    '$1$SomeSalt$UqddPX3r4kH3UL5jq5/ZI.'
    

提交回复
热议问题