diff --git a/lib/ansible/modules/identity/cyberark/cyberark_authentication.py b/lib/ansible/modules/identity/cyberark/cyberark_authentication.py index 416c08cbdf1..ad576eec5ae 100644 --- a/lib/ansible/modules/identity/cyberark/cyberark_authentication.py +++ b/lib/ansible/modules/identity/cyberark/cyberark_authentication.py @@ -1,21 +1,9 @@ #!/usr/bin/python -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . -# +# Copyright: (c) 2017, Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import absolute_import, division, print_function +__metaclass__ = type ANSIBLE_METADATA = {'status': ['preview'], 'supported_by': 'community', diff --git a/lib/ansible/modules/identity/ipa/ipa_dnsrecord.py b/lib/ansible/modules/identity/ipa/ipa_dnsrecord.py index 8e3ff794af1..f146add5177 100644 --- a/lib/ansible/modules/identity/ipa/ipa_dnsrecord.py +++ b/lib/ansible/modules/identity/ipa/ipa_dnsrecord.py @@ -1,22 +1,10 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# (c) 2017, Abhijeet Kasurde (akasurde@redhat.com) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# Copyright: (c) 2017, Abhijeet Kasurde (akasurde@redhat.com) +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import absolute_import, division, print_function +__metaclass__ = type ANSIBLE_METADATA = { 'metadata_version': '1.0', @@ -118,9 +106,11 @@ dnsrecord: type: dict ''' +import traceback + from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.pycompat24 import get_exception from ansible.module_utils.ipa import IPAClient +from ansible.module_utils._text import to_native class DNSRecordIPAClient(IPAClient): @@ -229,9 +219,8 @@ def main(): password=module.params['ipa_pass']) changed, record = ensure(module, client) module.exit_json(changed=changed, record=record) - except Exception: - e = get_exception() - module.fail_json(msg=str(e)) + except Exception as e: + module.fail_json(msg=to_native(e), exception=traceback.format_exc()) if __name__ == '__main__': diff --git a/lib/ansible/modules/identity/ipa/ipa_group.py b/lib/ansible/modules/identity/ipa/ipa_group.py index 2132c3ee220..4f72edce6ee 100644 --- a/lib/ansible/modules/identity/ipa/ipa_group.py +++ b/lib/ansible/modules/identity/ipa/ipa_group.py @@ -1,19 +1,10 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# Copyright: (c) 2017, Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], @@ -140,9 +131,11 @@ group: type: dict ''' +import traceback + from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.pycompat24 import get_exception from ansible.module_utils.ipa import IPAClient +from ansible.module_utils._text import to_native class GroupIPAClient(IPAClient): @@ -280,9 +273,8 @@ def main(): password=module.params['ipa_pass']) changed, group = ensure(module, client) module.exit_json(changed=changed, group=group) - except Exception: - e = get_exception() - module.fail_json(msg=str(e)) + except Exception as e: + module.fail_json(msg=to_native(e), exception=traceback.format_exc()) if __name__ == '__main__': diff --git a/lib/ansible/modules/identity/ipa/ipa_hbacrule.py b/lib/ansible/modules/identity/ipa/ipa_hbacrule.py index 2afee04611e..6d1ed4c6338 100644 --- a/lib/ansible/modules/identity/ipa/ipa_hbacrule.py +++ b/lib/ansible/modules/identity/ipa/ipa_hbacrule.py @@ -1,19 +1,10 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# Copyright: (c) 2017, Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], @@ -171,9 +162,11 @@ hbacrule: type: dict ''' +import traceback + from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.pycompat24 import get_exception from ansible.module_utils.ipa import IPAClient +from ansible.module_utils._text import to_native class HBACRuleIPAClient(IPAClient): @@ -374,9 +367,8 @@ def main(): password=module.params['ipa_pass']) changed, hbacrule = ensure(module, client) module.exit_json(changed=changed, hbacrule=hbacrule) - except Exception: - e = get_exception() - module.fail_json(msg=str(e)) + except Exception as e: + module.fail_json(msg=to_native(e), exception=traceback.format_exc()) if __name__ == '__main__': diff --git a/lib/ansible/modules/identity/ipa/ipa_host.py b/lib/ansible/modules/identity/ipa/ipa_host.py index c6c1c96ce64..a37055f9515 100644 --- a/lib/ansible/modules/identity/ipa/ipa_host.py +++ b/lib/ansible/modules/identity/ipa/ipa_host.py @@ -1,19 +1,10 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# Copyright: (c) 2017, Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], @@ -165,9 +156,11 @@ host_diff: type: list ''' +import traceback + from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.pycompat24 import get_exception from ansible.module_utils.ipa import IPAClient +from ansible.module_utils._text import to_native class HostIPAClient(IPAClient): @@ -292,10 +285,8 @@ def main(): password=module.params['ipa_pass']) changed, host = ensure(module, client) module.exit_json(changed=changed, host=host) - except Exception: - e = get_exception() - module.fail_json(msg=str(e)) - + except Exception as e: + module.fail_json(msg=to_native(e), exception=traceback.format_exc()) if __name__ == '__main__': main() diff --git a/lib/ansible/modules/identity/ipa/ipa_hostgroup.py b/lib/ansible/modules/identity/ipa/ipa_hostgroup.py index 276b5266920..66ac5743cf3 100644 --- a/lib/ansible/modules/identity/ipa/ipa_hostgroup.py +++ b/lib/ansible/modules/identity/ipa/ipa_hostgroup.py @@ -1,19 +1,10 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# Copyright: (c) 2017, Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], @@ -118,9 +109,11 @@ hostgroup: type: dict ''' +import traceback + from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.pycompat24 import get_exception from ansible.module_utils.ipa import IPAClient +from ansible.module_utils._text import to_native class HostGroupIPAClient(IPAClient): @@ -242,9 +235,8 @@ def main(): password=module.params['ipa_pass']) changed, hostgroup = ensure(module, client) module.exit_json(changed=changed, hostgroup=hostgroup) - except Exception: - e = get_exception() - module.fail_json(msg=str(e)) + except Exception as e: + module.fail_json(msg=to_native(e), exception=traceback.format_exc()) if __name__ == '__main__': diff --git a/lib/ansible/modules/identity/ipa/ipa_role.py b/lib/ansible/modules/identity/ipa/ipa_role.py index 1d6959b9b3e..1604434b0f9 100644 --- a/lib/ansible/modules/identity/ipa/ipa_role.py +++ b/lib/ansible/modules/identity/ipa/ipa_role.py @@ -1,19 +1,10 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# Copyright: (c) 2017, Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], @@ -160,9 +151,11 @@ role: type: dict ''' +import traceback + from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.pycompat24 import get_exception from ansible.module_utils.ipa import IPAClient +from ansible.module_utils._text import to_native class RoleIPAClient(IPAClient): @@ -332,9 +325,8 @@ def main(): password=module.params['ipa_pass']) changed, role = ensure(module, client) module.exit_json(changed=changed, role=role) - except Exception: - e = get_exception() - module.fail_json(msg=str(e)) + except Exception as e: + module.fail_json(msg=to_native(e), exception=traceback.format_exc()) if __name__ == '__main__': diff --git a/lib/ansible/modules/identity/ipa/ipa_sudocmd.py b/lib/ansible/modules/identity/ipa/ipa_sudocmd.py index 13ba6d90483..db1daca27fb 100644 --- a/lib/ansible/modules/identity/ipa/ipa_sudocmd.py +++ b/lib/ansible/modules/identity/ipa/ipa_sudocmd.py @@ -1,19 +1,10 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# Copyright: (c) 2017, Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], @@ -97,9 +88,11 @@ sudocmd: type: dict ''' +import traceback + from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.pycompat24 import get_exception from ansible.module_utils.ipa import IPAClient +from ansible.module_utils._text import to_native class SudoCmdIPAClient(IPAClient): @@ -187,9 +180,8 @@ def main(): password=module.params['ipa_pass']) changed, sudocmd = ensure(module, client) module.exit_json(changed=changed, sudocmd=sudocmd) - except Exception: - e = get_exception() - module.fail_json(msg=str(e)) + except Exception as e: + module.fail_json(msg=to_native(e), exception=traceback.format_exc()) if __name__ == '__main__': diff --git a/lib/ansible/modules/identity/ipa/ipa_sudocmdgroup.py b/lib/ansible/modules/identity/ipa/ipa_sudocmdgroup.py index 10af297fc3c..9becc988674 100644 --- a/lib/ansible/modules/identity/ipa/ipa_sudocmdgroup.py +++ b/lib/ansible/modules/identity/ipa/ipa_sudocmdgroup.py @@ -1,19 +1,10 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# Copyright: (c) 2017, Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], @@ -104,9 +95,11 @@ sudocmdgroup: type: dict ''' +import traceback + from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.pycompat24 import get_exception from ansible.module_utils.ipa import IPAClient +from ansible.module_utils._text import to_native class SudoCmdGroupIPAClient(IPAClient): @@ -213,10 +206,8 @@ def main(): password=module.params['ipa_pass']) changed, sudocmdgroup = ensure(module, client) module.exit_json(changed=changed, sudorule=sudocmdgroup) - except Exception: - e = get_exception() - module.fail_json(msg=str(e)) - + except Exception as e: + module.fail_json(msg=to_native(e), exception=traceback.format_exc()) if __name__ == '__main__': main() diff --git a/lib/ansible/modules/identity/ipa/ipa_sudorule.py b/lib/ansible/modules/identity/ipa/ipa_sudorule.py index 60687543f5a..dd25d348207 100644 --- a/lib/ansible/modules/identity/ipa/ipa_sudorule.py +++ b/lib/ansible/modules/identity/ipa/ipa_sudorule.py @@ -1,19 +1,10 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# Copyright: (c) 2017, Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], @@ -156,9 +147,11 @@ sudorule: type: dict ''' +import traceback + from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.pycompat24 import get_exception from ansible.module_utils.ipa import IPAClient +from ansible.module_utils._text import to_native class SudoRuleIPAClient(IPAClient): @@ -381,9 +374,8 @@ def main(): password=module.params['ipa_pass']) changed, sudorule = ensure(module, client) module.exit_json(changed=changed, sudorule=sudorule) - except Exception: - e = get_exception() - module.fail_json(msg=str(e)) + except Exception as e: + module.fail_json(msg=to_native(e), exception=traceback.format_exc()) if __name__ == '__main__': diff --git a/lib/ansible/modules/identity/ipa/ipa_user.py b/lib/ansible/modules/identity/ipa/ipa_user.py index 8d6b997f3c5..5a7bef17ea9 100644 --- a/lib/ansible/modules/identity/ipa/ipa_user.py +++ b/lib/ansible/modules/identity/ipa/ipa_user.py @@ -1,19 +1,10 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# Copyright: (c) 2017, Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], @@ -143,10 +134,11 @@ user: import base64 import hashlib +import traceback from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.pycompat24 import get_exception from ansible.module_utils.ipa import IPAClient +from ansible.module_utils._text import to_native class UserIPAClient(IPAClient): @@ -328,9 +320,8 @@ def main(): password=module.params['ipa_pass']) changed, user = ensure(module, client) module.exit_json(changed=changed, user=user) - except Exception: - e = get_exception() - module.fail_json(msg=str(e)) + except Exception as e: + module.fail_json(msg=to_native(e), exception=traceback.format_exc()) if __name__ == '__main__': diff --git a/lib/ansible/modules/identity/opendj/opendj_backendprop.py b/lib/ansible/modules/identity/opendj/opendj_backendprop.py index 1bc85014719..4e88df83503 100644 --- a/lib/ansible/modules/identity/opendj/opendj_backendprop.py +++ b/lib/ansible/modules/identity/opendj/opendj_backendprop.py @@ -1,23 +1,11 @@ #!/usr/bin/python # -*- coding: utf-8 -*- +# Copyright: (c) 2016, Werner Dijkerman (ikben@werner-dijkerman.nl) +# Copyright: (c) 2017, Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# (c) 2016, Werner Dijkerman (ikben@werner-dijkerman.nl) -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . -# +from __future__ import absolute_import, division, print_function +__metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], @@ -97,6 +85,8 @@ EXAMPLES = ''' RETURN = ''' ''' +from ansible.module_utils.basic import AnsibleModule + class BackendProp(object): @@ -209,8 +199,5 @@ def main(): else: module.exit_json(changed=False) - -from ansible.module_utils.basic import AnsibleModule - if __name__ == '__main__': main() diff --git a/test/sanity/code-smell/boilerplate.sh b/test/sanity/code-smell/boilerplate.sh index 4d5830f1529..270e487c0e0 100755 --- a/test/sanity/code-smell/boilerplate.sh +++ b/test/sanity/code-smell/boilerplate.sh @@ -19,7 +19,6 @@ future2=$(find ./lib/ansible -path ./lib/ansible/modules -prune \ # Eventually we want metaclass3 and future3 to get down to 0 metaclass3=$(find ./lib/ansible/modules -path ./lib/ansible/modules/windows -prune \ - -o -path ./lib/ansible/modules/identity -prune \ -o -path ./lib/ansible/modules/files -prune \ -o -path ./lib/ansible/modules/database/proxysql -prune \ -o -path ./lib/ansible/modules/cloud/ovirt -prune \ @@ -42,7 +41,6 @@ metaclass3=$(find ./lib/ansible/modules -path ./lib/ansible/modules/windows -pru -o -name '*.py' -type f -size +0c -exec grep -HL '__metaclass__ = type' '{}' '+') future3=$(find ./lib/ansible/modules -path ./lib/ansible/modules/windows -prune \ - -o -path ./lib/ansible/modules/identity -prune \ -o -path ./lib/ansible/modules/files -prune \ -o -path ./lib/ansible/modules/database/proxysql -prune \ -o -path ./lib/ansible/modules/cloud/ovirt -prune \ @@ -78,7 +76,6 @@ future3=$(find ./lib/ansible/modules -path ./lib/ansible/modules/windows -prune # network/netvisor # network/aos [!] # network/vyos [i] -# identity [!] # network/lenovo # network/panos [!] # network/junos [i]