Ansible Script

Ansible Script to create user with password

 ---
- name: Create User and Set Password
  hosts: server_ip
  user : username_to_connect_server
  become : yes
  tasks:
    - name: Create a user
      user:
        name: username
        state: present
        shell: /bin/bash
        home: /home/username

    - name: Set the password for the user
      become: yes
      command: echo "username:password" | chpasswd

أحدث أقدم