Skip to content

added support for windows #12

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

Open
wants to merge 3 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
4 changes: 4 additions & 0 deletions provision/manifests/default.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
if $hostname == 'puppet' {
class { 'puppet::server': }
}

if $operatingsystem == 'windows' {
include certificates
}
28 changes: 28 additions & 0 deletions provision/modules/certificates/manifests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Class: certificates
#
#
class certificates {

if $::operatingsystem == 'windows' {
exec { 'remove_dupilcate_cert_thwarte':
command => 'CertUtil -delstore Root BE36A4562FB2EE05DBB3D32323ADF445084ED656',
path => 'c:/Windows/System32',
logoutput => true,
#refreshonly => true,
creates => 'c:/thwarte_removed.txt',
}

file { 'c:/thwarte_removed.txt':
ensure => file,
content => 'true',
require => Exec [ 'remove_dupilcate_cert_thwarte' ],
}
}
}


# $store = New-Object System.Security.Cryptography.X509Certificates.X509Store “Root”
# $store.Open(“ReadWrite”)
# foreach ($certi in $store.Certificates){if ($certi.friendlyname -eq 'thawte' -AND $certi.Thumbprint -eq 'BE36A4562FB2EE05DBB3D32323ADF445084ED656'){$certi}}
# foreach ($certi in $store.Certificates){if ($certi.friendlyname -eq 'thawte' -AND $certi.Thumbprint -eq 'BE36A4562FB2EE05DBB3D32323ADF445084ED656'){$store.Remove($certi)} }
# foreach ($certi in $store.Certificates){if ($certi.friendlyname -eq 'thawte' -AND $certi.Thumbprint -eq 'BE36A4562FB2EE05DBB3D32323ADF445084ED656'){$certi}}
2 changes: 1 addition & 1 deletion provision/modules/mirrors/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class { 'mirrors::apt': }
}
default: {
fail("Module '${module_name}' is not currently supported by Puppet Sandbox on ${::operatingsystem}")
warning("Module '${module_name}' is not currently supported by Puppet Sandbox on ${::operatingsystem}")
}
}

Expand Down
21 changes: 15 additions & 6 deletions provision/modules/networking/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,20 @@
#
class networking {

file { '/etc/hosts':
owner => 'root',
group => 'root',
mode => '0644',
content => template('networking/hosts.erb'),
}
case $::operatingsystem {
'windows': {
file { 'c:/Windows/System32/drivers/etc/hosts':
content => template('networking/hosts-win.erb'),
}
}

default: {
file { '/etc/hosts':
owner => 'root',
group => 'root',
mode => '0644',
content => template('networking/hosts.erb'),
}
}
}
}
34 changes: 34 additions & 0 deletions provision/modules/networking/templates/hosts-win.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost
127.0.1.1 <%= @fqdn %>

172.16.32.10 puppet.<%= @domain %> puppet
172.16.32.11 client1.<%= @domain %> client1
172.16.32.12 client2.<%= @domain %> client2

# The following lines are desirable for IPv6 capable hosts
# ::1 localhost ip6-localhost ip6-loopback
# fe00::0 ip6-localnet
# ff00::0 ip6-mcastprefix
# ff02::1 ip6-allnodes
# ff02::2 ip6-allrouters
36 changes: 22 additions & 14 deletions provision/modules/puppet/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,30 @@
}
}

package { 'puppet':
ensure => $ensure,
}
if $osfamily == 'windows' {
service { 'puppet':
enable => true,
ensure => running,
}
} else {
package { 'puppet':
ensure => $ensure,
}

# required to start client agent on ubuntu
exec { 'start_puppet':
command => '/bin/sed -i /etc/default/puppet -e "s/START=no/START=yes/"',
onlyif => '/usr/bin/test -f /etc/default/puppet',
require => Package[ 'puppet' ],
before => Service[ 'puppet' ],
service { 'puppet':
enable => true,
ensure => running,
require => Package[ 'puppet' ],
}
}

service { 'puppet':
enable => true,
ensure => running,
require => Package[ 'puppet' ],
if $::operatingsystem != 'windows' {
# required to start client agent on ubuntu
exec { 'start_puppet':
command => '/bin/sed -i /etc/default/puppet -e "s/START=no/START=yes/"',
onlyif => '/usr/bin/test -f /etc/default/puppet',
require => Package[ 'puppet' ],
before => Service[ 'puppet' ],
}
}

}
10 changes: 9 additions & 1 deletion provision/modules/puppet/manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,24 @@
#
class puppet::params {

$client_ensure = 'latest'
$server_ensure = 'latest'

case $::osfamily {
'redhat': {
$client_ensure = 'latest'
$server_package_name = 'puppet-server'
}
'debian': {
$client_ensure = 'latest'
$server_package_name = 'puppetmaster'
}

'windows': {
$client_ensure = 'present'
$server_package_name = undef
warning ("Puppet master is not currently supported by Puppet Labs on ${::operatingsystem}")
}

default: {
fail("Module 'puppet' is not currently supported by Puppet Sandbox on ${::operatingsystem}")
}
Expand Down
109 changes: 56 additions & 53 deletions provision/modules/puppet/manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,67 +36,70 @@
$package_name = $puppet::params::server_package_name
) inherits puppet::params {

# required to prevent syslog error on ubuntu
# https://bugs.launchpad.net/ubuntu/+source/puppet/+bug/564861
file { [ '/etc/puppet', '/etc/puppet/files' ]:
ensure => directory,
before => Package[ 'puppetmaster' ],
}
if $package_name != undef {
# required to prevent syslog error on ubuntu
# https://bugs.launchpad.net/ubuntu/+source/puppet/+bug/564861
file { [ '/etc/puppet', '/etc/puppet/files' ]:
ensure => directory,
before => Package[ 'puppetmaster' ],
}

package { 'puppetmaster':
ensure => $ensure,
name => $package_name,
}
package { 'puppetmaster':
ensure => $ensure,
name => $package_name,
}

package { 'puppet-lint':
ensure => latest,
provider => gem,
}
package { 'puppet-lint':
ensure => latest,
provider => gem,
}

file { 'puppet.conf':
path => '/etc/puppet/puppet.conf',
owner => 'puppet',
group => 'puppet',
mode => '0644',
source => 'puppet:///modules/puppet/puppet.conf',
require => Package[ 'puppetmaster' ],
notify => Service[ 'puppetmaster' ],
}
file { 'puppet.conf':
path => '/etc/puppet/puppet.conf',
owner => 'puppet',
group => 'puppet',
mode => '0644',
source => 'puppet:///modules/puppet/puppet.conf',
require => Package[ 'puppetmaster' ],
notify => Service[ 'puppetmaster' ],
}

file { 'site.pp':
path => '/etc/puppet/manifests/site.pp',
owner => 'puppet',
group => 'puppet',
mode => '0644',
source => 'puppet:///modules/puppet/site.pp',
require => Package[ 'puppetmaster' ],
}
file { 'site.pp':
path => '/etc/puppet/manifests/site.pp',
owner => 'puppet',
group => 'puppet',
mode => '0644',
source => 'puppet:///modules/puppet/site.pp',
require => Package[ 'puppetmaster' ],
}

file { 'autosign.conf':
path => '/etc/puppet/autosign.conf',
owner => 'puppet',
group => 'puppet',
mode => '0644',
content => '*',
require => Package[ 'puppetmaster' ],
}
file { 'autosign.conf':
path => '/etc/puppet/autosign.conf',
owner => 'puppet',
group => 'puppet',
mode => '0644',
content => '*',
require => Package[ 'puppetmaster' ],
}

file { '/etc/puppet/manifests/nodes.pp':
ensure => link,
target => '/vagrant/nodes.pp',
require => Package[ 'puppetmaster' ],
}
file { '/etc/puppet/manifests/nodes.pp':
ensure => link,
target => '/vagrant/nodes.pp',
require => Package[ 'puppetmaster' ],
}

# initialize a template file then ignore
file { '/vagrant/nodes.pp':
ensure => present,
replace => false,
source => 'puppet:///modules/puppet/nodes.pp',
}
# initialize a template file then ignore
file { '/vagrant/nodes.pp':
ensure => present,
replace => false,
source => 'puppet:///modules/puppet/nodes.pp',
}

service { 'puppetmaster':
enable => true,
ensure => running,
}

service { 'puppetmaster':
enable => true,
ensure => running,
}

}