Open ShreyasNBS opened 1 year ago
FYI: This is a pan-os-python issue, it is reproducible outside of Ansible. We will need to progress a fix in that SDK to fix this issue.
@jamesholland-uk Can we add the ignore_disconnect flag like we have on panos_op? We had a similar issue in the past when you set serial number (empty response).
- name: set panorama serial number if it does not match the current one
no_log: true
paloaltonetworks.panos.panos_op:
provider: '{{ primary_provider }}'
cmd: "<set><serial-number>{{ primary_panos_data['serial_number'] }}</serial-number></set>"
cmd_is_xml: true
ignore_disconnect: true
when: "serial != primary_panos_data['serial_number']"
Hi @ShreyasNBS, that could be one of probably multiple solutions, let's see which is the best solution though
Thanks @jamesholland-uk . Another question based on the same issue above. We are attempting a commit and push for log collector group to managed devices via lambda function. This is done when a new firewall spins up, grabs a license from CSP, has the device group and template stack pushed to it (via commit-all). Code below
def panorama_push_log_collector_group(panoramaIpAddress, panoramaApiKey, ewLogCollectorGroupName, instanceId, lifeCycleHook, autoScalingGroup):
# Panorama push (or commit-all in Pano land) log collector group to firewall.
try:
request = "https://" + panoramaIpAddress + "/api/?type=commit&action=all&cmd=<commit-all><log-collector-config><log-collector-group>" + ewLogCollectorGroupName + "</log-collector-group></log-collector-config></commit-all>&key="+ panoramaApiKey
response_panorama_commit_all = http.request('POST', request).data.decode('utf-8')
logger.info("Launch: [Panorama Push Log Collector Group Response]: %s", response_panorama_commit_all)
resp_panorama_commit_all = et.fromstring(response_panorama_commit_all)
messageElement = resp_panorama_commit_all.findall(".//msg")
message = messageElement[0].text
if message is not None and message.find("There are no changes to commit") != -1:
logger.info("Launch: No panorama pending commits")
return True
else:
jobIdElement = resp_panorama_commit_all.findall(".//job")
jobId = jobIdElement[0].text
return check_job_status(jobId, panoramaIpAddress, panoramaApiKey, instanceId, lifeCycleHook, autoScalingGroup)
except Exception as e:
logger.error('Launch: Panorama Push Log Collector Group failed')
logger.error(e)
abandon_lifecycle_hook(instanceId, lifeCycleHook, autoScalingGroup)
return False
The same code logic works for DG and TS (different api call of course), but fails for LCG. The error we get is
If we try to execute the command in a browser via panorama API, it works
The next thing I am going to try is adding "merge with candidate config" if it's allowed for LCG, but that's the only thing remaining tbh.
Ok another quick update. We changed the timeout for the LCG commit-all request to 120 seconds, and it returned success response. However this does not seem to fit in the generic "commit-all" response structure which returns a Job ID that we have to poll. In this case, the success response was similar to one we tried via browser. Honestly, I feel stupid, because the answer was staring right in my face. For DG and TS commit-all, the response is "Job ID xxx enqueued". So we are going to change the logic to just check the success status and move on. Still not sure why the pan-os-sdk returns an empty response though.
Describe the bug
When I run the following code
I get the exception
I have a device group and template stack configured via ansible and they work fine when I commit. The only "gotcha" could be that I do not have any managed firewalls added yet (but if the behaviour was consistent, then commit to device group and template stack should also fail?)
Another interesting thing to note is that the commit actually goes through on the panorama side, even though ansible errors. So I am presuming the issue is on the panos collection side.
I am using the latest panos ansible collection, and I am on panorama 10.2.2-h2.