Created
October 3, 2019 10:34
-
-
Save jeff1evesque/4df247dabc8a22062669c8b8e324a3c9 to your computer and use it in GitHub Desktop.
proto
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
### | |
### create_key.pp, create ssh key(s). | |
### | |
class sshkey::create_key { | |
$directory_path = '/etc/puppetlabs/puppetserver/ssh' | |
$ssh_keys = $::sshkey::params::ssh_keys | |
$ssh_keys.each |Integer $index, String $value| { | |
$ssh_key = basename($value, '.git') | |
$certs = [ | |
"${directory_path}/${ssh_key}", | |
"${directory_path}/${ssh_key}.pub" | |
] | |
ssh_keygen { 'puppet': | |
type => 'rsa', | |
bits => 4096, | |
filename => "/etc/puppetlabs/puppetserver/ssh/${ssh_key}", | |
before => File[ $certs ] | |
} | |
file { $certs: | |
ensure => present, | |
owner => 'puppet', | |
group => 'root', | |
mode => '600', | |
} | |
} | |
} |
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
### | |
### create_directory.pp, create directory. | |
### | |
class sshkey::create_directory { | |
$directories = [ | |
'/etc/puppetlabs', | |
'/etc/puppetlabs/puppetserver', | |
'/etc/puppetlabs/puppetserver/ssh' | |
] | |
## create log directories | |
file { $directories: | |
ensure => 'directory', | |
owner => 'puppet', | |
group => 'root', | |
mode => '750', | |
} | |
} |
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
### | |
### create_key.pp, create ssh key(s). | |
### | |
class sshkey::create_key { | |
$directory_path = '/etc/puppetlabs/puppetserver/ssh' | |
$ssh_keys = $::sshkey::params::ssh_keys | |
$ssh_keys.each |Integer $index, String $value| { | |
$ssh_key = basename($value, '.git') | |
$certs = [ | |
"${directory_path}/${ssh_key}", | |
"${directory_path}/${ssh_key}.pub" | |
] | |
ssh_keygen { 'puppet': | |
type => 'rsa', | |
bits => 4096, | |
filename => "/etc/puppetlabs/puppetserver/ssh/${ssh_key}", | |
before => File[ $certs ] | |
} | |
file { $certs: | |
ensure => present, | |
owner => 'puppet', | |
group => 'root', | |
mode => '600', | |
} | |
} | |
} |
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
### | |
### init.pp: create sshkey | |
### | |
class sshkey ( | |
$sshkeys = $::puppetserver::params::ssh_keys | |
) inherits ::sshkey::params { | |
class { 'sshkey::create_directory': } -> | |
class { 'sshkey::create_key': } -> | |
class { 'sshkey::add_key': } | |
} |
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
### | |
### params.pp: default class parameters. | |
### | |
class sshkey::params { | |
$hiera = lookup( { 'name' => 'puppetserver', 'default_value' => false } ) | |
if $hiera { | |
$ssh_keys = $hiera['ssh_keys'] | |
} | |
else { | |
$ssh_keys = [] | |
} | |
} |
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 the puppetserver configurations. | |
## | |
puppetserver: | |
ssh_keys: | |
- '[email protected]:account/repo.git' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment