PaloAltoNetworks / panhandler

Panhandler is a tool to manage config snippets and Skillets for PAN-OS devices
Apache License 2.0
41 stars 19 forks source link

python skillet unable to run in panhandler dev #112

Closed scotchoaf closed 4 years ago

scotchoaf commented 4 years ago

Running the load baseline config added to HomeSkillet based on the code from panos_tools. skillet: https://github.com/scotchoaf/HomeSkillet/tree/90dev/HS_load_baseline_config

I can run the python code from the command line and works great. However when running in panhandler I get the error:

usage: load_baseline.py [-h] [-f TARGET_IP] [-u TARGET_USERNAME] [-p TARGET_PASSWORD] [-n FW_NAME] [-d1 DNS_1] [-d2 DNS_2] [-t MGMT_TYPE] [-m MGMT_MASK] [-dg MGMT_DG] load_baseline.py: error: unrecognized arguments: --repo_name=HomeSkillet_scotchoaf --url=https://github.com/scotchoaf/HomeSkillet.git --snippet_name=import_baseline_config_HomeSkillet

these arguments are not part of my skillet per the usage output shown in the message. Not sure what has changed and if this info now required in python skillets as args.

scotchoaf commented 4 years ago

Same issue with the content update python skillet in the same repo and 90dev branch

scotchoaf commented 4 years ago

usage: content_update.py [-h] [-f TARGET_IP] [-u TARGET_USERNAME] [-p TARGET_PASSWORD] content_update.py: error: unrecognized arguments: --repo_name=HomeSkillet_scotchoaf --url=https://github.com/scotchoaf/HomeSkillet.git --snippet_name=ngfw_content_update --FW_NAME=homeSkilletFirewall --MGMT_TYPE=dhcp-client --MGMT_MASK=192.0.6.1 --MGMT_DG=255.255.255.0 --DNS_1=8.8.8.8 --DNS_2=4.2.2.2

based on the error output looks like a running list of prior run skillets cached that it looks for in new python skillets as args

nembery commented 4 years ago

This is due to a recent change that allowed output variables from one script to be passed into another script without requiring that input value be specified as a variable. Previously python scripts only got the input that was defined as a 'variable' and nothing else.

The fix could be one of three things: add a new variable type that is 'hidden' and doesn't not necessarily appear in any input form, or to add a new attribute to the snippet section that would define what variables would be required from the context that may NOT be specified in the variables section. The third option could be to examine all variables from the 'workflow' if any and only include those. This would require the python script writer to know that this script will be a part of a larger workflow and add those items to the list of cmd line args.

i.e. more thought needed here to fix

nembery commented 4 years ago

this has been fixed with latest panhandler:dev. give it a test and let me know how it works