An example Ansible Collection using ansible-specdoc to generate module specification and documentation.
This project exposes a file module that allows users to create and manage simple files through Ansible.
NOTE: The file module was created exclusively as an example and should not be used in production playbooks.
This section will guide you through the basic setup process for this repository.
When developing Ansible Collections, users are required to follow a specific directory structure.
Due to how this project renders documentation, it will need to be stored outside of the ~/.ansible directory.
This can be achieved by running the following command in your desired project directory:
mkdir -p ansible_collections/linodeFrom here, you can clone this repository:
git clone git@github.com:linode/ansible-specdoc-example.git ansible_collections/linode/specdoc_exampleNow you can enter the project directory:
cd ansible_collections/linode/specdoc_exampleTo keep your project dependencies separate from your system dependencies, it is recommended that you set up a Python virtual environment.
To create the environment in the venv directory, run:
python3 -m venv venvYou can then enter this environment by running:
source venv/bin/activateTo install the dependencies for this project, run the following:
pip install -r requirements.txt -r requirements-dev.txtFrom here you can run the following Makefile target to install the collection:
make installThis collection should now be available to use through playbooks.
Please refer to the Makefile Targets section for information about running integration and sanity tests, building the project, and previewing documentation.
This project includes a few Makefile targets to allow for easier project testing and vetting.
Running the entire integration test suite:
make testintRunning a single integration test:
make TEST_ARGS="-v file_basic" testintRun sanity tests for the entire project:
make sanityPreview documentation for an individual module:
make DOC_MODULE_NAME=linode.specdoc_example.file doc-previewplugins: Contains collection modules and helpersmodules: Contains all the module implementations for this collecitonfile.py: Logic and spec for thefilemodule
module_utils: Contains shared helpers for use in modulesdocumentation: Contains documentation strings for use in modulesfile.py: Documentation fragments for thefilemodule
base_module.py: Base module class to be consumed by moduleshelpers.py: Various shared helper functions
scripts: Contains various helper scriptsgenerate_sanity_ignores.py: Generates a sanity test ignore file to disable sanity tests that are incompatible with ansible-specdoc.inject_docs.sh: Injects generated documentation strings into each Ansible module
tests: Contains testing configuration and playbookintegration/targets/file_basic/tasks/main.yaml: Thefile_basicintegration test casesanity: Contains sanity test ignore filesconfig.yml: Used to set the minimum supported Python version for testing
Want to improve ansible-specdoc-example? Please start here.