如何使用 Ansible 更改 junos 设备根密码?

How do you change a junos device root password with Ansible?

我是 Ansible 的新手,找不到很多关于更改 Juniper 设备的根密码的文档。做这样的事情的框架是什么?

这是我目前所知道的,但我不确定它是否正确。

---
- vars: 
  newPassword: "{{ newPassword }}"
- hosts: all
  gather_facts: no
  tasks:
  - name: Update Root user's Password
    user: 
     name: root
     update_password: always 
     password: newPassword

关于Understanding the Ansible for Junos OS Collections, Roles, and Modules with references to the Ansible Collection Junipernetworks.Junos有一个很好的介绍。

如评论中所述,某些任务的模块可用,包括 Manage local user accounts on Juniper JUNOS devices

- name: Set user password
  junipernetworks.junos.junos_user:
    name: ansible
    role: super-user
    encrypted_password: "{{ 'my-password' | password_hash('sha512') }}"
    state: present