Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

RSS

ssh (14) Versions 0.10.2

LWRPs for managing SSH known_hosts and config files

Berkshelf/Librarian
Policyfile
Knife
cookbook 'ssh', '= 0.10.2'
cookbook 'ssh', '= 0.10.2', :supermarket
knife cookbook site install ssh
knife cookbook site download ssh
README
Dependencies
Changelog
Quality

Chef SSH

Description

Provides 2 LWRPs to manage system-wide and per-user ssh_config and known_host files.

Setup

Include the ssh cookbook via Berkshelf or Librarian.

cookbook "ssh"

Or add the following line to your cookbook's metadata.rb.

depends "ssh"

Usage

When using SSH with Chef deployments, it's crucial to not get any prompts for input. Adding entries to known_hosts files and better managing your per-connection configuration can help with this.

An important thing to note is that if you create a user during a chef run, be sure to reload OHAI data so that the new user will be in the node data. For instance:

ohai "reload_passwd" do
    plugin "passwd"
end

The ssh cookbook bypasses this need somewhat by using ohai classes directly to discover your users' ssh paths. However some of your cookbooks may not be as generous.

Resources and Providers

known_hosts

Actions

<table> <thead> <tr> <th>Action</th><th>Description</th><th>Default</th> </tr> </thead> <tbody> <tr> <td>add</td> <td>Adds an entry for the given host to a known_hosts file</td> <td>Yes</td> </tr> <tr> <td>remove</td> <td>Removes entries for a host from a known_hosts file</td> <td> </td> </tbody> </table>

Attributes

<table> <thead> <tr> <th>Attribute</th><th>Description</th><th>Default Value</th> </tr> </thead> <tbody> <tr> <td>host</td> <td> <b>Name attribute:</b> the FQDN for a host to add to a known_hosts file </td> <td><code>nil</code></td> </tr> <tr> <td>hashed</td> <td>A Boolean indicating if SSH is configured to use a hashed known_hosts file. </td> <td><code>true</code></td> </tr> <tr> <td>key</td> <td>A full line to add to the file, instead of performing a lookup for the host. </td> <td><code>nil</code></td> </tr> <tr> <td>user</td> <td>A username to add the known_hosts entry for. If unspecified, the known_host will be added system-wide. <b>Note:</b> if specified, the user must already exist. </td> <td><code>nil</code></td> </tr> <tr> <td>path</td> <td>A full path to a known_hosts file. If used with the user attribute, this will take precedence over the path to a user's file, but the file will be created (if necessary) as that user. </td> <td><code>nil</code></td> </tr> </tbody> </table>

Example

ssh_known_hosts "github.com" do
  hashed true
  user 'webapp'
end

config

Actions

<table> <thead> <tr> <th>Action</th><th>Description</th><th>Default</th> </tr> </thead> <tbody> <tr> <td>add</td> <td>Adds an entry for the given host to a ssh_config file</td> <td>Yes</td> </tr> <tr> <td>remove</td> <td>Removes entries for a host from a ssh_config file</td> <td> </td> </tbody> </table>

Attributes

<table> <thead> <tr> <th>Attribute</th><th>Description</th><th>Default Value</th> </tr> </thead> <tbody> <tr> <td>host</td> <td> <b>Name attribute:</b> the string to match when connecting to a host. This can be an IP, FQDN (github.com), or contain wildcards (*.prod.corp) </td> <td><code>nil</code></td> </tr> <tr> <td>options</td> <td>A hash containing the key-values to write for the host in </td> <td><code>true</code></td> </tr> <tr> <td>user</td> <td>A username to add the ssh_config entry for. If unspecified, the entry will be added system-wide. <b>Note:</b> if specified, the user must already exist. </td> <td><code>nil</code></td> </tr> <tr> <td>path</td> <td>A full path to a ssh config file. If used with the user attribute, this will take precedence over the path to a user's file, but the file will be created (if necessary) as that user. </td> <td><code>nil</code></td> </tr> </tbody> </table>

Example

ssh_config "github.com" do
  options 'User' => 'git', 'IdentityFile' => '/var/apps/github_deploy_key'
  user 'webapp'
end

CHANGELOG for ssh

0.10.2

  • Update the README
  • Fix some spec tests
  • Fix bug in config that did not allow HostName directive

0.10.0

  • MAJOR rewrite, but no breaking changes known of.

0.6.5

  • Add an option for the ssh port number to known_hosts (Scott Arthur)

0.6.4

  • Use OHAI to determine the user's $HOME (Tom Duckering)

0.6.3:

  • Fixed libary to make /root instead of /home/root work (Vincent Gijsen)
  • Correct default action for config resource (joelwurtz)
  • Use the correct user and path for the remove action (roderik)

0.6.0:

  • Initial release of ssh

Foodcritic Metric
            

0.10.2 failed this metric

FC023: Prefer conditional attributes: /tmp/cook/0daafa722e5caa46953a8e58/ssh/providers/known_hosts.rb:37