Giter VIP home page Giter VIP logo

ansible-vault-agent's Introduction

Vault Agent

This is a simple, ssh-key-agent like agent for ansible-vault passwords.
It consists of two components, a server and a client-script.
The server will listen on a unix-socket and store tuples of vault-ids and secrets. It will serve those when requested.
The client can connect to the socket and send commands to store or retrieve secrets.

This is pure python and neither client nor server have any dependencies except standard-components, so you should be able to get this to run on any linux-machine where ansible works, even if you don't have sudo.
Only Python 3 is supported, though, and it is only tested on Linux. It should work on MacOS (not tested) and might work on the WSL on Windows (not tested, as well).

How To

The whole thing works without configuration.
Start the server by running vault-agent.py and then add a secret by running vault-agent-client.py put --vault-id <your-vault-id>. It will ask you for the secret.
You can then run vault-agent-client.py get --vault-id <your-vault-id> to retrieve the secret.
To use it in an ansible command, append --vault-id <your-vault-id>@/path/to/vault-agent-client.py.

You can also use --vault-pass-file /path/to/vault-agent-client.py. In that case, ansible will ask for vault-id default. So you need to use default as vault-id when adding the passphrase.

Options

These options are common for client and server.
You can use -v to enable debug-output.
Use -s </path/to/socket> to specify a socket. You can use ~ in the beginning to refer to your home-directory.
The -v and -s options work on the client, as well as the server. They need to be provided before the sub-command.

Client

The client has four sub-commands:

  • get to get a secret from the server (requires --vault-id)
  • put to put a secret on the server, which will fail if the vault-id is already there (requires --vault-id)
  • replace to put a secret on the server or replace it if there is already one with this vault-id (requires --vault-id)
  • exit to ask the server to stop and clean up the socket

All put and replace will ask for the secret to put on the server on stdin.
The client prints all messages to stderr to be compatible with ansible.

If you don't use the default socket, put an ini-file called vault-agent-client.ini in the directory where you run your ansible command, that contains the lines below, otherwise the client will not be able to find the socket and will fail.
When in doubt, just use the default socket.

vault-agent-client.ini:

[DEFAULT]
socket = /path/to/socket

Server

The server doesn't know any options except the ones mentioned earlier. You can send SIGINT (e.g. by pressing Ctrl + C in the terminal) to the server. It will then "forget" all secrets, clean up the socket and exit.

The server doesn't load any configuration file.

Additional Notes

Q&A:

  • Q: Are the secrets stored encrypted in RAM?
    A: No - if somebody can read your RAM, you are f****d already.
  • Q: Couldn't anybody on the machine read from the socket?
    A: No, only the user who started the server is allowed to access the socket. (root can access it, as well)
  • Q: Speaking of sockets - is the port open on the network?
    A: No! This is a unix-file-socket. No network-communication is involved.

Future Features

  • Make the server forget a secret without shutting it down
  • Daemonize the server
  • setup.py or other way to build a wheel

ansible-vault-agent's People

Contributors

toydarian avatar

Stargazers

 avatar  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.