Giter Club home page Giter Club logo

chef-salt's Introduction

Salt Cookbook

Build Status

Because every Chef needs a little Salt.

Improved Remote Execution for Open Source Chef

Install Salt master and/or minion.

Why would anyone ever want to use both Salt and Chef?

I'm glad you asked!

Open Source Chef is weak in one key area that Salt just so happens to be very strong: remote execution. knife ssh "name:*" "sudo chef-client" really doesn't scale very well.

Think of Salt as the Push Jobs plugin for Open Source Chef. They're even based on the same basic messaging technology: ZeroMQ.

And as of SaltStack 2014.7, they have significantly improved Chef integration. Want to do a chef client run on all your nodes: salt "*" chef.client Then, you can use the job management commands to check on the status of your run.

And since you made or are hopefully about to make the wise decision to use this cookbook, you'll get even better Chef-Salt integration. The cookbook will automatically sync up the metadata (grains in Salt parlance) between Chef and Salt to allow you to filter on role or environment or custom markers.

Requirements

Platforms

This cooked has been confirmed to work on:

  • Ubuntu 12.04 or later
  • CentOS 5+, RedHat 5+, Scientific Linux 5+
  • Fedora 21+
  • Debian 7+ (Wheezy)

Dependencies

  • compat_resource
  • ohai

Attributes

General

  • node['salt']['version'] - Package version to be installed (defaults to nil for latest). This attribute applies to both the master and minion, since you'll want to keep their versions synced up
  • node['salt']['role']['master'] - Salt master role (defaults to salt_master)
  • node['salt']['role']['minion'] - Salt minion role (defaults to salt_minion)

Minion

  • node['salt']['minion']['master'] - Address or list of masters, if not using built-in search functionality.

  • node['salt']['minion']['environment'] - The environment in which to search for a master; or nil to search all environments (defaults to the node's environment)

  • node['salt']['minion']['config_cookbook'] and node['salt']['minion']['config_template'] allow you to override the template used to generate the minion config file /etc/salt/minion

  • node['salt']['minion']['install_opts'] allows you to specify install options for the package install statement (ex. '--nogpgcheck', but defaults to nil)

  • node['salt']['minion']['config'] - contains a hash of config values (see https://docs.saltstack.com/en/latest/ref/configuration/minion.html)

Master

  • node['salt']['master']['api']['enable'] - install salt-api package (defaults to false)

  • node['salt']['master']['api']['install_opts'] - (defaults to nil)

  • node['salt']['master']['api']['package'] - (defaults to salt-api)

  • node['salt']['master']['api']['config'] - contains a hash of config values (see https://docs.saltstack.com/en/latest/ref/netapi/all/salt.netapi.rest_cherrypy.html)

  • node['salt']['minion']['environment'] - The environment in which to search for minions; or nil to search all environments (defaults to the node's environment)

  • node['salt']['master']['config_cookbook'] and node['salt']['master']['config_template'] allow you to override the template used to generate the master config file /etc/salt/master

  • node['salt']['master']['install_opts'] allows you to specify install options for the package install statement (ex. '--nogpgcheck', but defaults to nil)

  • node['salt']['master']['config'] - contains a hash of config values (see https://docs.saltstack.com/en/latest/ref/configuration/master.html)

See attribute files for more supported attributes.

Recipes

default

Nothing; reserved to include future LWRPs.

master

Install Salt master using OS package manager.

minion

Install Salt minion using OS package manager.

Resources/Providers

None at this time.

Usage

Define two roles named salt_master and salt_minion, which include the corresponding recipes. The nodes will automatically discover each other within the same environment (when using Chef Server).

If you want your Salt Masters to operate across all environments, set node['salt']['minion']['environment'] to nil for all minions; and set node['salt']['master']['environment'] to nil for all masters.

The cookbook will automatically manage the key exchange between minions and masters. Note that once a new minion is setup, it will still be unable to communicate with the master(s) until the next Chef run on the master(s). The minion recipe registers the minion's public key and the master recipe then accepts any new keys that are registered with Chef.

Using Salt

Targetting Minions

This cookbook attempts to keep metadata synchronized between Chef and Salt.

Minions are automatically tagged (and updated on every chef-client run) with the following two standard Salt grains:

  • environment contains the chef environment of the node: salt -G "environment:production" ...
  • role contains a complete expanded list of roles assigned to the node (this includes roles within roles): salt -G "role:salt_minion" ...

In addition, you can define your own custom grains using the node['salt']['minion']['grains'] attribute. See above.

License and Author

  • Author:: Daryl Robbins
  • Author:: Grant Ridder
Copyright:: 2016, Grant Ridder
Copyright:: 2014, Daryl Robbins

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

chef-salt's People

Contributors

darylrobbins avatar herhde avatar ryanoleary avatar shortdudey123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

chef-salt's Issues

Attribute for install options in package node statement

Hello Daryl,
Great cookbook. Using it to install Salt across all our nodes. It would be nice if you could include an attribute that would allow addition of install options when installing salt-minion and salt-master.

Specifically, I need to add the --nogpgcheck option to play well in our local spacewalk repo.

Ex.

package node.salt['minion']['package'] do
version node.salt['version'] if node.salt['version']
options node.salt['minion']['install_opts'] if node.salt['minion']['install_opts']
action :install
end

search role not roles

The search functions in minion.rb and master.rb do not work for me unless I change the filter to "role:..." instead of "roles:...".

I am using chef-server-core v12.0.0.rc4 and chef client v11.16.0.

Several issues

Please forgive me if I have misread the code and some of these are not correct.

Regarding the following in the documentation under Minion: "node['salt']['minion']['environment'] - The environment in which to search for a master; or nil to search all environments (defaults to the node's environment)"
1) Was this supposed to be node['salt']['master']['environment']? The documentation Master section refers to node['salt']['minion']['environment'] which seems to be right if I am interpreting the intent correctly.
2) The code appears to be using node.salt['minion']['master_environment'] to search for master(s). which isn't either of the above.. It seems like it should be using node.salt['master']['environment'] to me.
3) The code doesn't appear to handle the case of it being null as advertised in the documentation.
4) The code doesn't appear to handle the default case as advertised in the documentation.
5) The code does refer to this attribute when the value is "_default", but that is not documented anywhere.

Regarding the corresponding Documentation under Master:
6) The master recipe code appears to be using node.salt['master']['environment'] to look for minions. Should that be node.salt['minion']['environment'] as documented?
7) Same as #3 above
8) Same as #4 above

Thank you for your cookbook, and thank you for considering my comments.

create lwrp external_auth

allow wrapper cookbook to create external auth configuration files under /etc/salt/master.d/ using LWRP.

will submit a PR shortly.

use salt api for minion key accept

Currently, this cookbook uses Ohai salt and node attributes to auto accept the minion key.

I am working on PR which uses salt-api to accept the minion key. Below are the PR details.

  • add new attribute default['salt']['key_accept_method']

    • default['salt']['key_accept_method'] = 'pub_key_sync' # options: pub_key_sync, api_key_accept
  • configure ohai only if node['salt']['key_accept_method'] == 'pub_key_sync' as much as possible across the recipes

  • make API call to master to accept minion key only_if

    • minion key has not been already accepted
    • node['salt']['key_accept_method'] == 'api_key_accept'
    • print warning message if failed to accept
  • configure master with an external_auth pam user and password by default, which is optional and controlled by attribute default['salt']['master']['api']['enable_default_user']

    • check if default['salt']['master']['api']['enable'] == true
    • check if default['salt']['master']['api']['enable_default_user'] == true
    • add linux user default['salt']['master']['api']['default_user_name'] & default['salt']['master']['api']['default_user_password']
    • add external_auth pam user config for default['salt']['master']['api']['default_user'] with permissions *, @wheel, @runner to /etc/salt/master
external_auth:
  pam:
    default-user:
      - .*
      - '@wheel'
      - '@runner'
  • add attributes for recipes/minion to make API call to master
default['salt']['minion']['api'] = {
  'host' => 'localhost',
  'port' => 8000,
  'username' => 'default-user',
  'password' => 'default-passwd',
  'eauth' => 'pam',
  'use_ssl' => true,
  'verify' => false
}

fix for helper salt_config immutable mash

/etc/salt/master:

    +---
    +external_auth:
    +  pam:
    +    saltapi: !ruby/array:Chef::Node::ImmutableArray
    +      internal:
    +      - "@wheel"
    +      - "@runner"
    +      ivars:
    +        :@__path__: []
    +        :@__root__:
    +        :@__node__:
    +        :@__precedence__:

Instead, use below code (been using it in numerous cookbooks).

$ git diff libraries/helpers.rb
diff --git a/libraries/helpers.rb b/libraries/helpers.rb
index 9412bca..2571e12 100644
--- a/libraries/helpers.rb
+++ b/libraries/helpers.rb
@@ -6,7 +6,7 @@ require 'mixlib/log'

 module SaltCookbookHelper
   def salt_config(config)
-    config.to_hash.compact.sorted_hash.to_yaml
+    JSON.parse(config.to_json).to_yaml.lines.to_a[1..-1].join
   end
 end

Will submit a PR.

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.