Code Monkey home page Code Monkey logo

ansible-host-drift's Introduction

Host-drift

Experimental playbook/role for keeping track of Host-drift using ansible and git!

The idea is to define custom checks and write the output to a file locally to a git repo on the ansible host.
At the end of the playbook run we check in the changes and push them to git.
By leveraging git we can go back to previous commits to see what has changed.
We can also make use of webhooks of the upstream git repo to notify if any changes have been detected!

Usage

Create an inventory and run the example playbook. Extra nice if we use a dynamic inventory.

# inventory

host1
host2

Create a git repo and make sure it has an upstream remote called origin.
Usually this is as simple as creating a repo on ie. Github and running the git clone procedure.
You really want to use git over ssh and ensure that your ansible host users public key is allowed to push
The drift role can't handle user authentication

$ git clone [email protected]:user/host-drift-repo.git /home/user/hostdrift

Define the local git repo path for where we are going to save the output/result.

- hosts: host1,host2
  become: true
  vars:
    git_repo_path: /home/user/hostdrift/  <--
  tasks:
  ....

Run the playbook!

$ ansible-playbook -i inventory run-host-check.yml

On the initial run it will push all the output files into your git repo.
On the second run, it will only push changes detected by git (git diff ).

ansible-host-drift's People

Watchers

 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.