Last active
August 29, 2015 14:20
-
-
Save acidprime/729a38031e9aeaa6d525 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/opt/puppet/bin/ruby | |
require 'puppet' | |
require 'r10k/deployment/environment' | |
Puppet.parse_config | |
keyscan = `ssh-keyscan github.com 2>/dev/null`.split | |
FileUtils.mkdir_p('/root/.ssh/') | |
FileUtils.touch('/root/.ssh/known_hosts') | |
sshkey = Puppet::Resource.new('sshkey', keyscan[0], :parameters => { | |
:ensure =>'present', | |
:target => "/root/.ssh/known_hosts", | |
:type => keyscan[1], | |
:key => keyscan[2], | |
}) | |
result, report = Puppet::Resource.indirection.save(sshkey) | |
environment = R10K::Environment::Git.new( | |
Puppet[:environment], | |
Puppet.settings[:environmentpath], | |
Puppet[:environment], | |
{ | |
:remote => Dir.pwd, | |
:ref => Puppet[:environment], | |
} | |
) | |
environment.sync | |
puppetfile = environment.puppetfile | |
puppetfile.load! | |
puppetfile.modules.each do |mod| | |
mod.sync | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More comments:
R10K::Deployment::Environment
is deprecated. UseR10K::Environment::Git.new
. The order of args was shuffled to be more sane, so make sure you check out https://github.com/puppetlabs/r10k/blob/master/lib/r10k/environment/git.rb#L26-L34