This is a demo of an Ansible Collection python.dist packaged
as a Python distribution package. It contains only one Ansible
module called boo. Given that this dist and Ansible are
installed into the same (virtual)env, it's accessible from Ansible by
FQDN python.dist.boo. Here's how you can call it adhoc-style:
$ PYTHONPATH=`pwd` ansible -m python.dist.boo -a name=Bob localhost
[WARNING]: No inventory was parsed, only implicit localhost is available
localhost | SUCCESS => {
"changed": false,
"greeting": "Hello, Bob!",
"msg": "Greeting Bob completed."
}
Alternatively, install it, instead of mangling with PYTHONPATH:
$ pip install ansible-collections.python.dist.boo
$ ansible -m python.dist.boo -a name=Bob localhost
[WARNING]: No inventory was parsed, only implicit localhost is available
localhost | SUCCESS => {
"changed": false,
"greeting": "Hello, Bob!",
"msg": "Greeting Bob completed."
}
At the moment of publishing this project, this demo only works with the code supplied by Ansible PR #67093. One can test it by installing Ansible from that PR-branch:
$ pip install git+https://github.com/sivel/ansible@acd-content-dir
This project implements automatic building and publishing of a Python
distribution package to PyPI for tagged commits and to TestPyPI for
every push to master. All the heavy lifting is done by the
combination of GitHub Actions CI/CD workflows, pep517 CLI tool and
setuptools-scm.
The published dists are then installable by:
$ pip install ansible-collections.python.dist.boo # for PyPI
and
$ pip install ansible-collections.python.dist.boo \
-i https://test.pypi.org/simple/ --pre # for TestPyPI
If you're learning by example, take a look at the following files:
pyproject.tomlsetup.cfg.github/workflows/publish-to-test-pypi.yml
Besides, you can follow a PyPA guide about publishing packages via GitHub Actions that will walk you through the process.
Python 3.7+
The source code and the documentation in this project are released under the GPL v3 license.