jumpserver/apps/accounts/automations/verify_account/host/posix/main.yml
fit2bot ef2b7b464e
perf: ansible 用户切换至 (#11766)
Co-authored-by: feng <1304903146@qq.com>
2023-10-09 14:35:21 +08:00

24 lines
978 B
YAML

- hosts: demo
gather_facts: no
tasks:
- name: Verify account connectivity(Do not switch)
ansible.builtin.ping:
vars:
ansible_become: no
ansible_user: "{{ account.username }}"
ansible_password: "{{ account.secret }}"
ansible_ssh_private_key_file: "{{ account.private_key_path }}"
when: not account.become.ansible_become
- name: Verify account connectivity(Switch)
ansible.builtin.ping:
vars:
ansible_become: yes
ansible_user: "{{ account.become.ansible_user }}"
ansible_password: "{{ account.become.ansible_password }}"
ansible_ssh_private_key_file: "{{ account.become.ansible_ssh_private_key_file }}"
ansible_become_method: "{{ account.become.ansible_become_method }}"
ansible_become_user: "{{ account.become.ansible_become_user }}"
ansible_become_password: "{{ account.become.ansible_become_password }}"
when: account.become.ansible_become