Automation

 View Only
last person joined: 6 days ago 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  Using ansible to change the root-auth password

    Posted 17 days ago

    I have been reading some docs on the Junipernetworks.junos collection, here is the section for the .junos_user module
    junipernetworks.junos.junos_user module - Manage local user accounts on Juniper JUNOS devices - Ansible Community Documentation

    I have this playbook

    ---
    - name: Change User Password
      hosts: test
      gather_facts: no
      connection: netconf

      vars_files:
        - ../Credentials/credentials.yml

      tasks:
        - name: Change User Password
          junipernetworks.junos.junos_user:
            name: NewUser
            role: super-user
            encrypted_password: "{{ 'test123' | password_hash('sha512') }}"
            state: present


    That playbook works perfectly fine,

    Im trying to figure out how to change the root user password

    I have tried this,

    ---
    - name: Change User Password
      hosts: test
      gather_facts: no
      connection: netconf

      vars_files:
        - ../Credentials/credentials.yml

      tasks:
        - name: Change User Password
          junipernetworks.junos.junos_user:
            name: root
            encrypted_password: "{{ 'test123' | password_hash('sha512') }}"
            state: present

    i keep getting this error:
    fatal: [test]: FAILED! => {
        "changed": false,
        "invocation": {
            "module_args": {
                "active": true,
                "aggregate": null,
                "encrypted_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "full_name": null,
                "name": "root",
                "purge": false,
                "role": null,
                "sshkey": null,
                "state": "present"
            }
        },


    I have been researching all day on a way to do this and every soultion i try gives me errors, any help would be greatly appreciated.



    ------------------------------
    JORDAN ATHERTON
    ------------------------------


  • 2.  RE: Using ansible to change the root-auth password

    Posted 16 days ago

    For root password changing, I use the  juniper_junos_config module and update the configuration with "set system root-authentication plain-text-password-value {{ new_pw }}".




  • 3.  RE: Using ansible to change the root-auth password

    Posted 16 days ago

    Thank you, shortly after posting this i did try this route and it worked. I apprechiate the fast reply.

    I will post the playbook that i have gotten working in case anyone in the future comes across the same issue

    ---
    - name: Change Password on Junos Device
      hosts: test
      gather_facts: no
      connection: netconf
    
      vars_files:
        - ../Credentials/credentials.yml
    
      vars:
        ansible_network_os: junos
        new_user_password: "{{ 'test123' | password_hash('sha512') }}"
        new_root_password: "{{ 'test123' | password_hash('sha512') }}"
    
      tasks:
        - name: Set a new password for the bptrooper user
          junipernetworks.junos.junos_user:
            name: NewUser
            role: super-user
            encrypted_password: "{{ new_user_password }}"
            state: present
    
        - name: Change the system root password
          junipernetworks.junos.junos_config:
            lines:
              - set system root-authentication encrypted-password "{{ new_root_password }}"
            confirm: 0
    


    ------------------------------
    JORDAN ATHERTON
    ------------------------------