This repository has been archived by the owner on Jan 29, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sidekiq support with puppet and r10k libs
Added sidekiq gem and configuration. Replaced old r10k methods with r10k libs and sidekiq workers. Replaced generate_types method with Puppet helpers.
- Loading branch information
1 parent
e9ebb0c
commit f4b2073
Showing
12 changed files
with
187 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
require 'puppet/generate/type' | ||
|
||
module PuppetHelpers | ||
# Return an array of modulepaths for the Puppet environment. | ||
# | ||
# @api public | ||
# | ||
# @param name [String] Name of the environment | ||
# @param paths [Array] Array of absolute paths. | ||
# | ||
# @return Array | ||
def self.mod_paths(name, paths) | ||
return paths unless paths.empty? | ||
|
||
["/etc/puppetlabs/code/environments/#{name}/modules"] | ||
end | ||
|
||
# Create new environment object that will be used for the Puppet Generate types. | ||
# | ||
# @api public | ||
# | ||
# @param name [String] Name of the environment | ||
# @param paths [Array] Array of module path(s) for the environment | ||
# | ||
# @return Puppet::Node::Environment | ||
def self.set_environment(name, paths = []) | ||
module_path = PuppetHelpers.mod_paths(name, paths) | ||
|
||
Puppet::Node::Environment.create(name, module_path) | ||
end | ||
|
||
# Find the inputs from the environment's modulepath | ||
# | ||
# @api public | ||
# | ||
# @param environment [Puppet::Node::Environment] A Puppet environment object. | ||
# | ||
# @return Array[Puppet::Generate::Type::Input] | ||
def self.find_inputs(environment) | ||
Puppet::Generate::Type.find_inputs(:pcore, environment) | ||
end | ||
|
||
# Generate type files from puppet inputs and place them in the output directory. | ||
# | ||
# @api public | ||
# | ||
# @param inputs [Array[Puppet::Generate::Inputs]] Array of Puppet inputs | ||
# @param output [String] Output directory for the generated types. | ||
def self.gen_types(inputs, output) | ||
FileUtils.mkdir(output) unless File.directory?(output) | ||
types = Puppet::Generate::Type.generate(inputs, output) | ||
logger.info(types.message) unless types.nil? | ||
end | ||
end |
Oops, something went wrong.