2022-10-09 12:54:11 +00:00
|
|
|
- hosts: demo
|
2022-10-10 05:56:42 +00:00
|
|
|
gather_facts: no
|
2022-10-09 12:54:11 +00:00
|
|
|
tasks:
|
2022-10-20 12:34:15 +00:00
|
|
|
- name: Test privileged account
|
2022-10-14 08:33:24 +00:00
|
|
|
ansible.windows.win_ping:
|
2022-10-09 12:54:11 +00:00
|
|
|
|
2022-10-14 08:33:24 +00:00
|
|
|
# - name: Print variables
|
|
|
|
# debug:
|
|
|
|
# msg: "Username: {{ account.username }}, Password: {{ account.secret }}"
|
2022-10-09 12:54:11 +00:00
|
|
|
|
|
|
|
- name: Change password
|
2022-10-14 08:33:24 +00:00
|
|
|
ansible.windows.win_user:
|
2023-07-04 09:34:31 +00:00
|
|
|
fullname: "{{ account.username}}"
|
2022-10-09 12:54:11 +00:00
|
|
|
name: "{{ account.username }}"
|
2022-10-14 08:33:24 +00:00
|
|
|
password: "{{ account.secret }}"
|
2023-07-04 09:34:31 +00:00
|
|
|
password_never_expires: yes
|
|
|
|
groups: "{{ params.groups }}"
|
2023-02-10 06:07:20 +00:00
|
|
|
groups_action: add
|
2022-10-09 12:54:11 +00:00
|
|
|
update_password: always
|
2023-05-19 08:09:32 +00:00
|
|
|
ignore_errors: true
|
2022-10-21 10:19:09 +00:00
|
|
|
when: account.secret_type == "password"
|
2022-10-09 12:54:11 +00:00
|
|
|
|
2022-10-14 08:33:24 +00:00
|
|
|
- name: Refresh connection
|
|
|
|
ansible.builtin.meta: reset_connection
|
2022-10-09 12:54:11 +00:00
|
|
|
|
|
|
|
- name: Verify password
|
2022-10-14 08:33:24 +00:00
|
|
|
ansible.windows.win_ping:
|
2022-10-09 12:54:11 +00:00
|
|
|
vars:
|
|
|
|
ansible_user: "{{ account.username }}"
|
2022-10-14 08:33:24 +00:00
|
|
|
ansible_password: "{{ account.secret }}"
|
2022-10-21 10:19:09 +00:00
|
|
|
when: account.secret_type == "password"
|