Juniper save configuration

713 views
Skip to first unread message

texas living

unread,
Jun 6, 2018, 9:05:35 AM6/6/18
to Junos Python EZ
Does anyone have an example task to save a Juniper SRX configuration with a specific name? I use Juniper.junos role version 2.1.0 and tried juniper_junos_config, but cannot get it to take the save command. Currently, I use the Expect module to save the config, but would like to use some Juniper module.

Nitin Kr (India)

unread,
Jun 6, 2018, 9:16:12 AM6/6/18
to texas living, Junos Python EZ
Hi,

Can you please share your task?

Thanks
Nitin Kr

Sent from mobile, please excuse my brevity

On Jun 6, 2018 18:35, texas living <adolp...@gmail.com> wrote:
Does anyone have an example task to save a Juniper SRX configuration with a specific name? I use Juniper.junos role version 2.1.0 and tried juniper_junos_config, but cannot get it to take the save command. Currently, I use the Expect module to save the config, but would like to use some Juniper module.

--
You received this message because you are subscribed to the Google Groups "Junos Python EZ" group.
To unsubscribe from this group and stop receiving emails from it, send an email to junos-python-...@googlegroups.com.
Visit this group at https://groups.google.com/group/junos-python-ez.
To view this discussion on the web visit https://groups.google.com/d/msgid/junos-python-ez/5c136b48-a449-4a96-b7be-d8b6f0dfa33f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

texas living

unread,
Jun 6, 2018, 9:40:52 AM6/6/18
to Junos Python EZ

Here is my expect module task:

- name: "Save Pre Base Configuration"

  expect:
    command
: "ssh
{{user}}@{{IP_Address}}"
    echo: no
    timeout
: "{{timer_license}}"
    responses
:

       
### ssh known_hosts check
       
'Are you sure you want to continue connecting.*':
       
- "yes"

       
### Initial login password
       
'Password:':
       
- "{{ passwd }}"

       
### Go into configure mode
       
'\@.*> $':
       
- "configure private"
       
- exit

       
### Commands to run inside configure mode
       
'\@.*# $':
       
- save {{Hostname}}_base_configuration
       
- exit

       
### Answer yes for any yes/no prompts
       
'yes\,no.*':
       
- yes


 

texas living

unread,
Jun 6, 2018, 7:46:12 PM6/6/18
to Junos Python EZ
To clarify, I want to save the config with specific name on the vSRX device, not the local ansible server. 

Nitin Kr (India)

unread,
Jun 8, 2018, 8:19:00 AM6/8/18
to texas living, Junos Python EZ

Hi,

 

You can use the module which is being written (part of pull request as of now)

https://github.com/Juniper/ansible-junos-stdlib/pull/370

 

Thanks

Nitin Kr

--

You received this message because you are subscribed to the Google Groups "Junos Python EZ" group.
To unsubscribe from this group and stop receiving emails from it, send an email to junos-python-...@googlegroups.com.
Visit this group at https://groups.google.com/group/junos-python-ez.

texas living

unread,
Jun 11, 2018, 4:25:46 PM6/11/18
to Junos Python EZ
I found the solution in the juniper_junos_rpc module.
 
- name: "Save Pre Base Configuration"

  juniper_junos_rpc
:
    host
: "{{hostname}}"
    user
: "{{user}}"
    passwd
: "{{ password }}"
    port
: 22
    rpc
: 'request-shell-execute'
    kwarg
:
      command
: 'cli -c "show configuration | save {{Hostname}}_base_configuration"'


 
Reply all
Reply to author
Forward
0 new messages