ansiblejuniperjunos-automation

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


I am completely new to Ansible and cannot find much documentation regarding changing the root password of a Juniper device. What is the framework to do something like this?

This is what I have so far but I am not confident it is correct.

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

Solution

  • There is a good introduction regarding Understanding the Ansible for Junos OS Collections, Roles, and Modules with references to the Ansible Collection Junipernetworks.Junos.

    As already mentioned in a comment, modules for certain tasks are available including 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