Automation

Expand all | Collapse all

Op Script from URL fails when running as event-option

Jump to Best Answer
  • 1.  Op Script from URL fails when running as event-option

    Posted 11-18-2019 12:16

    We have a script we can run manually by calling the "op url exampleurl.py". It downloads from Github and processes the script without issue. When we put this script into an event-option we recieve the following error in the op script logs:

     

    Nov 18 17:33:34: Traceback (most recent call last): 
    Nov 18 17:33:34:   File "/var/db/scripts/event/script.py", line 390, in
    Nov 18 17:33:34: main()
    Nov 18 17:33:34:   File "/var/db/scripts/event/script.py", line 375, in main
    Nov 18 17:33:34: dev.open()
    Nov 18 17:33:34:   File "../../../../../../../src/dist/python-add-ons/junos-eznc/lib/jnpr/junos/device.py", line 1237, in open
    Nov 18 17:33:34: jnpr.junos.exception
    Nov 18 17:33:34: .
    Nov 18 17:33:34: ConnectError
    Nov 18 17:33:34: : 
    Nov 18 17:33:34: ConnectError(host: None, msg: user "nobody" does not have access privileges.)
    Nov 18 17:33:34 event script failed: /var/db/scripts/event/script.py

     

    The event option syntax we are using is the following:

    generate-event {
    RUNSCRIPT time-interval 300;
    }
    policy Script {
    events RUNSCRIPT;
    then {
    execute-commands {
    commands {
    "op url someurl@script.py";">https://someurl@script.py";
    }
    user-name user1;
    }
    }
    }

     

    If we manually download the script and run it as an event-option event-script and specifically write in the configuration to run the event-script as a certain user then it works just fine. We are trying to however be able to run this script from the URL with the event-option method so we can update the script without the need to download it back to the device.

     

    The issue appears to be with the way the op script is called where it runs as a generic user and group nobody when it's run as an event-policy action.

     

    Has anyone had any luck with calling a script that way in an event-option or possibly a work around to get this to work that way?  



  • 2.  RE: Op Script from URL fails when running as event-option
    Best Answer

    Posted 11-18-2019 13:23

    No idea what type of code in your script but might be related on this > https://prsearch.juniper.net/InfoCenter/index?page=prcontent&id=PR1445917 ?