Skip to content

Commit

Permalink
Wrappers fro reboot and iis, + firstrun docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alvagante committed Nov 12, 2017
1 parent 5556cd7 commit f9ad890
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 0 deletions.
2 changes: 2 additions & 0 deletions data/windows.yaml
@@ -0,0 +1,2 @@
---
psick::puppet::pe_agent::config_file_path: 'c:/programdata/puppetlabs/puppet/etc/puppet.conf'
41 changes: 41 additions & 0 deletions docs/firstrun.md
@@ -0,0 +1,41 @@
## First run mode

First run mode is a special condition, which can be applied at the first Puppet run
on the clients, where a seleceted number of classes are included and configured.
Optionally, a reboot may be triggered at the end of this first Puppet run.

The next Puppet runs will be normal and will use the normal configurations expected
in each nodes.

Possible use cases for Firstrun mode:
- Set a desired hostname on Windows, reboot and join an AD domain
- Install aws-sdk gem, reboot and have ec2_tags facts since the first real Puppet run
- Set external facts with configurable content (not via pluginsync) and run a catalog
only when they are loaded (after the first Puppet run)
- Any case where a configuration or some installations have to be done
in a separated and never repeating first Puppet run. With or without a
system reboot.

To enable first run mode (by default it's disabled) set:

psick::enable_firstrun: true

To define which classes to include in nodes, according to each $::kernel:

psick::firstrun::windows_classes:
hostname: psick::hostname
psick::firstrun::windows_reboot: true # (Default value)

psick::firstrun::linux_classes:
hostname: psick::hostname
proxy: psick::proxy
psick::firstrun::linux_reboot: false # (Default value)

IMPORTANT NOTE: If firstrun mode is activated on an existing infrastructure or if
the 'firstrun' external fact is removed from nodes, this class will be included
in the main psick class as if this were a real first Puppet run.
This will trigger a, probably unwanted, reboot on Windows nodes (and in any
other node for which reboot is configured.

Set psick::firstrun::${kernel}_reboot to false to prevent undesired reboots.

36 changes: 36 additions & 0 deletions manifests/iis.pp
@@ -0,0 +1,36 @@
#
class psick::iis (
Hash $features = {},
Hash $sites = {},
Hash $applications = {},
Hash $application_pools = {},
Hash $virtual_directories = {},
) {

$features.each | $k,$v | {
iis_feature { $k:
* => $v,
}
}
$sites.each | $k,$v | {
iis_site { $k:
* => $v,
}
}
$applications.each | $k,$v | {
iis_application { $k:
* => $v,
}
}
$application_pools.each | $k,$v | {
iis_application_pool { $k:
* => $v,
}
}
$virtual_directories.each | $k,$v | {
iis_virtual_directory { $k:
* => $v,
}
}
include ::iis
}
30 changes: 30 additions & 0 deletions manifests/reboot.pp
@@ -0,0 +1,30 @@
# This profile triggers a system reboot
#
# This profiles uses puppetfile/reboot module to manage
# system reboots.
#
# @example Enable firstrun mode and set reboot class on windows
# and linux
# firstrun_enable: true
# psick::firstrun::linux::reboot_class: psick::reboot
# psick::firstrun::windows::reboot_class: psick::reboot
#
class psick::reboot (
Boolean $manage = true,
Enum['immediately','finished'] $apply = 'finished',
Enum['refreshed','pending'] $when = 'pending',
String $reboot_name = 'Psick Reboot',
Integer $timeout = 60,
) {

$message = "Rebooting: when ${when} - apply ${apply} - timeout ${timeout}"
if $manage {
reboot { $reboot_name:
apply => $apply,
message => $message,
when => $when,
timeout => $timeout,
}
}
}

0 comments on commit f9ad890

Please sign in to comment.