Skip to main content

ansible-keepalived-config

ansible module API for working with configuration files for linux keepalived package.

Features

  • Modify the config object and any parameter inside
  • Save back the (modified) config to another (or the same) file
  • Comments in the config file are supported and can also be added
  • ansible module that supports modification of parameters and also blocks in the configuration with full idempotency

Usage

Recommended way is to install the module in your virtual environment you are using on yopur ansible controller. Then just create a symlink in your ANSIBLE_LIBRARY with the same name pointing to the installed ansible_keepalived.py (or just clone this repo or only the module file).

Parameters

  • key [required]
    This is the name of the key in the configuration you want to modify. If you need to modify a nested key, give the key as a dot seperated path.

    Example:
    vrrp_instance VI_1 {
        router_id 1
        authentication {
            user myuser
            pass mypass
        }
    }
    

    If you want to modify the authentication password, the correct key would be:
    vrrp_instance VI_1.authentication.pass

  • file [optional, default=/etc/keepalived/keepalived.conf]
    This is the source file of the keepalived configuration you want to modify

  • value [optional, required if state == present, default=none]
    The new/desired value you want your given key to have. In general, this should be just the value of your key, for example my very strong password.
    But you can also manipulate a complete configuration block:

    {
        token my-very strong t0ken even with spaces
    }
    

    Setting this value and the key to vrrp_instance VI_1.authentication, then the authentication block will be updated with all the nested contents.

    NOTE: If you have a block with an id (like vrrp_instance) and you want to modify its id, you have to fully redefine the block in the value field like so:

    vrrp_instance VI_NEW {
     router_id 3    
    }
    

    and you need to set the module parameter with_key_prefix to false (the related key would be vrrp_instance VI_1)! Keep in mind, that this is not idemptotent, as on the next execution VI_1 will not be present anymore!

  • with_key_prefix [optional, default=false]
    This automatically adds the last element of your (eventually) nested key value to the given value to build the new/updated configuration. There are special cases (like renaming a named config block), where this is requried to be set to false

  • create [optional, default=false]
    If this is true, the module will not fail when the given key is not found in the config but instead add it to the configuration. Also works for nested keys.

  • state [optional, default=present] If this is set to present, the key will be updated or not modified at all if the value already matches. If the key is not existing, it will fail if create == false. If state is absent the key will be removed from the configuration if present.

Development

Setup

To setup your dev environment, you have 2 options:

  1. local: execute the command main.sh setup. This will install a virtual python environment and install the required packages.
  2. container: Use the provided devcontainer, where everything is already installed (no need to run the setup command)

Tests

Units tests are to be developed for all public modules and methods and placed inside the tests directory. They can be executed via the command main.sh test

Packaging

The source build and wheel distrubtions can be generated via the command main.sh build. The package can then be uploaded to PyPi via the command main.sh upload.

Metadata

Release files for ansible-keepalived-config 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ansible-keepalived-config 0.1.0
File Size Uploaded Provenance Actions
ansible_keepalived_config-0.1.0.tar.gz 45.8 kB Without provenance Details for ansible_keepalived_config-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ansible-keepalived-config 0.1.0
File Interpreter ABI Platform Actions
ansible_keepalived_config-0.1.0-py3-none-any.whl Python 3 none any Details for ansible_keepalived_config-0.1.0-py3-none-any.whl

Total release size: 76.0 kB

Release files / ansible_keepalived_config-0.1.0.tar.gz

Download URL ansible_keepalived_config-0.1.0.tar.gz
Size 45.8 kB
Tags Source
SHA-256 checksum
How to use checksums
97dc4e81f91573c871bea198ee852744e0242824fed77aec83e5b5e6e5b2e4ae
BLAKE2b-256 checksum
How to use checksums
96b5a9a6f609f1e527d7e3b82d1b3de9933cced4cd3596beb7bf99caec944704
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / ansible_keepalived_config-0.1.0-py3-none-any.whl

Download URL ansible_keepalived_config-0.1.0-py3-none-any.whl
Size 30.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
079b389e96b9dff8cac2da7d53a510db25b42a9965ccc33eabb7b31aa4abfc1e
BLAKE2b-256 checksum
How to use checksums
67156df2541c341c7637ef8ad287866d185f8300c3f75feedb21082386055029
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.3

Security for ansible-keepalived-config 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page