Creating a new user and password with Ansible

后端 未结 22 1513
迷失自我
迷失自我 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:29

    Neither of the solutions worked directly on my Mac controlling Ubuntu. So for others' sake, combining Mxx and JoelB answers, here is the current Python 3 solution:

    pip3 install passlib
    
    python3 -c 'from passlib.hash import md5_crypt; \
          print(md5_crypt.encrypt("This is my Password", salt="SomeSalt"))'
    

    The result will be $1$SomeSalt$UqddPX3r4kH3UL5jq5/ZI., as in Mxx' answer.

    Better still, use SHA512 instead of MD5:

    python3 -c 'from passlib.hash import sha512_crypt; \
          print(sha512_crypt.encrypt("This is my Password", salt="SomeSalt"))' 
    

    Result:

    $6$rounds=656000$SomeSalt$oYpmnpZahIsvn5FK8g4bDFEAmGpEN114Fe6Ko4HvinzFaz5Rq2UXQxoJZ9ZQyQoi9zaBo3gBH/FEAov3FHv48

提交回复
热议问题