No project description provided
Project description
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 examplemy 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_prefixto false (the related key would bevrrp_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 ifcreate == false. If state isabsentthe key will be removed from the configuration if present.
Development
Setup
To setup your dev environment, you have 2 options:
- local: execute the command
main.sh setup. This will install a virtual python environment and install the required packages. - 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ansible_keepalived_config-0.1.0.tar.gz.
File metadata
- Download URL: ansible_keepalived_config-0.1.0.tar.gz
- Upload date:
- Size: 45.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97dc4e81f91573c871bea198ee852744e0242824fed77aec83e5b5e6e5b2e4ae
|
|
| MD5 |
fa5521f624d470b995fc99f23b82a8f6
|
|
| BLAKE2b-256 |
96b5a9a6f609f1e527d7e3b82d1b3de9933cced4cd3596beb7bf99caec944704
|
File details
Details for the file ansible_keepalived_config-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ansible_keepalived_config-0.1.0-py3-none-any.whl
- Upload date:
- Size: 30.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
079b389e96b9dff8cac2da7d53a510db25b42a9965ccc33eabb7b31aa4abfc1e
|
|
| MD5 |
55bb35fa890980726c7133b6e3ca913d
|
|
| BLAKE2b-256 |
67156df2541c341c7637ef8ad287866d185f8300c3f75feedb21082386055029
|