Giter VIP home page Giter VIP logo

vaultsearch's Introduction

vaultsearch

vaultsearch is a Python 3 script that uses built-in Python and Ansible modules to recursively search for given terms in all found vault files.

If you configured vault_password_file in ansible.cfg, it will use that -- otherwise, it will prompt for the vault password upon usage.

Note: I don't think it will find vault encrypted strings as I rarely use them and didn't consider them while writing the script.


Install

  • Clone the repo or download the file.
  • Copy or symlink the script to somewhere in your $PATH.
  • It is also possible to place the script in the top level of the playbook and run it from there.

Usage

  • Recursively search all vault files starting in your current working directory:
vaultsearch 'searchterm'
  • For a shorter file path output use . as a location:
vaultsearch 'searchterm' .
  • Recursively search all vault files starting from specified directory:
vaultsearch 'searchterm' host_vars/myhost
  • Recursively search with regex patterns (I haven't tested many regex patterns yet):
vaultsearch 'searchterm|otherterm' group_vars/all

Additional Information

I had originally used a bash script which worked well, but took a long time when parsing the entire playbook.

Initial testing on a medium sized playbook shows this script can be up to 20x faster!:

# Bash Script
time vaultgrep 'user_001' .
<--snip-->
real    1m31.351s
user    1m21.560s
sys     0m8.327s

# Python Script
time vaultsearch 'user_001' .
<--snip-->
real    0m3.795s
user    0m3.743s
sys     0m0.044s

Disclaimer

I do not have much experience with Python and pieced this together with snippets that I found from around the web.

Any pull requests improving the code and/or performance are welcomed.


Links

vaultsearch's People

Contributors

chuckn246 avatar

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.