Skip to content

Commit

Permalink
Rename python files in hacking/ directory to have .py suffix
Browse files Browse the repository at this point in the history
ansible-test only passes files which have the .py suffix for sanity
tests on python files.  This change will allow sanity tests to run on
the Python files in hacking/

* Rename test-module to test-module.py
* Symlink test-module for backwards compat since end users may be using
  test-module
* Fix test-module sanity errors that are now triggered
* Rename ansible_profile to ansible-profile.py
* Rename build-ansible
  • Loading branch information
abadger committed Jul 11, 2019
1 parent 146a7f8 commit 33d2728
Show file tree
Hide file tree
Showing 18 changed files with 305 additions and 301 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ include contrib/README.md
recursive-include contrib/inventory *
exclude test/sanity/code-smell/botmeta.*
recursive-include hacking/build_library *.py
include hacking/build-ansible
include hacking/build-ansible.py
4 changes: 2 additions & 2 deletions docs/docsite/rst/dev_guide/debugging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ Debugging AnsibleModule-based modules

.. tip::

If you're using the :file:`hacking/test-module` script then most of this
If you're using the :file:`hacking/test-module.py` script then most of this
is taken care of for you. If you need to do some debugging of the module
on the remote machine that the module will actually run on or when the
module is used in a playbook then you may need to use this information
instead of relying on test-module.
instead of relying on :file:`test-module.py`.

Starting with Ansible 2.1, AnsibleModule-based modules are put together as
a zip file consisting of the module file and the various python module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ General guidelines & tips

* Each module should be self-contained in one file, so it can be be auto-transferred by Ansible.
* Module name MUST use underscores instead of hyphens or spaces as a word separator. Using hyphens and spaces will prevent Ansible from importing your module.
* Always use the ``hacking/test-module`` script when developing modules - it will warn you about common pitfalls.
* Always use the ``hacking/test-module.py`` script when developing modules - it will warn you about common pitfalls.
* If you have a local module that returns facts specific to your installations, a good name for this module is ``site_facts``.
* Eliminate or minimize dependencies. If your module has dependencies, document them at the top of the module file and raise JSON error messages when dependency import fails.
* Don't write to files directly; use a temporary file and then use the ``atomic_move`` function from ``ansible.module_utils.basic`` to move the updated temporary file into place. This prevents data corruption and ensures that the correct context for the file is kept.
Expand Down
10 changes: 5 additions & 5 deletions hacking/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ can install them from pip

From there, follow ansible instructions on docs.ansible.com as normal.

test-module
-----------
test-module.py
--------------

'test-module' is a simple program that allows module developers (or testers) to run
'test-module.py' is a simple program that allows module developers (or testers) to run
a module outside of the ansible program, locally, on the current machine.

Example:

$ ./hacking/test-module -m lib/ansible/modules/commands/command.py -a "echo hi"
$ ./hacking/test-module.py -m lib/ansible/modules/commands/command.py -a "echo hi"

This is a good way to insert a breakpoint into a module, for instance.

Expand All @@ -46,7 +46,7 @@ parent:
Use:
$ ./hacking/test-module -m module \
$ ./hacking/test-module.py -m module \
-a '{"parent": {"child": [{"item": "first", "val": "foo"}, {"item": "second", "val": "bar"}]}}'
return_skeleton_generator.py
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion hacking/build-ansible → hacking/build-ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def main():

arg_parser = create_arg_parser(os.path.basename(sys.argv[0]))
subparsers = arg_parser.add_subparsers(title='Subcommands', dest='command',
help='for help use build-ansible SUBCOMMANDS -h')
help='for help use build-ansible.py SUBCOMMANDS -h')
subcommands.pipe('init_parser', subparsers.add_parser)

if argcomplete:
Expand Down
4 changes: 2 additions & 2 deletions hacking/build_library/build_ansible/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

class Command:
"""
Subcommands of :program:`build-ansible`.
Subcommands of :program:`build-ansible.py`.
This defines an interface that all subcommands must conform to. :program:`build-ansible` will
This defines an interface that all subcommands must conform to. :program:`build-ansible.py` will
require that these things are present in order to proceed.
"""
@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion hacking/return_skeleton_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# and creates a starting point for the RETURNS section of a module.
# This can be provided as stdin or a file argument
#
# The easiest way to obtain the JSON output is to use hacking/test-module
# The easiest way to obtain the JSON output is to use hacking/test-module.py
#
# You will likely want to adjust this to remove sensitive data or
# ensure the `returns` value is correct, and to write a useful description
Expand Down
274 changes: 0 additions & 274 deletions hacking/test-module

This file was deleted.

1 change: 1 addition & 0 deletions hacking/test-module
Loading

0 comments on commit 33d2728

Please sign in to comment.