From 7d6f417f3212beac92d5eb01c45f811ead190dc5 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Wed, 26 Jun 2019 14:25:45 +0530 Subject: [PATCH] Multiple minor fixes (#58374) * Documentation update * Typo fixes * fail_json fixes Signed-off-by: Abhijeet Kasurde --- lib/ansible/modules/cloud/amazon/aws_codepipeline.py | 8 ++++---- lib/ansible/modules/cloud/amazon/ec2_eip.py | 2 +- .../modules/database/postgresql/postgresql_pg_hba.py | 2 +- lib/ansible/modules/monitoring/zabbix/zabbix_mediatype.py | 5 ++--- lib/ansible/modules/network/cnos/cnos_l2_interface.py | 6 +++--- lib/ansible/modules/packaging/os/rhn_channel.py | 2 +- lib/ansible/modules/system/puppet.py | 2 +- 7 files changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/aws_codepipeline.py b/lib/ansible/modules/cloud/amazon/aws_codepipeline.py index d6020d1ab7..61128b7d5c 100644 --- a/lib/ansible/modules/cloud/amazon/aws_codepipeline.py +++ b/lib/ansible/modules/cloud/amazon/aws_codepipeline.py @@ -34,7 +34,7 @@ options: required: true artifact_store: description: - - Location information where articacts are stored (on S3). Dictionary with fields type and location. + - Location information where artifacts are stored (on S3). Dictionary with fields type and location. required: true suboptions: type: @@ -71,13 +71,13 @@ extends_documentation_fragment: EXAMPLES = ''' # Note: These examples do not set authentication details, see the AWS Guide for details. -# Example for creating a pipeline for continouos deploy of Github code to an ECS cluster (container) +# Example for creating a pipeline for continuous deploy of Github code to an ECS cluster (container) - code_pipeline: name: my_deploy_pipeline role_arn: arn:aws:iam::123456:role/AWS-CodePipeline-Service artifact_store: type: S3 - locatation: my_s3_codepipline_bucket + location: my_s3_codepipline_bucket stages: - name: Get_source actions: @@ -159,7 +159,7 @@ pipeline: type: complex contains: type: - desrciption: The type of the artifacts store, such as S3 + description: The type of the artifacts store, such as S3 returned: always type: string sample: S3 diff --git a/lib/ansible/modules/cloud/amazon/ec2_eip.py b/lib/ansible/modules/cloud/amazon/ec2_eip.py index b1ad5eb0b3..f4b9202f21 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_eip.py +++ b/lib/ansible/modules/cloud/amazon/ec2_eip.py @@ -287,7 +287,7 @@ def release_address(ec2, address, check_mode): # If we're in check mode, nothing else to do if not check_mode: if not address.release(): - EIPException('release failed') + raise EIPException('release failed') return {'changed': True} diff --git a/lib/ansible/modules/database/postgresql/postgresql_pg_hba.py b/lib/ansible/modules/database/postgresql/postgresql_pg_hba.py index df212eaa99..6364fafbbd 100644 --- a/lib/ansible/modules/database/postgresql/postgresql_pg_hba.py +++ b/lib/ansible/modules/database/postgresql/postgresql_pg_hba.py @@ -633,7 +633,7 @@ class PgHbaRule(dict): return 1 if isinstance(sourceobj, str): return 0 - raise PgHbaValueError('This source {1} is of an unknown type...'.format(sourceobj)) + raise PgHbaValueError('This source {0} is of an unknown type...'.format(sourceobj)) def db_weight(self): """Report the weight of the database. diff --git a/lib/ansible/modules/monitoring/zabbix/zabbix_mediatype.py b/lib/ansible/modules/monitoring/zabbix/zabbix_mediatype.py index 64836981fb..9a485cbd3f 100644 --- a/lib/ansible/modules/monitoring/zabbix/zabbix_mediatype.py +++ b/lib/ansible/modules/monitoring/zabbix/zabbix_mediatype.py @@ -34,7 +34,7 @@ options: type: 'str' description: - Desired state of the mediatype. - - On C(present), it will create a medatype if it does not exist or update the mediatype if the associated data is different. + - On C(present), it will create a mediatype if it does not exist or update the mediatype if the associated data is different. - On C(absent), it will remove the mediatype if it exists. choices: - present @@ -131,7 +131,7 @@ options: smtp_authentication: type: 'bool' description: - - Whether SMTP authetication with username and password should be enabled or not. + - Whether SMTP authentication with username and password should be enabled or not. - If set to C(true), C(username) and C(password) should be specified. default: false smtp_security: @@ -476,7 +476,6 @@ def delete_mediatype(module, zbx, mediatype_id): def update_mediatype(module, zbx, **kwargs): try: - pass mediatype_id = zbx.mediatype.update(kwargs) except Exception as e: module.fail_json(msg="Failed to update mediatype '{_id}': {e}".format(_id=kwargs['mediatypeid'], e=e)) diff --git a/lib/ansible/modules/network/cnos/cnos_l2_interface.py b/lib/ansible/modules/network/cnos/cnos_l2_interface.py index 65bed580c8..af11693d69 100644 --- a/lib/ansible/modules/network/cnos/cnos_l2_interface.py +++ b/lib/ansible/modules/network/cnos/cnos_l2_interface.py @@ -515,11 +515,11 @@ def main(): if mode == 'access' and state == 'present' and not access_vlan: msg = 'access_vlan param required for mode=access && state=present' - module.fail_json(msg) + module.fail_json(msg=msg) if mode == 'trunk' and access_vlan: msg = 'access_vlan param not supported when using mode=trunk' - module.fail_json(msg) + module.fail_json(msg=msg) if not is_switchport(name, module): module.fail_json(msg='Ensure interface is configured to be a L2' @@ -538,7 +538,7 @@ def main(): # If there isn't an existing, something is wrong per previous comment if not existing: msg = 'Make sure you are using the FULL interface name' - module.fail_json(msg) + module.fail_json(msg=msg) if trunk_vlans or trunk_allowed_vlans: if trunk_vlans: diff --git a/lib/ansible/modules/packaging/os/rhn_channel.py b/lib/ansible/modules/packaging/os/rhn_channel.py index ca725a5aa0..e1736c069b 100644 --- a/lib/ansible/modules/packaging/os/rhn_channel.py +++ b/lib/ansible/modules/packaging/os/rhn_channel.py @@ -154,7 +154,7 @@ def main(): unsubscribe_channels(channelname, client, session, systname, sys_id) module.exit_json(changed=True, msg="Channel %s removed" % channelname) except Exception as e: - module.fail_json('Unable to %s channel (%s): %s' % ('add' if state == 'present' else 'remove', channelname, to_text(e))) + module.fail_json(msg='Unable to %s channel (%s): %s' % ('add' if state == 'present' else 'remove', channelname, to_text(e))) finally: client.auth.logout(session) diff --git a/lib/ansible/modules/system/puppet.py b/lib/ansible/modules/system/puppet.py index a856751b3c..d8261a2b36 100644 --- a/lib/ansible/modules/system/puppet.py +++ b/lib/ansible/modules/system/puppet.py @@ -267,7 +267,7 @@ def main(): if module.check_mode: cmd += " --noop" if p['use_srv_records'] is not None: - if not ['use_srv_records']: + if not p['use_srv_records']: cmd += " --no-use_srv_records" else: cmd += " --use_srv_records"