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
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'puppet' | |
require 'yaml' | |
# Have puppet parse its config so we can call its settings | |
Puppet.initialize_settings | |
# Use puppet to manage host keys | |
def add_known_host(user, homedir, hostname) | |
ssh_dir = "#{homedir}/.ssh/" |
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
curl 'https://console.vm:4433/classifier-api/v1/groups' \ | |
-H "Accept: application/json" -H "Content-Type: application/json" \ | |
-X GET \ | |
--tlsv1 \ | |
--cacert /etc/puppetlabs/puppet/ssl/certs/ca.pem \ | |
--cert /etc/puppetlabs/puppet/ssl/certs/console.vm.pem \ | |
--key /etc/puppetlabs/puppet/ssl/private_keys/console.vm.pem \ |
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
yes y | ssh-keygen -t dsa -C "r10k" -f /root/.ssh/id_dsa -q -N '' | |
curl "http://gitlab.internal.server/api/v3/projects/1/keys" -H "PRIVATE-TOKEN: GDHAHAJggshjgdfssfNOTREAL" -H "Accept: application/json" -H "Content-type: application/json" -X POST --data "{ \"title\": \"`hostname -f`\", \"key\": \"`cat /root/.ssh/id_dsa.pub`\"}" |
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/puppetlabs/puppet/bin/ruby | |
require 'puppet' | |
service = Puppet::Type.type(:service).new({:name => 'puppet'}).provider | |
service.restart |
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
Facter.add('root_ssh_key') do | |
setcode do | |
pubkey = '/root/.ssh/id_rsa.pub' | |
File.read(pubkey).split[1] if File.exists? pubkey | |
end | |
end | |
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') |
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/face' | |
require 'yaml' | |
Puppet.parse_config | |
resources = Puppet::Face[:resource_type, '0.0.1'].search('.*',{:extra => { 'environment' => 'production' }}) | |
output = Hash.new | |
resources.each do |resource| | |
resource.arguments.each do |k,v| |
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
#!/usr/bin/ruby | |
require 'puppet_forge' | |
# Example of a module from an internal repo co-existing with forge modules. | |
#mod 'splunk', | |
# :git => 'https://internal.git.server/example/puppet-splunk.git', | |
# :commit => '3ca47046a86aef9fbfdf58cc7b418d8e7254ecb9' | |
@dependencies = [] | |
@approved = [] |
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
cat /tmp/foo.pp | |
$empty = '' | |
if $empty { | |
notify { 'condition is true': } | |
} else { | |
notify { 'condition is false': } | |
} | |
vagrant:~ zack$ /opt/puppet/bin/puppet apply /tmp/foo.pp | |
Notice: Compiled catalog for swiftstore2.corp.puppetlabs.net in environment production in 0.02 seconds |
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
augeas { 'remove_multi_hosts': | |
context => '/files/etc/hosts', | |
changes => [ | |
"rm *[canonical = 'foo.bar.com']", | |
], | |
} |