Skip to content

Commit d41dd37

Browse files
authored
Merge pull request #167 from CiscoISE/develop
Develop
2 parents 92996d0 + 93c7724 commit d41dd37

File tree

6 files changed

+86
-19
lines changed

6 files changed

+86
-19
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The following table shows the supported versions.
5353
| 3.1_Patch_1 | 2.5.16 | 2.0.10 |
5454
| 3.2_beta | 2.8.0 | 2.1.1 |
5555
| 3.3_patch_1 | 2.10.0 | 2.2.3 |
56-
| 3.5.0 | 3.0.0 | 2.4.0 |
56+
| 3.5.0 | 3.0.1 | 2.4.0 |
5757

5858
If your Ansible collection is older please consider updating it first.
5959
*Notes*:
@@ -90,7 +90,7 @@ export ISE_HOSTNAME=<A.B.C.D>
9090
export ISE_USERNAME=<username>
9191
export ISE_PASSWORD=<password>
9292
export ISE_VERIFY=False # optional, defaults to True
93-
export ISE_VERSION=3.3_patch_1 # optional, defaults to 3.3_patch_1
93+
export ISE_VERSION=3.5.0 # optional, defaults to 3.5.0
9494
export ISE_WAIT_ON_RATE_LIMIT=True # optional, defaults to True
9595
export ISE_USES_API_GATEWAY=True # optional, defaults to True
9696
export ISE_DEBUG=False # optional, defaults to False

changelogs/changelog.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,3 +1621,10 @@ releases:
16211621
- Updated .gitignore with additional exclusion patterns.
16221622
- Fixed galaxy.yml metadata for compatibility
16231623
with newer Ansible versions.
1624+
3.0.1:
1625+
release_date: "2025-11-20"
1626+
changes:
1627+
release_summary: Update ISE version to 3.5.0
1628+
bugfixes:
1629+
- networkdevice add support for 'absent' state, implement update and delete methods
1630+
- update ISE version to 3.5.0 for improved functionality.

galaxy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
namespace: cisco
33
name: ise
4-
version: 3.0.0
4+
version: 3.0.1
55
readme: README.md
66
authors:
77
- William Astorga <[email protected]>

playbooks/group_vars/ise_servers

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# Consider using ansible-vault
22
---
33
# ise_hostname: "198.18.133.27"
4-
ise_hostname: "stopping-contribution-destiny-kick.trycloudflare.com"
5-
ise_username: "admin"
6-
ise_password: "C1sco12345"
7-
ise_version: "3.3_patch_1"
8-
ise_verify: False
9-
ise_debug: True
10-
ise_uses_api_gateway: True
11-
ise_uses_csrf_token: False
4+
# ise_username: "admin"
5+
# ise_password: "C1sco12345"
6+
# ise_version: "3.5.0"
7+
# ise_verify: False
8+
# ise_debug: True
9+
# ise_uses_api_gateway: True
10+
# ise_uses_csrf_token: False

plugins/action/networkdevice.py

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
argument_spec = ise_argument_spec()
3333
# Add arguments specific for this module
3434
argument_spec.update(dict(
35-
state=dict(type="str", default="present", choices=["present"]),
35+
state=dict(type="str", default="present", choices=["present", "absent"]),
3636
authenticationSettings=dict(type="dict"),
3737
coaPort=dict(type="float"),
3838
dtlsDnsName=dict(type="str"),
@@ -51,7 +51,8 @@
5151
))
5252

5353
required_if = [
54-
("state", "present", ["name"], True),
54+
("state", "present", ["id", "name"], True),
55+
("state", "absent", ["id", "name"], True),
5556
]
5657
required_one_of = []
5758
mutually_exclusive = []
@@ -108,14 +109,31 @@ def get_object_by_name(self, name):
108109
return result
109110

110111
def get_object_by_id(self, id):
111-
# NOTICE: Does not have a get by id method or it is in another action
112-
result = None
112+
try:
113+
result = self.ise.exec(
114+
family="networkdevice",
115+
function="get_networkdevice_by_id",
116+
handle_func_exception=False,
117+
params={"id": id}
118+
).response['NetworkDevice']
119+
except (TypeError, AttributeError) as e:
120+
self.ise.fail_json(
121+
msg=(
122+
"An error occured when executing operation."
123+
" Check the configuration of your API Settings and API Gateway settings on your ISE server."
124+
" This collection assumes that the API Gateway, the ERS APIs and OpenAPIs are enabled."
125+
" You may want to enable the (ise_debug: True) argument."
126+
" The error was: {error}"
127+
).format(error=e)
128+
)
129+
except Exception:
130+
result = None
113131
return result
114132

115133
def exists(self):
116-
prev_obj = None
117134
id_exists = False
118135
name_exists = False
136+
prev_obj = None
119137
o_id = self.new_object.get("id")
120138
name = self.new_object.get("name")
121139
if o_id:
@@ -128,6 +146,8 @@ def exists(self):
128146
_id = prev_obj.get("id")
129147
if id_exists and name_exists and o_id != _id:
130148
raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object")
149+
if _id:
150+
prev_obj = self.get_object_by_id(_id)
131151
it_exists = prev_obj is not None and isinstance(prev_obj, dict)
132152
return (it_exists, prev_obj)
133153

@@ -165,6 +185,34 @@ def create(self):
165185
).response
166186
return result
167187

188+
def update(self):
189+
id = self.new_object.get("id")
190+
name = self.new_object.get("name")
191+
result = None
192+
if not id:
193+
id_ = self.get_object_by_name(name).get("id")
194+
self.new_object.update(dict(id=id_))
195+
result = self.ise.exec(
196+
family="networkdevice",
197+
function="update_networkdevice_by_id",
198+
params=self.new_object
199+
).response
200+
return result
201+
202+
def delete(self):
203+
id = self.new_object.get("id")
204+
name = self.new_object.get("name")
205+
result = None
206+
if not id:
207+
id_ = self.get_object_by_name(name).get("id")
208+
self.new_object.update(dict(id=id_))
209+
result = self.ise.exec(
210+
family="networkdevice",
211+
function="delete_networkdevice_by_id",
212+
params=self.new_object
213+
).response
214+
return result
215+
168216

169217
class ActionModule(ActionBase):
170218
def __init__(self, *args, **kwargs):
@@ -205,12 +253,16 @@ def run(self, tmp=None, task_vars=None):
205253
state = self._task.args.get("state")
206254

207255
response = None
256+
208257
if state == "present":
209258
(obj_exists, prev_obj) = obj.exists()
210259
if obj_exists:
211260
if obj.requires_update(prev_obj):
212-
response = prev_obj
213-
ise.object_present_and_different()
261+
ise_update_response = obj.update()
262+
self._result.update(dict(ise_update_response=ise_update_response))
263+
(obj_exists, updated_obj) = obj.exists()
264+
response = updated_obj
265+
ise.object_updated()
214266
else:
215267
response = prev_obj
216268
ise.object_already_present()
@@ -220,6 +272,15 @@ def run(self, tmp=None, task_vars=None):
220272
response = created_obj
221273
ise.object_created()
222274

275+
elif state == "absent":
276+
(obj_exists, prev_obj) = obj.exists()
277+
if obj_exists:
278+
obj.delete()
279+
response = prev_obj
280+
ise.object_deleted()
281+
else:
282+
ise.object_already_absent()
283+
223284
self._result.update(dict(ise_response=response))
224285
self._result.update(ise.exit_json())
225286
return self._result

plugins/plugin_utils/ise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def ise_argument_spec():
133133
ise_username=dict(type="str", fallback=(env_fallback, ['ISE_USERNAME']), required=True),
134134
ise_password=dict(type="str", fallback=(env_fallback, ['ISE_PASSWORD']), required=True, no_log=True),
135135
ise_verify=dict(type="bool", default=True, fallback=(env_fallback, ['ISE_VERIFY'])),
136-
ise_version=dict(type="str", default="3.3_patch_1", fallback=(env_fallback, ['ISE_VERSION'])),
136+
ise_version=dict(type="str", default="3.5.0", fallback=(env_fallback, ['ISE_VERSION'])),
137137
ise_wait_on_rate_limit=dict(type="bool", default=True, fallback=(env_fallback, ['ISE_WAIT_ON_RATE_LIMIT'])),
138138
ise_uses_api_gateway=dict(type="bool", default=True, fallback=(env_fallback, ['ISE_USES_API_GATEWAY'])),
139139
ise_uses_csrf_token=dict(type="bool", default=False, fallback=(env_fallback, ['ISE_USES_CSRF_TOKEN'])),

0 commit comments

Comments
 (0)