Dec.03

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

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

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

 



Share this Story:
  • facebook
  • twitter
  • gplus

About bentech4u

Comments(1)

  1. Typicalcat95
    1792 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