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

31 lines
779 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:
- name: ping
ping:
#- name: print variables
# debug:
# msg: "Username: {{ account.username }}, Password: {{ account.password }}"
- name: Change password
user:
name: "{{ account.username }}"
password: "{{ account.password | password_hash('des') }}"
update_password: always
when: account.password
- name: Change public key
authorized_key:
user: "{{ account.username }}"
key: "{{ account.public_key }}"
state: present
when: account.public_key
- name: Verify password
ping:
vars:
ansible_user: "{{ account.username }}"
ansible_pass: "{{ account.password }}"
ansible_ssh_connection: paramiko