[j-nsp] Ansible juniper_junos -add license module?

Stacy W. Smith stacy at acm.org
Wed Mar 28 12:38:25 EDT 2018


Thanks Phil! 
I knew there was an RPC for this, but hadn’t had the chance to figure it out.

Adam,
Given the info from Phil, you can use a playbook similar to this:

---
- name: 'Add a license to a Junos device'
  hosts: junos-all
  connection: local
  gather_facts: no
  roles:
    - Juniper.junos

  tasks:
    - name: 'Add a license'
      juniper_junos_rpc:
        rpc: 'request-license-add'
        kwarg:
          key_data: ‘<add your license data here>'


Alternatively, you can load the license from a file or URL with:

---
- name: 'Add a license to a Junos device'
  hosts: junos-all
  connection: local
  gather_facts: no
  roles:
    - Juniper.junos

  tasks:
    - name: 'Add a license'
      juniper_junos_rpc:
        rpc: 'request-license-add'
        kwarg:
          source: ‘<URL to a file containing the license data>'


You can also refer to the documentation here: http://junos-ansible-modules.readthedocs.io/en/2.0.2/juniper_junos_rpc.html <http://junos-ansible-modules.readthedocs.io/en/2.0.2/juniper_junos_rpc.html>

> On Mar 28, 2018, at 3:28 AM, adamv0025 at netconsultings.com wrote:
>  I could not find any juniper_junos module for amnesiac mode. (all the modules
> kind of assume working ssh and netconf).


The modules do have limited support for initial device configuration if you have a direct serial connection from the Ansible control machine to the Juniper device’s serial console or if you have the serial console connected to a terminal server which is reachable via an unauthenticated Telnet port. (If the console server is only reachable over SSH or adds additional authentication, that’s not currently supported.)

Performing NETCONF operations over the serial console is sometimes problematic because the NETCONF gets interspersed with any console logging. There’s not currently a way to disable this, so the best bet is to simply repeat any failed NETCONF operations over the serial console.

—Stacy



> On Mar 28, 2018, at 8:45 AM, Phil Shafer <phil at juniper.net> wrote:
> 
> adamv0025 at netconsultings.com writes:
>> The problem is I need to hit enter after the license is passed and then also
>> ^D (ctrl+D) at the end and I'm not sure how would I go about doing that in
>> junos_command. 
> 
> Not sure why these aren't documented but the functionality is there.
> Here's the JUNOS DDL (think "YANG"):
> 
>            command add-license {
>                help "Add license keys from file, local or from server";
>                action acceptable mgd mgd_is_product_licensed;
>                action execute mgd mgd_add_license_mgd;
>                xml-name request-license-add;
>                odl-tag add-license-results;
>                argument source {
>                    help "URL of source license key file";
>                    type string;
>                }
>                argument key-data {
>                    help "License key data";
>                    type string;
>                }
>            }
>            command save-license {
>                help "Save license keys to file, local or to server";
>                action acceptable mgd mgd_is_product_licensed;
>                xml-name request-license-save;
>                odl-tag none;
>                action execute mgd mgd_save_license_mgd;
>                argument destination {
>                    help "URL of destination license key file";
>                    type string;
>                }
>            }
> 
> The "xml-name" statement gives the name of the RPC used to access
> this command, which means the <request-license-add> RPC adds a
> license from either a <source> URL or a <key-data> string, and the
> <request-license-save> exports license data to a <destination> URL.
> 
> In SLAX, that looks something like:
> 
>    var $rpc = <request-license-add> {
>        <key-data> $my-data;
>    }
> 
> Thanks,
> Phil
> _______________________________________________
> juniper-nsp mailing list juniper-nsp at puck.nether.net
> https://puck.nether.net/mailman/listinfo/juniper-nsp



More information about the juniper-nsp mailing list