Creating a new user and password with Ansible

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

    If you'd like to accomplish this as a Ansible ad-hoc command you can do the following:

    $ password='SomethingSecret!'
    $ ansible 192.168.1.10 -i some_inventory -b -m user -a "name=joe_user \
           update_password=always password=\"{{ \"$password\" | password_hash('sha512') }}\""
    

    Output from above command:

    192.168.1.10 | SUCCESS => {
        "append": false,
        "changed": true,
        "comment": "Joe User",
        "group": 999,
        "home": "/home/joe_user",
        "move_home": false,
        "name": "joe_user",
        "password": "NOT_LOGGING_PASSWORD",
        "shell": "/bin/bash",
        "state": "present",
        "uid": 999
    }
    

提交回复
热议问题