Ansible: Creating multiple user, Generating Password(sha512), expiring password(force user to change)

  - name: multiple
      name: "{{ }}"
      shell: /bin/bash
      createhome: yes
      password: "{{ item.password | password_hash('sha512') }}"
      comment: "{{ item.comment }}"
      state: present
      update_password: on_create
    register: changes
     - { name: testuser1, password: testuser1@123, comment: "test user1" }
     - { name: testuser2, password: testuser2@123, comment: "test user2" }

  - name: Expire password
    shell: chage -d 0 {{ }}
    with_items: "{{ changes.results }}"
    when: "{{ item.changed == true }}"


Share this Story:
  • facebook
  • twitter
  • gplus

About bentech4u


  1. Typicalcat95
    1603 days ago

    Thanx for a very interesting site. Where else could I get that type of information written in such an ideal method? I’ve a undertaking that I’m just now running on, and I have been on the look out for such info.

Leave a comment