Last active
December 20, 2015 12:59
-
-
Save Ancillas/6135084 to your computer and use it in GitHub Desktop.
Patched r10k cli/deploy.rb file.
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
require 'r10k/cli' | |
require 'r10k/deployment' | |
require 'r10k/deployment/config' | |
require 'r10k/task_runner' | |
require 'r10k/task/deployment' | |
require 'cri' | |
module R10K::CLI | |
module Deploy | |
def self.command | |
@cmd ||= Cri::Command.define do | |
name 'deploy' | |
usage 'deploy <subcommand>' | |
summary 'Puppet dynamic environment deployment' | |
description <<-DESCRIPTION | |
`r10k deploy` implements the Git branch to Puppet environment workflow | |
(https://puppetlabs.com/blog/git-workflow-and-puppet-environments/). | |
DESCRIPTION | |
required :c, :config, 'Specify a configuration file' | |
run do |opts, args, cmd| | |
puts cmd.help(:verbose => opts[:verbose]) | |
exit 0 | |
end | |
end | |
end | |
module Environment | |
def self.command | |
@cmd ||= Cri::Command.define do | |
name 'environment' | |
usage 'environment <options> <environment> <...>' | |
summary 'deploy environments and their dependent modules' | |
description <<-DESCRIPTION | |
`r10k deploy environment` creates and updates Puppet environments based on Git | |
branches. | |
Environments can provide a Puppetfile at the root of the directory to deploy | |
independent Puppet modules. To recursively deploy an environment, pass the | |
`--puppetfile` flag to the command. | |
**NOTE**: If an environment has a Puppetfile when it is instantiated a | |
recursive update will be forced. It is assumed that environments are dependent | |
on modules specified in the Puppetfile and an update will be automatically | |
scheduled. On subsequent deployments, Puppetfile deployment will default to off. | |
DESCRIPTION | |
flag :p, :puppetfile, 'Deploy modules from a puppetfile' | |
run do |opts, args, cmd| | |
deploy = R10K::Deployment.load_config(opts[:config]) | |
task = R10K::Task::Deployment::DeployEnvironments.new(deploy) | |
task.update_puppetfile = opts[:puppetfile] | |
task.environment_names = args | |
purge = R10K::Task::Deployment::PurgeEnvironments.new(deploy) | |
runner = R10K::TaskRunner.new(:trace => opts[:trace]) | |
runner.append_task task | |
#Purges are done on all non-environment data in the environment directory, but | |
#the purges are done foreach source, with no knowledge of other sources so if two | |
#sources share a directory, they will purge each other. I'm disabling the purging feature | |
#so that we can deploy from multiple repos to the same environment directory. | |
#-Greg Baker | |
# | |
#runner.append_task purge | |
runner.run | |
exit runner.exit_value | |
end | |
end | |
end | |
end | |
self.command.add_command(Environment.command) | |
module Module | |
def self.command | |
@cmd ||= Cri::Command.define do | |
name 'module' | |
usage 'module [module] <module ...>' | |
summary 'deploy modules in all environments' | |
description <<-DESCRIPTION | |
`r10k deploy module` Deploys and updates modules inside of Puppet environments. | |
It will load the Puppetfile configurations out of all environments, and will | |
try to deploy the given module names in all environments. | |
DESCRIPTION | |
run do |opts, args, cmd| | |
deploy = R10K::Deployment.load_config(opts[:config]) | |
task = R10K::Task::Deployment::DeployModules.new(deploy) | |
task.module_names = args | |
runner = R10K::TaskRunner.new(:trace => opts[:trace]) | |
runner.append_task task | |
runner.run | |
exit runner.exit_value | |
end | |
end | |
end | |
end | |
self.command.add_command(Module.command) | |
module Display | |
def self.command | |
@cmd ||= Cri::Command.define do | |
name 'display' | |
usage 'display' | |
summary 'Display environments and modules in the deployment' | |
flag :p, :puppetfile, 'Display Puppetfile modules' | |
run do |opts, args, cmd| | |
deploy = R10K::Deployment.load_config(opts[:config]) | |
task = R10K::Task::Deployment::Display.new(deploy) | |
task.puppetfile = opts[:puppetfile] | |
runner = R10K::TaskRunner.new(:trace => opts[:trace]) | |
runner.prepend_task task | |
runner.run | |
exit runner.exit_value | |
end | |
end | |
end | |
end | |
self.command.add_command(Display.command) | |
end | |
self.command.add_command(Deploy.command) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 72 is the line I commented out in the r10k source to disable environment purging.