Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to puppet 4 #9

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added files/Salt-Minion-2016.3.4-AMD64-Setup.exe
Binary file not shown.
44 changes: 34 additions & 10 deletions manifests/defaults.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# defaults for salt module
class salt::defaults {

# Only needed for windows
$temp_installer = 'C:\ProgramData\PuppetLabs\Salt-Minion-2016.3.4-AMD64-Setup.exe'
# set location of conf file for master
#
$master_conf_file = $::operatingsystem ? {
Expand All @@ -9,8 +11,21 @@

# set location of conf file for minion
#
$minion_conf_file = $::operatingsystem ? {
default => '/etc/salt/minion',
$minion_conf_file = $::kernel ? {
'Linux' => '/etc/salt/minion',
'Windows' => 'C:\salt\conf\minion',
default => '/etc/salt/minion',
}

$user = $::kernel ? {
'Linux' => 'root',
'Windows' => 'SYSTEM',
default => 'root',
}
$group = $::kernel ? {
'Linux' => 'root',
'Windows' => 'administrators',
default => 'root',
}

# set templates for master and minion
Expand All @@ -20,17 +35,26 @@

# set location of grains file
#
$grains_file = $::operatingsystem ? {
default => '/etc/salt/grains',
$grains_file = $::kernel ? {
'Linux' => '/etc/salt/grains',
'Windows' => 'C:\salt\conf\grains',
default => '/etc/salt/grains',
}

case $::operatingsystem {
/Ubuntu/: {
# salt only installs init style scripts
$service_provider = debian
case $::kernel {
'Linux': {
case $::operatingsystem {
/Ubuntu/: {
# salt only installs init style scripts
$service_provider = debian
}
default: {
$service_provider = undef
}
}
}
default: {
$service_provider = undef
'Windows': {
$service_provider = windows
}
}
}
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
$minion_ipc_mode = undef,
$minion_tcp_pub_port = undef,
$minion_tcp_pull_port = undef,
$minion_grains = undef,
) inherits salt::defaults {

# Repo management
Expand Down Expand Up @@ -183,4 +184,3 @@
class {'salt::minion':}
}
# vim:shiftwidth=2:tabstop=2:softtabstop=2:expandtab:smartindent

2 changes: 1 addition & 1 deletion manifests/master/config.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# config for master
class salt::master::config {
class salt::master::config inherits salt {
file { 'master-conf':
ensure => present,
path => $salt::master_conf_file,
Expand Down
14 changes: 7 additions & 7 deletions manifests/minion/config.pp
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
class salt::minion::config {
file { 'minion-conf':
class salt::minion::config inherits salt {
file { "$salt::minion_conf_file":
ensure => present,
path => $salt::minion_conf_file,
owner => 'root',
group => 'root',
owner => $salt::user,
group => $salt::group,
mode => '0644',
content => template($salt::minion_conf_template),
}

if $salt::facter_include {
file { 'grains':
file { "$salt::grains_file":
ensure => present,
path => $salt::grains_file,
owner => 'root',
group => 'root',
owner => $salt::user,
group => $salt::group,
mode => '0644',
content => template('salt/grains.erb'),
}
Expand Down
36 changes: 32 additions & 4 deletions manifests/minion/install.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
class salt::minion::install {
package { 'salt-minion':
ensure => $salt::version,
}
class salt::minion::install inherits salt {

case $::kernel {
'Linux' : {
package { 'salt-minion':
ensure => $salt::version,
}
}
'Windows' : {
# puppet file server as msi package source is not supported
# https://docs.puppetlabs.com/puppet/4.4/reference/resources_package_windows.html
file { "$salt::temp_installer":
ensure => present,
#mode => '0644',
source => "puppet:///modules/salt/Salt-Minion-2016.3.4-AMD64-Setup.exe",
} ->
package { 'Salt Minion 2016.3.4':
ensure => $ensure_setting,
source => "$temp_installer",
install_options => ['/S']
}
#exec { 'install_minion_service':
# command => '"C:\ProgramData\PuppetLabs\Salt-Minion-2016.3.4-AMD64-Setup.exe" /S',
# unless => 'C:\\windows\\system32\\cmd.exe /c sc.exe query salt-minion',
#}
} # end Windows
default : {
# lint:ignore:80chars
fail("The Salt-minion module is not yet supported on this ${::kernel}")
# lint:endignore
}
} # end $::kernel case
}
44 changes: 17 additions & 27 deletions manifests/repo/deb.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,27 @@
include apt

case $::operatingsystem {
'Ubuntu': { # http://docs.saltstack.com/topics/installation/ubuntu.html
apt::ppa { 'ppa:saltstack/salt': }
'Ubuntu': {
$os_string = $::os['release']['full']
apt::source {'saltstack':
location => "http://repo.saltstack.com/apt/ubuntu/${os_string}/amd64/2016.11",
release => "${::lsbdistcodename}",
repos => 'main',
key => 'DE57BFBE',
key_source => "https://repo.saltstack.com/apt/ubuntu/${os_string}/amd64/2016.11/SALTSTACK-GPG-KEY.pub",
}
}
'Debian': { # http://docs.saltstack.com/topics/installation/debian.html
$deb_base_url = 'http://debian.saltstack.com/debian'
$deb_key = 'F2AE6AB9'
$deb_key_source = 'http://debian.saltstack.com/debian-salt-team-joehealy.gpg.key'
case $::lsbdistcodename {
/(squeeze|wheezy|jessie)/: {
apt::source {'saltstack':
location => $deb_base_url,
release => "${::lsbdistcodename}-saltstack",
repos => 'main',
key => $deb_key,
key_source => $deb_key_source,
}
}
'sid': {
apt::soruce {'saltstack':
location => $deb_base_url,
release => 'unstable',
repos => 'main',
key => $deb_key,
key_source => $deb_key_source,
}
}
default : { fail("${::lsbdistcodename} is not yet supported, Add it and send a pull request!") }
'Debian': {
$os_string = $::os['release']['major']
apt::source {'saltstack':
location => "http://repo.saltstack.com/apt/debian/${os_string}/amd64/2016.11",
release => "${::lsbdistcodename}",
repos => 'main',
key => 'DE57BFBE',
key_source => "https://repo.saltstack.com/apt/debian/${os_string}/amd64/2016.11/SALTSTACK-GPG-KEY.pub",
}
}
default: { fail("${::operatingsystem} is not yet supported, Add it and send a pull request!") }
}
}
# vim:shiftwidth=2:tabstop=2:softtabstop=2:expandtab:smartindent

9 changes: 8 additions & 1 deletion templates/grains.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ facter:
scope.compiler.topscope.to_hash.reject do |k,v|
k.to_s =~ /(uptime.*|last_run|timestamp|(memory|swap)free|ssh*)/ or ! v.is_a?(String)
end.sort.each do |fact| -%>
<%= fact[0] -%>:
<%= fact[0] -%>:
- <%= fact[1] %>
<% end %>
<% if @minion_grains -%>
<% @minion_grains.each do |key, value| -%>
<% if value.is_a?(String) -%>
<%= key -%>: <%= value %>
<% end -%>
<% end -%>
<% end -%>