Coder Social home page Coder Social logo

Comments (4)

dutchshark avatar dutchshark commented on June 2, 2024

Hello @nkhambal,

Did you resolve this problem already?
Please look at the Nokia MD-CLI playbook example

The syntax your using isn't the same as in the Nokia MD-CLI sample as linked above your using:
cli_command:
command: configure private

vs the sample:
cli_config:
config: |
configure private

from ansible-networking-collections.

wisotzky avatar wisotzky commented on June 2, 2024

@nkhambal, the cli_config should take care about changing into configuration mode and to finally commit the change. It must not be manually to ensure function.

from ansible-networking-collections.

nkhambal avatar nkhambal commented on June 2, 2024

Following playbook worked with one exception of "commit" tag. It commits even when it is set to "No". Is there an option to perform a commit "validate" and then "rollback" without actually committing the configuration?

---
- name: Configure Nokia.
  hosts: nokia-hosts
  serial: 1
  vars:
    - ansible_network_os: nokia.sros.md
    - ansible_user: "{{ SSH_USER }}"
    - ansible_password: "{{ SSH_PASSWORD }}"
    - ansible_command_timeout: 60
    - ansible_python_interpreter: "/Users/nileshkhambal/Documents/myansible/bin/python3"
  connection: network_cli
  gather_facts: No

  collections:
  - nokia.sros

  vars_files:
  - prod-tacacs-vault.yaml

  tasks:
  - name: Apply Configuration from File
    cli_config:
      config: "{{ lookup('file', devfilename)}}"
      commit: No
    vars:
      devfilename: "{{ inventory_hostname }}.set"
    register: configResult

  - name: Print Results
    debug:
      msg: "{{ configResult.diff.split('\n') }}"

from ansible-networking-collections.

nkhambal avatar nkhambal commented on June 2, 2024

Replying the answer to my own query. To skip commit and discard candidate after validate, use "commit: False". Default is "commit: True". Following playbook worked. It fetches the template and generates the configuration (deleting mpls lsp configuration in this case) and pushes it via cli_config. Does compare, validate and then discards the configuration providing the diff.

NOTE: make sure you use "delete configure router" and not just "delete router" in the template. Later works with "configure private" but not "edit-config private" which is what the module uses to configure the device.

---
- name: Configure Nokia.
  hosts: nokia-hosts
  serial: 1
  vars:
    - ansible_network_os: nokia.sros.md
    - ansible_user: "{{ SSH_USER }}"
    - ansible_password: "{{ SSH_PASSWORD }}"
    - ansible_command_timeout: 60
    - ansible_python_interpreter: "/Users/nileshkhambal/Documents/myansible/bin/python3"
    - remoteLsr: "{{ egress_lsr }}"
  connection: network_cli
  gather_facts: No

  collections:
  - nokia.sros

  vars_files:
  - prod-tacacs-vault.yaml

  tasks:
  - name: Apply Configuration from File
    cli_config:
      config: "{{ lookup('template', './delete_nokia_lsps_template.j2')}}"
      commit: False
    vars:
      ingressLsr: "{{ inventory_hostname| upper }}"
      egressLsr: "{{ remoteLsr| upper }}"
    register: configResult

  - name: Print Results
    debug:
      msg: "{{ configResult.diff.split('\n') }}"

from ansible-networking-collections.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.