Skip to main content

A python package to automate documentation generation for ansible roles.

Project description

ansible-mdgen

<CircleCI>

Generate documentation for ansible roles

Description

This package reads all task and variables files and creates equivalent .md files in the docs directory of the role. It also allows you to configure it so that you can combine tasks into a single .md file.

If docs directory does not exist then it will be created.

The script iterates over each of the tasks files, parsing the yaml to extract the "name" values from each task and writing it to the .md file. So good descriptions on the task names will lead to better documentation.

To install

pip install ansible-mdgen

To run

Call ansible-mdgen passing in the path to the role

ansible-mdgen <path_to_role>

See --help for all available options

To configure

Create a configuration file called ansible-mdgen.yaml in the root of the project that you want to document. Alternatively rename the config file to something else and specify this in the command line using the -C or --conf options.

ansible-mdgen <path_to_role> --conf <name_of_config_file>

In the configuration file you can specify to combine various task files into a single md file for output e.g.

tasks:
  combinations:
    - filename: <name_of_single_file_to_create_1>
      files_to_combine:
        - name: <name_of_file_to_include_1>
        - name: <name_of_file_to_include_2>
        - name: <name_of_file_to_include_3>
    - filename: <name_of_single_file_to_create_2>
      files_to_combine:
        - name: <name_of_file_to_include_1>
        - name: <name_of_file_to_include_2>

e.g. 

tasks:
  combinations:
    - filename: SystemSetup
      files_to_combine:
        - name: install-packages.yml
        - name: configure-services.yml
        - name: start-services.yml
    - filename: UserSetup
      files_to_combine:
        - name: create-users.yml
        - name: assign-privileges.yml

Combining tasks in a single .md file may be useful where related tasks have been broken down logically into different files but for documentation readability are better suited to being in one file.

To annotate

To provide and output default variable descriptions add a comment with the var annotation as follows:

# @var: <variable_name>: <variable_description>

Note: currently only available for defaults and vars directory files...

To debug

Pass the options -vvv for debugging

Credits

The idea for this project is based on (and includes some code from) ansible-autodoc by Andres Bott so credit to him for his work.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ansible-mdgen-0.0.8.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

ansible_mdgen-0.0.8-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file ansible-mdgen-0.0.8.tar.gz.

File metadata

  • Download URL: ansible-mdgen-0.0.8.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

File hashes

Hashes for ansible-mdgen-0.0.8.tar.gz
Algorithm Hash digest
SHA256 854c9ec2a3b921e8854e542e828d6d07812d3a117c40b0135d4d4793461bb0df
MD5 0ed6cbc25b8b090531b72d73c604933e
BLAKE2b-256 3f80c137fbef57036fa344acb29874af2810037e6b098698fa1a0cfdb24d1536

See more details on using hashes here.

File details

Details for the file ansible_mdgen-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: ansible_mdgen-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

File hashes

Hashes for ansible_mdgen-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 f07b3f4bf7b50d1e9c730f2b164d1c992b6a5accc9ccf15d858289d9455804d7
MD5 386040e0fd0994d15840eedbe39f0a37
BLAKE2b-256 aa4a5e459c75153edd45e970dd6253bc561c854b19a2dac9c0b9dd953a32a4e8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page