Ansible: Create a new user account and password using vars_promt

It will asks for the username and password for a new account right after you run the ansible playbook.

Ansible hosts.yaml

- hosts: hasnan1x
  roles:
    - common

  vars_prompt:
  - name: "group_account"
    prompt: "Enter a new account for the group"
    private: no

  - name: "group_password"
    prompt: "Enter a new password for the group"
    private: yes
    encrypt: "md5_crypt" #need to have python-passlib installed in local machine before we can use it
    confirm: yes
    salt_size: 7

Place this somewhere in your task in "common" roles.

- name: create new group account
  user: name={{group_account}} password={{group_password}}
  tags: group-pass

Test

ansible-playbook -i hosts sites.yaml -u root --ask-pass --tags group-pass

8 thoughts on “Ansible: Create a new user account and password using vars_promt

  1. This will go to the activation page where you will need to fill in the fields with your credit card number, security code (three digits), and the last four digits of your Social Security number. When you’re done, simply click the blue “Activate My Card” button to complete the process. https://oldnevycomactivate.info/

  2. The growth and standing of Kohls Feedback divisions may be attributed to their customer-focused approach and their goal of providing best-in-class results at competitive prices. Local Kohler retailers sell a variety of goods, including jewelry, toys, clothes, and entertainment. https://kolsfeedbackcom.info/

Leave a Reply

Your email address will not be published. Required fields are marked *