Code Monkey home page Code Monkey logo

ansible-template-validator's Introduction

ansible-config-validator

image Build Status

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.

ansible-template-validator's People

Contributors

naimetti avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.