Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

inprovise-fork

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inprovise-fork

  • 0.2.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Inprovise Fork

This project implements an extension for the Inprovise provisioning tool providing a fork method to the execution contexts of Inprovise scripts allowing scripts to fork off provisioning commands (apply, revert, validate or trigger) for other nodes.

Build Status Code Climate Test Coverage Gem Version

Installation

$ gem install inprovise-fork

Usage

Add the following to (for example) your Inprovise project's rigrc file.

require 'inprovise/fork'

Syntax

fork(mode = :sync).apply('script', 'name'[, 'name'[, ...]][, config={}])
fork(mode = :sync).revert('script', 'name'[, 'name'[, ...]][, config={}])
fork(mode = :sync).validate('script', 'name'[, 'name'[, ...]][, config={}])
fork(mode = :sync).trigger('action', 'name'[, 'name'[, ...]][, config={}])

or

fork(mode = :sync) do
  apply('script', 'name'[, 'name'[, ...]][, config={}])  
end
fork(mode = :sync) do
  revert('script', 'name'[, 'name'[, ...]][, config={}])
end
fork(mode = :sync) do 
  validate('script', 'name'[, 'name'[, ...]][, config={}])
end
fork(mode = :sync) do
  trigger('action', 'name'[, 'name'[, ...]][, config={}])
end

The mode argument can be :sync (default) or :async. With the first the provisioning methods will not return until the provisioning process they kicked off has finished. With the latter the provisioning methods kick off the provisioning process in parallel and return immediately.

The provisioning methods return a reference to the forking execution context allowing provisioning methods to be chained like:

fork.apply('script', 'node1').trigger('action', 'node1')

Example

By combining the Inprovise-VBox plugin and the Inprovise-Fork plugin provisioning scripts could add a virtual machine on a host server, register an Inprovise node and provision that new node with a single rig command using a scheme like this:

# assumes rigrc has been defined with
# require 'inprovise/vbox' and
# require 'inprovise/fork'

include 'rubysetup.rb'  # includes a scheme defining scripts to control ruby provisioning dependencies

script 'vmSetup' do

  validate do
    # check node setup
    trigger 'gem:exists', 'rails'
  end

  apply do
    trigger 'gem:install', 'rails'
  end
  
  revert do
    trigger 'gem:uninstall', 'rails'
  end
  
end


vbox 'myVM' do
    configuration ({
      :name => 'MyVM',
      :image => '/remote/image/path/MyVM.qcow2',
      :memory => 1024,
      :cpus => 2  
    })

    apply do
      fork(:async).apply('vmSetup', 'MyVM')
    end
    
    revert do
      # in real life you may not want to do this to be able to reinstate 
      # the VM faster with all setup already in place   
      fork(:sync).revert('vmSetup', 'MyVM')
    end
end

end

FAQs

Package last updated on 20 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc