A helper script to use with the validate option from ansible template module
Project description
ansible-config-validator
A helper script to use with the validate option from ansible template module
The module provides a command line tool to validate configuration templates in cases where the validation depends on more than one file, and there is no clear way to sandboxing the validation process.
So, for example, if you want to validate an NGINX config file that contains a server block configuration you will have to validate the entire configuration tree of NGINX files, therefore what this script does is to replace the original config file with the new one, runs the validation command, and then restores all to the previous state independently of the validation command result.
Install
pip install ansible-config-validator
Usage
usage: ansible-template-validator [-h] [-l SYMLINK]
new_file original_file validation_command
Command to be used as helper with ansible template validate. Replaces
original_file with new_file, and then run validation_command. After this,
returns validation_command return code and original_file is restored.If a
symlink is specified, in case it doesn't exists, it is created pointing to
original_file and then is deleted.
positional arguments:
new_file File used to replace original_file
original_file Original file that is going to be validated
validation_command Command to be executed to validate the config files
optional arguments:
-h, --help show this help message and exit
-l SYMLINK, --create-sym-link SYMLINK
Creates an ephemeral symbolic link pointing to
original_file, just in case it doesn't exists.
Example
- name: Update nginx {{website_config}} file
template:
src: "website.conf"
dest: "{{website_config}}"
validate: "ansible-template-validator %s {{website_config}} {{nginx_validation_command|quote}}"
vars:
website_config: "/etc/nginx/sites-enabled/website.conf"
nginx_validation_command: /usr/sbin/nginx -t -q -g 'daemon on; master_process on;
Note: The script must have been previously installed on the target node.
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
File details
Details for the file ansible_template_validator-0.1.4.tar.gz
.
File metadata
- Download URL: ansible_template_validator-0.1.4.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/2.7.15+
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74128a0547be48eacbecb61cc6f851709693b7993a6b0c840f39caa8bf1cc08b |
|
MD5 | f47213d5d3a2fc52842bf15d143c7279 |
|
BLAKE2b-256 | a8ed8526f6c1702885d154ab21a71414307e96c0b88a71e86fa613fde55cd728 |
File details
Details for the file ansible_template_validator-0.1.4-py2.py3-none-any.whl
.
File metadata
- Download URL: ansible_template_validator-0.1.4-py2.py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/2.7.15+
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bbc69f7aaa4742c653416b11e89969b99789bf96f49ddda56bfb0268927c67f |
|
MD5 | 939953dbe0cdcefd79d29d5e5c6dfadd |
|
BLAKE2b-256 | 7ec8220aefb4feb070dbefe647fe96692cf56815c075bac6d4bd6fee14987505 |