0.04
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
A ruby implementation of Ansible's vault utilities. Currently supports the AES256 variant, no support for the original AESformat is planned.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 8.2
< 3.1.0
~> 10.0
~> 3.0
~> 0.8.7

Runtime

 Project Readme

Ansible::Vault

Build Status

A ruby implementation of the Ansible vault file format for use in tooling that needs to work with the vaults but doesn't want to shell out. The goal is to provide an IO like API for interacting with the files, basic reading and writing will be implemented first with a stream interface coming later if the need arises. The API design is inspired by Ruby's IO class for ease of adoption and [http://nacl.cr.yp.to/](NaCl's crypto_box) in that it takes care of doing the right things for the user.

Installation

Add this line to your application's Gemfile:

gem 'ansible-vault'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ansible-vault

Usage

Reading the contents of a vault

require 'ansible/vault'

contents = Ansible::Vault.read(path: '/path/to/file', password: 'foobar')
  # => 'These are the secrets that I keep.'

Yep, that's it! This call opens the vault file, verifies the included HMAC, and (assuming the HMAC checks out) decrypts the contents of the file and returns the String representation of the contents.

Writing new contents to a vault

require 'ansible/vault'

Ansible::Vault.write({
  path: '/path/to/file',
  password: 'foobar',
  plaintext: 'My secrets.'
}) # => #<File:(closed)>

This call overwrites anything at the path specified with the cyphertext of the supplied contents. The plaintext is expected to have been cast to a string prior to being passed to this function.

Development

After checking out the repo, run bin/setup to check for the required dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/tpickett66/ansible-vault-rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.