Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optionally ignore error for pdadmin commands #138

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plugins/connection/isam.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def call_isam_action(self, isam_module, options):
raise AnsibleConnectionFailure("Error> IBMError, action: {0} Exception: {1}".format(isam_module, e), options,
e)

def call_isam_admin(self, adminDomain, isamuser, isampwd, commands):
def call_isam_admin(self, adminDomain, isamuser, isampwd, commands, ignore_error):
"""
Execute an ISAM Admin command, also know as pdadmin commands
"""
Expand All @@ -230,7 +230,7 @@ def call_isam_admin(self, adminDomain, isamuser, isampwd, commands):

# Execute isam admin function
ret_obj = ibmsecurity.isam.web.runtime.pdadmin.execute(isamAppliance=self.isam_server, isamUser=iu,
admin_domain=adminDomain, commands=commands)
admin_domain=adminDomain, commands=commands, ignore_error=ignore_error)
ret_obj['ansible_facts'] = self.isam_server.facts
return ret_obj
except ImportError as e:
Expand Down
9 changes: 7 additions & 2 deletions plugins/modules/isamadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import sys
from ansible.module_utils.basic import AnsibleModule
import datetime
import re

from ansible_collections.ibm.isam.plugins.module_utils.isam import ISAMUtil

Expand All @@ -76,7 +77,8 @@ def main():
isamuser=dict(required=False),
isampwd=dict(required=True, no_log=True),
isamdomain=dict(required=False, default='Default'),
commands=dict(required=True, type='list', elements='str')
commands=dict(required=True, type='list', elements='str'),
ignore_error=dict(required=False, default=False, choices=[True,False])
),
supports_check_mode=False
)
Expand All @@ -88,13 +90,14 @@ def main():
isampwd = module.params['isampwd']
isamdomain = module.params['isamdomain']
commands = module.params['commands']
ignore_error = module.params['ignore_error']

isam_util = ISAMUtil(module)

# Execute isam admin commands (pdadmin)
startd = datetime.datetime.now()

ret_obj = isam_util.connection.call_isam_admin(isamdomain, isamuser, isampwd, commands)
ret_obj = isam_util.connection.call_isam_admin(isamdomain, isamuser, isampwd, commands, ignore_error)

endd = datetime.datetime.now()
delta = endd - startd
Expand All @@ -106,6 +109,8 @@ def main():
ret_obj['delta'] = str(delta)
ret_obj['cmd'] = "pdadmin execution using Domain: {0}, User: {1} and Commands: {2}".format(isamdomain, isamuser,
commands)
if re.search("Warning:", ret_obj['data']['result']):
ret_obj['warnings'] = ret_obj['data']['result']

module.exit_json(**ret_obj)

Expand Down