Skip to content
Ruby wrapper around Ansible
Ruby Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows Tweak new functionality, augment tests Sep 24, 2019
bin Tweak new functionality, augment tests Sep 24, 2019
examples/streaming Tweak new functionality, augment tests Sep 24, 2019
lib Bump version, release 0.2.2 [ci skip] Sep 26, 2019
spec
.gitignore Initial commit Jul 10, 2015
.rspec Initial commit Jul 10, 2015
.travis.yml
Gemfile Initial commit Jul 10, 2015
LICENSE.txt Initial commit Jul 10, 2015
README.md
Rakefile Initial commit Jul 10, 2015
ansible-wrapper.gemspec

README.md

Ansible Wrapper

Gem Version Build Status Coverage Status Code Climate Documentation

A lightweight Ruby wrapper around Ansible that allows for ad-hoc commands and playbook execution. The primary purpose is to support easy streaming output.

Requirements

Ensure Ansible is installed and available to shell commands i.e. in PATH. Tested with Ansible versions 2.0.2 thru 2.8.5 and Ruby 2.1+, but please create an issue if you use a version that fails.

Installation

Add this line to your application's Gemfile:

gem 'ansible-wrapper'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ansible-wrapper

Usage

Ad-hoc commands

Ansible::AdHoc.run 'all -i localhost, --list-hosts'
Ansible::AdHoc.run 'all -m shell -a "echo Test" -i localhost,'

Playbooks

Ansible::Playbook.run '-i localhost, spec/fixtures/mock_playbook.yml'
Ansible::Playbook.stream('-i localhost, spec/fixtures/mock_playbook.yml') # defaults to standard output
Ansible::Playbook.stream('-i localhost, spec/fixtures/mock_playbook.yml') { |line_of_output| puts line_of_output }

Shortcuts

To enable shortcuts:

Ansible.enable_shortcuts!

You can then access Ansible via the A alias and use the following syntax:

A['all -i localhost, --list-hosts'] # alias for Ansible::AdHoc.run
A << '-i localhost, spec/fixtures/mock_playbook.yml' # alias for Ansible::Playbook.stream

Examples

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake rspec 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/pgeraghty/ansible-wrapper-ruby.

License

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

You can’t perform that action at this time.