Automation

 View Only
last person joined: 15 hours ago 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  Configuration changes using "replace pattern" via Ansible

    Posted 07-16-2024 12:10

    Is there anyway to use Ansible to make configuration changes via the "replace pattern" command?  I want to use Ansible to make the same change to multiple devices, which is a simple "replace pattern" under a specific stanza.  Basically I want to change the IP for a syslog server, without changing all of the other parameters that are already defined in the configuration stanza.



  • 2.  RE: Configuration changes using "replace pattern" via Ansible

    Posted 07-16-2024 12:36

    Hi,
    You can use something like this:

    ansible junos_host -m junipernetworks.junos.junos_config -a '{"lines": ["replace pattern old.old.old.old with new.new.new.new"]}'

    But be careful: it will replace all occurrences of "old.old.old.old" with "new.new.new.new". If you enter "edit system syslog" first, it can be more precise.

    Best regards,
    Jacques G. Busnardo





  • 3.  RE: Configuration changes using "replace pattern" via Ansible

    Posted 07-16-2024 13:23

    I'm trying to accomplish this in a playbook using juniper_junos_config, but "replace" is not accepted as a "lines".

      tasks:
        - name: Run Juniper configuration commands.
          juniper_junos_config:
            timeout: 120
            load: set
            format: text
            config_mode: exclusive
            comment: "Performed by Ansible Playbook replace-test.yml"
            commit: true
            lines:
              - edit system syslog
              - replace pattern x.x.x.x with y.y.y.y




  • 4.  RE: Configuration changes using "replace pattern" via Ansible

    Posted 07-16-2024 13:53

    Maybe this will help you:

    - name: Run Juniper configuration commands.
      junipernetworks.junos.junos_command:
        commands:
          - configure private
     - edit system syslog
     - replace pattern x.x.x.x with y.y.y.y
     - commit and-quit
     
    but change "exclusive" to "private" so it doesn't lock from the outside.

    Best regards,
    Jacques G. Busnardo