Skip to content

Commit

Permalink
Merge pull request #147 from CiscoISE/develop
Browse files Browse the repository at this point in the history
Develop v2.9.5
  • Loading branch information
fmunozmiranda authored Oct 18, 2024
2 parents 2d75144 + 9821095 commit edb760a
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 18 deletions.
7 changes: 6 additions & 1 deletion changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1035,4 +1035,9 @@ releases:
- Collection not compatible with ansible.utils 5.x.y
- Getting deployment info for entire deployment does not work
- cisco.ise.pan_ha object has no attribute 'enable_pan_ha'

2.9.5:
release_date: "2024-10-18"
changes:
release_summary: Update.
bugfixes:
- cisco.ise.support_bundle_download keeps failing after downloading the file
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: cisco
name: ise
version: 2.9.3
version: 2.9.5
readme: README.md
authors:
- Rafael Campos <[email protected]>
Expand Down
5 changes: 3 additions & 2 deletions playbooks/group_vars/ise_servers
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Consider using ansible-vault
---
ise_hostname: "198.18.133.27"
# ise_hostname: "198.18.133.27"
ise_hostname: "stopping-contribution-destiny-kick.trycloudflare.com"
ise_username: "admin"
ise_password: "910457"
ise_password: "C1sco12345"
ise_version: "3.3_patch_1"
ise_verify: False
ise_debug: True
Expand Down
19 changes: 8 additions & 11 deletions playbooks/support_bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
ise_username: "{{ ise_username }}"
ise_password: "{{ ise_password }}"
ise_verify: "{{ ise_verify }}"
ise_debug: true
id: ise
register: support_bundle_status_result

Expand All @@ -42,16 +43,12 @@
ise_username: "{{ ise_username }}"
ise_password: "{{ ise_password }}"
ise_verify: "{{ ise_verify }}"
dirPath: /Users/wilhelm32/Downloads/result/
fileName: "{{ support_bundle_status_result['ise_response']['fileName']}}"
saveFile: true
when:
- support_bundle_status_result['ise_response'] is defined
- support_bundle_status_result['ise_response']['status'] == "complete"
- support_bundle_status_result['ise_response']['fileName']
ise_debug: true
dirPath: /Users/fmunoz/Desktop/Work/Github/ISE/ansible-ise/
fileName: "Name.jpg"
register: support_bundle_download_result

- name: Print support_bundle_download_result
ansible.builtin.debug:
var: support_bundle_status_result
when: support_bundle_download_result
# - name: Print support_bundle_download_result
# ansible.builtin.debug:
# var: support_bundle_status_result
# when: support_bundle_download_result
14 changes: 14 additions & 0 deletions playbooks/support_bundle_download.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- hosts: ise_servers
gather_facts: false
tasks:
- name: Update all
cisco.ise.support_bundle_download:
ise_hostname: "{{ise_hostname}}"
ise_username: "{{ise_username}}"
ise_password: "{{ise_password}}"
ise_verify: "{{ise_verify}}"
ise_debug: true
dirPath: /tmp/downloads/
fileName: ise-support-bundle-pk-ise-admin.tar.gpg
saveFile: true
20 changes: 17 additions & 3 deletions plugins/action/support_bundle_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
ISESDK,
ise_argument_spec,
)

import os.path
# Get common arguements specification
argument_spec = ise_argument_spec()
# Add arguments specific for this module
Expand All @@ -42,7 +42,8 @@
class ActionModule(ActionBase):
def __init__(self, *args, **kwargs):
if not ANSIBLE_UTILS_IS_INSTALLED:
raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
raise AnsibleActionFail(
"ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
super(ActionModule, self).__init__(*args, **kwargs)
self._supports_async = False
self._supports_check_mode = False
Expand Down Expand Up @@ -87,8 +88,21 @@ def run(self, tmp=None, task_vars=None):
function="download_support_bundle",
params=self.get_object(self._task.args),
)

# Check if the data is in binary format
if download_response.headers.get('Content-Type') == 'application/json':
# Attempt to decode if JSON is expected
response_data = download_response.data.decode('utf-8')
else:
# Save binary data to a file
filename = os.path.join(
download_response.dirpath, download_response.filename) or 'default_filename.bin'
with open(filename, 'wb') as f:
f.write(download_response.data)
response_data = f"Data saved in: {filename}"

response = dict(
data=download_response.data.decode(encoding='utf-8'),
data=response_data,
filename=download_response.filename,
dirpath=download_response.dirpath,
path=download_response.path,
Expand Down

0 comments on commit edb760a

Please sign in to comment.