jumpserver/apps/accounts/automations/change_secret/host/windows/main.yml

27 lines
746 B
YAML
Raw Normal View History

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:
2022-10-09 12:54:11 +00:00
name: "{{ account.username }}"
2022-10-14 08:33:24 +00:00
password: "{{ account.secret }}"
2022-10-09 12:54:11 +00:00
update_password: always
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"