Inventory
[linux]
ubs1
ubs2
ubs3
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.25 ubs1
192.168.1.26 ubs2
192.168.1.27 ubs3
There are predefined linux servers hostnames, these hostnames have to be within the /etc/ansible/hosts
in order to execute the yaml.
Yaml for creating user
--- # start of YAML file - hosts: linux # ubs1,ubs2,ubs3 defined in /etc/ansible/hosts become: true # required privilege escalation become_user: root # escalated to root, i.e. sudo tasks: - name: create user # name for this task user: # user module see https://docs.ansible.com/ansible/latest/modules/user_module.html name: unixadm # username to be created. group: sudo # join this user to sudo group shell: /bin/bash # allow unixadm to use /bin/bash password: $6$jhdI.QNeBQQd5YLI$L1nUAC0utehr.kHzaurps5a1i.y5k4.LQ9bo/WjE8O0DSaHnUy/H9wyKwmzla/Ijc/02SUvWTypt4KsQCdZ9C. # Use https://www.mkpasswd.net/index.php to generate hash password state: present # present means i want username to exist, hence creating a user. ... # end of YAML file
I used an online mkpasswd to generate the hash for a password.
Result