GithubHelp home page GithubHelp logo

czeumer / chef-provisioning-ssh Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chef-boneyard/chef-provisioning-ssh

0.0 2.0 0.0 216 KB

Provision Machines Via SSH or WinRM Using Chef Provisioning

License: MIT License

Ruby 100.00%

chef-provisioning-ssh's Introduction

Gem Version

Chef::Provisioning::Ssh

TODO: Write a gem description

Installation

Add this line to your application's Gemfile: e

gem 'chef-provisioning-ssh'

And then execute:

$ bundle

Or install it yourself as:

$ gem install chef-provisioning-ssh

Usage

The machine_options for provisioning ssh now use the key transport_options which line up directly with the transport_options for chef-provisioning proper.

The transport_options key must be a symbol.

Sub-keys should be strings.

The transport_options can be viewed in the code for chef-provisioning here:

https://github.com/chef/chef-provisioning/blob/master/lib/chef/provisioning/transport/ssh.rb#L17-L34

The snippet from that link is:

   - host: the host to connect to, e.g. '145.14.51.45'
   - username: the username to connect with
   - ssh_options: a list of options to Net::SSH.start
   - options: a hash of options for the transport itself, including:
     - :prefix: a prefix to send before each command (e.g. "sudo ")
     - :ssh_pty_enable: set to false to disable pty (some instances don't
       support this, most do)
     - :ssh_gateway: the gateway to use, e.g. "[email protected]:222".
       nil (the default) means no gateway. If the username is omitted,
       then the default username is used instead (i.e. the user running
       chef, or the username configured in .ssh/config).
  
   The options are used in
     Net::SSH.start(host, username, ssh_options, options)

In addition to host, ip_address and hostname are also additional options.

  • the ssh_options key accepts options from Net::SSH.start, the full list can be seen here:

    http://net-ssh.github.io/ssh/v2/api/classes/Net/SSH.html#M000002

  • full machine_options for SSH example:

      with_machine_options  :transport_options => {
              'is_windows' => false,
              'ip_address' => '192.168.33.23',
              'host' => 'somehost',
              'username' => 'vagrant',
              'ssh_options' => {
                  'auth_methods' => '', 
                  'bind_address' => '',
                  'compression' => '',
                  'compression_level' => '',
                  'config' => '',
                  'encryption' => '',
                  'forward_agent' => '',
                  'hmac' => '',
                  'host_key' => '',
                  'keepalive' => '',
                  'keepalive_interval' => '',
                  'kex' => '',
                  'keys' => ['/home/username/.vagrant.d/insecure_private_key'],
                  'key_data' => '',
                  'languages' => '',
                  'logger' => '',
                  'paranoid' => '',
                  'password' => '',
                  'port' => '',
                  'proxy' => '',
                  'rekey_blocks_limit' => '',
                  'rekey_limit' => '',
                  'rekey_packet_limit' => '',
                  'timeout' => '',
                  'verbose' => '',
                  'global_known_hosts_file' => '',
                  'user_known_hosts_file' => '',
                  'host_key_alias' => '',
                  'host_name' => '',
                  'user' => '',
                  'properties' => '',
                  'passphrase' => '',
                  'keys_only' => '',
                  'max_pkt_size' => '',
                  'max_win_size, :send_env' => '',
                  'use_agent' => ''
              },
              'options' => {
                'prefix' => 'sudo ',
                'ssh_pty_enable' => false,
                'ssh_gateway' => 'yourgateway'
              }
            }
    
  • full machine_options for WinRM example:

      with_machine_options  :transport_options => {
                  'is_windows' => true,
                  'host' => '192.168.33.23',
                  'port' => 5985,
                  'username' => 'vagrant',
                  'password' => 'vagrant'
              }
    
  • machine resource example:

      	require 'chef/provisioning/ssh_driver'
    
      	with_driver 'ssh'
    
      	machine "ssh" do
      	  action [:ready, :setup, :converge]
      	  machine_options :transport_options => {
      	    'ip_address' => '192.168.33.22',
      	    'username' => 'vagrant',
      	    'ssh_options' => {
      	      'password' => 'vagrant'
      	    }
      	  }
      	  recipe 'vagrant::sshone'
      	  converge true
      	end
    
          ##
          # With WinRM you must use a remote chef-server
          # local-mode chef server is not currently supported
    
          with_chef_server "https://api.opscode.com/organizations/double-z",
                           :client_name => Chef::Config[:node_name],
                           :signing_key_filename => Chef::Config[:client_key]
    
      	machine "winrm" do
      	  action [:ready, :setup, :converge]
      	  machine_options :transport_options => {
      	    'is_windows' => true,
      	    'host' => '192.168.33.23',
              'port' => 5985,
      	    'username' => 'vagrant',
      	    'password' => 'vagrant'
      	  }
      	  recipe 'windows'
      	  converge true
      	end
    

To test it out, clone the repo:

git clone https://github.com/double-z/chef-provisioning-ssh.git

in the test directory there is a Vagrantfile with 2 nodes.

Run:

vagrant up

which will bring up both nodes.

Then run from the test directory:

chef-client -z -o vagrant::test_provisioning_ssh

NOTE: if the second machine fails it will be a result of issues with your vagrant key.

This will run chef-provisioning on each of the two vagrant nodes.

thats it.

party on wayne.

Contributing

  1. Fork it ( http://github.com/double-z/chef-provisioning-ssh/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

chef-provisioning-ssh's People

Contributors

double-z avatar jonsmorrow avatar pierrerambaud avatar

Watchers

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