Skip to content

Commit f55e957

Browse files
author
Shiva Shankar Vaddepally
committed
Refactor logic of systemfile handling
1 parent 2fc7aa5 commit f55e957

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

plugins/module_utils/module_executor.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@
4444
from .nitro_resource_map import NITRO_RESOURCE_MAP
4545

4646

47-
skippable_resource_list = [
48-
# In some cases, although keys are listed as immutable in the nitro_resource_map, they can actually be updated.
49-
# This list helps bypass the immutability check for these resources.
50-
"systemfile"
51-
]
52-
53-
5447
class ModuleExecutor(object):
5548
def __init__(self, resource_name, supports_check_mode=True):
5649
self.resource_name = resource_name
@@ -470,7 +463,22 @@ def create_or_update(self):
470463
)
471464
else:
472465
self.module_result["changed"] = True
473-
if self.resource_name.endswith("_binding"):
466+
if self.resource_name == "systemfile":
467+
# Generally systemfile is not updated. It is removed and added again.
468+
log(
469+
"INFO: Resource %s:%s exists and is different. Will be REMOVED and ADDED."
470+
% (self.resource_name, self.resource_id)
471+
)
472+
if self.resource_name == "systemfile":
473+
# If the systemfile is present, we will delete it and add it again
474+
self.delete()
475+
ok, err = create_resource(
476+
self.client, self.resource_name, self.resource_module_params
477+
)
478+
if not ok:
479+
self.return_failure(err)
480+
481+
elif self.resource_name.endswith("_binding"):
474482
# Generally bindings are not updated. They are removed and added again.
475483
log(
476484
"INFO: Resource %s:%s exists and is different. Will be REMOVED and ADDED."
@@ -489,7 +497,7 @@ def create_or_update(self):
489497
self.client, self.resource_name, self.resource_module_params
490498
)
491499

492-
elif immutable_keys_list is None or self.resource_name in skippable_resource_list:
500+
elif immutable_keys_list is None:
493501
self.module_result["changed"] = True
494502
log(
495503
"INFO: Resource %s:%s exists and is different. Will be UPDATED."

0 commit comments

Comments
 (0)