From 9310471c2dd3d7b35779edb3bede891286766b00 Mon Sep 17 00:00:00 2001 From: "DiMichel, Kevin" Date: Thu, 19 Dec 2013 17:37:38 -0700 Subject: [PATCH 1/3] added support for windows --- provision/modules/mirrors/manifests/init.pp | 2 +- .../modules/networking/manifests/init.pp | 21 +++- .../networking/templates/hosts-win.erb | 34 ++++++ provision/modules/puppet/manifests/init.pp | 36 +++--- provision/modules/puppet/manifests/params.pp | 10 +- provision/modules/puppet/manifests/server.pp | 109 +++++++++--------- 6 files changed, 137 insertions(+), 75 deletions(-) create mode 100644 provision/modules/networking/templates/hosts-win.erb diff --git a/provision/modules/mirrors/manifests/init.pp b/provision/modules/mirrors/manifests/init.pp index 3d3a1c0..c52715e 100644 --- a/provision/modules/mirrors/manifests/init.pp +++ b/provision/modules/mirrors/manifests/init.pp @@ -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}") } } diff --git a/provision/modules/networking/manifests/init.pp b/provision/modules/networking/manifests/init.pp index bb5b65d..18e583c 100644 --- a/provision/modules/networking/manifests/init.pp +++ b/provision/modules/networking/manifests/init.pp @@ -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'), + } + } + } } diff --git a/provision/modules/networking/templates/hosts-win.erb b/provision/modules/networking/templates/hosts-win.erb new file mode 100644 index 0000000..89f3ef3 --- /dev/null +++ b/provision/modules/networking/templates/hosts-win.erb @@ -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 diff --git a/provision/modules/puppet/manifests/init.pp b/provision/modules/puppet/manifests/init.pp index ce5844c..6721edf 100644 --- a/provision/modules/puppet/manifests/init.pp +++ b/provision/modules/puppet/manifests/init.pp @@ -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' ], + } } - } diff --git a/provision/modules/puppet/manifests/params.pp b/provision/modules/puppet/manifests/params.pp index 718be5e..e0b0264 100644 --- a/provision/modules/puppet/manifests/params.pp +++ b/provision/modules/puppet/manifests/params.pp @@ -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}") } diff --git a/provision/modules/puppet/manifests/server.pp b/provision/modules/puppet/manifests/server.pp index 9fbfce2..1e42b8b 100644 --- a/provision/modules/puppet/manifests/server.pp +++ b/provision/modules/puppet/manifests/server.pp @@ -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, } } From 45803a2c7edb5e5290821ba9c5ff90f54e8d9583 Mon Sep 17 00:00:00 2001 From: "DiMichel, Kevin" Date: Fri, 27 Dec 2013 16:41:47 -0700 Subject: [PATCH 2/3] added certificates module to remove duplicate certificate on windows systems that causes "puppet module install" error. --- provision/manifests/default.pp | 4 +++ .../modules/certificates/manifests/init.pp | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 provision/modules/certificates/manifests/init.pp diff --git a/provision/manifests/default.pp b/provision/manifests/default.pp index d820c12..21ab8a4 100644 --- a/provision/manifests/default.pp +++ b/provision/manifests/default.pp @@ -13,3 +13,7 @@ if $hostname == 'puppet' { class { 'puppet::server': } } + +if $operatingsystem == 'windows' { + include certificates +} \ No newline at end of file diff --git a/provision/modules/certificates/manifests/init.pp b/provision/modules/certificates/manifests/init.pp new file mode 100644 index 0000000..ce10f6f --- /dev/null +++ b/provision/modules/certificates/manifests/init.pp @@ -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}} \ No newline at end of file From e5b4d793870f9e1dfb28976afe511bcf7119fb05 Mon Sep 17 00:00:00 2001 From: "DiMichel, Kevin" Date: Fri, 27 Dec 2013 16:52:46 -0700 Subject: [PATCH 3/3] added new line at end of file. --- provision/manifests/default.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provision/manifests/default.pp b/provision/manifests/default.pp index 21ab8a4..7f51326 100644 --- a/provision/manifests/default.pp +++ b/provision/manifests/default.pp @@ -16,4 +16,4 @@ if $operatingsystem == 'windows' { include certificates -} \ No newline at end of file +}