Code Monkey home page Code Monkey logo

Comments (2)

shermdog avatar shermdog commented on July 20, 2024

This functionality is not available in PyEZ and thus far hasn't been requested. Deferring this.

from ansible-junos-stdlib.

stacywsmith avatar stacywsmith commented on July 20, 2024

This is now possible via the new juniper_junos_config module implemented via #290.

The file on the Junos device is specified via the url option which allows any URL format accepted by the device, including a simple file path local to the device.

Given the following config file on the Junos device:

user@r0> file show /var/tmp/new_hostname.conf 
system {
  host-name r0.foo;
}

This playbook loads the config file:

---
- name: "Install from config file on Junos device"
  hosts: junos-all
  connection: local
  gather_facts: no
  roles:
    - Juniper.junos

  tasks:
    - name: "Install from config file on Junos device"
      juniper_junos_config:
        load: "merge"
        url: "/var/tmp/new_hostname.conf"
      register: response
    - name: Print response
      debug:
        var: response

Executing the playbook produces the following result:

user@h0:~$ ansible-playbook --limit r0 -k ./pb.test.yaml 
SSH password: 

PLAY [Install from config file on Junos device] ************************************************************************

TASK [Install from config file on Junos device] ************************************************************************
changed: [r0]

TASK [Print response] **************************************************************************************************
ok: [r0] => {
    "response": {
        "changed": true, 
        "diff": "\n[edit system]\n-  host-name r0;\n+  host-name r0.foo;\n", 
        "diff_lines": [
            "", 
            "[edit system]", 
            "-  host-name r0;", 
            "+  host-name r0.foo;"
        ], 
        "failed": false, 
        "msg": "Configuration has been: opened, loaded, checked, diffed, committed, closed."
    }
}

PLAY RECAP *************************************************************************************************************
r0                         : ok=2    changed=1    unreachable=0    failed=0   

from ansible-junos-stdlib.

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.