2013-04-20 09:33:52 -04:00
|
|
|
'Hacking' directory tools
|
|
|
|
|
=========================
|
|
|
|
|
|
2018-05-21 16:14:53 -07:00
|
|
|
env-setup
|
2013-04-20 09:33:52 -04:00
|
|
|
---------
|
|
|
|
|
|
|
|
|
|
The 'env-setup' script modifies your environment to allow you to run
|
2025-07-30 16:39:38 -07:00
|
|
|
ansible from a git checkout using a supported Python version.
|
2013-04-20 09:33:52 -04:00
|
|
|
|
|
|
|
|
First, set up your environment to run from the checkout:
|
|
|
|
|
|
2023-07-11 14:40:47 -07:00
|
|
|
```shell
|
|
|
|
|
source ./hacking/env-setup
|
|
|
|
|
```
|
2013-04-20 09:33:52 -04:00
|
|
|
|
|
|
|
|
You will need some basic prerequisites installed. If you do not already have them
|
|
|
|
|
and do not wish to install them from your operating system package manager, you
|
|
|
|
|
can install them from pip
|
|
|
|
|
|
2023-07-11 14:40:47 -07:00
|
|
|
```shell
|
2024-09-06 17:13:06 +02:00
|
|
|
python -Im ensurepip # if pip is not already available
|
2023-07-11 14:40:47 -07:00
|
|
|
pip install -r requirements.txt
|
|
|
|
|
```
|
2013-04-20 09:33:52 -04:00
|
|
|
|
2014-01-28 20:29:24 -05:00
|
|
|
From there, follow ansible instructions on docs.ansible.com as normal.
|
2013-04-20 09:33:52 -04:00
|
|
|
|
2019-07-02 12:18:40 -07:00
|
|
|
test-module.py
|
|
|
|
|
--------------
|
2013-04-20 09:33:52 -04:00
|
|
|
|
2019-07-02 12:18:40 -07:00
|
|
|
'test-module.py' is a simple program that allows module developers (or testers) to run
|
2013-04-20 09:33:52 -04:00
|
|
|
a module outside of the ansible program, locally, on the current machine.
|
|
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
2023-07-11 14:40:47 -07:00
|
|
|
```shell
|
|
|
|
|
./hacking/test-module.py -m lib/ansible/modules/command.py -a "echo hi"
|
|
|
|
|
```
|
2013-04-20 09:33:52 -04:00
|
|
|
|
|
|
|
|
This is a good way to insert a breakpoint into a module, for instance.
|
|
|
|
|
|
2015-05-28 14:43:25 -04:00
|
|
|
For more complex arguments such as the following yaml:
|
|
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
|
parent:
|
|
|
|
|
child:
|
|
|
|
|
- item: first
|
|
|
|
|
val: foo
|
|
|
|
|
- item: second
|
|
|
|
|
val: boo
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Use:
|
|
|
|
|
|
2023-07-11 14:40:47 -07:00
|
|
|
```shell
|
|
|
|
|
./hacking/test-module.py -m module \
|
|
|
|
|
-a '{"parent": {"child": [{"item": "first", "val": "foo"}, {"item": "second", "val": "bar"}]}}'
|
|
|
|
|
```
|
2015-05-28 14:43:25 -04:00
|
|
|
|
2017-10-01 14:55:52 -07:00
|
|
|
return_skeleton_generator.py
|
|
|
|
|
----------------------------
|
|
|
|
|
|
|
|
|
|
return_skeleton_generator.py helps in generating the RETURNS section of a module. It takes
|
|
|
|
|
JSON output of a module provided either as a file argument or via stdin.
|