-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
337 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Ignore everything in this directory | ||
* | ||
# Except this file | ||
!.gitignore |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Ignore everything in this directory | ||
* | ||
# Except this file | ||
!.gitignore |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?xml version="1.0" encoding="UTF-16"?> | ||
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"> | ||
<RegistrationInfo> | ||
<Date>2014-04-15T00:00:00</Date> | ||
<Author>new23d</Author> | ||
<Description>Facter Caching of Expensive Facts</Description> | ||
</RegistrationInfo> | ||
<Triggers> | ||
<TimeTrigger> | ||
<Repetition> | ||
<Interval>PT10M</Interval> | ||
<StopAtDurationEnd>false</StopAtDurationEnd> | ||
</Repetition> | ||
<StartBoundary>2014-01-01T00:00:00</StartBoundary> | ||
<ExecutionTimeLimit>PT9M</ExecutionTimeLimit> | ||
<Enabled>true</Enabled> | ||
</TimeTrigger> | ||
<RegistrationTrigger> | ||
<ExecutionTimeLimit>PT9M</ExecutionTimeLimit> | ||
<Enabled>true</Enabled> | ||
</RegistrationTrigger> | ||
<BootTrigger> | ||
<ExecutionTimeLimit>PT9M</ExecutionTimeLimit> | ||
<Enabled>true</Enabled> | ||
</BootTrigger> | ||
</Triggers> | ||
<Principals> | ||
<Principal id="Author"> | ||
<UserId>S-1-5-18</UserId> | ||
<RunLevel>HighestAvailable</RunLevel> | ||
</Principal> | ||
</Principals> | ||
<Settings> | ||
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy> | ||
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries> | ||
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries> | ||
<AllowHardTerminate>true</AllowHardTerminate> | ||
<StartWhenAvailable>true</StartWhenAvailable> | ||
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable> | ||
<IdleSettings> | ||
<StopOnIdleEnd>true</StopOnIdleEnd> | ||
<RestartOnIdle>false</RestartOnIdle> | ||
</IdleSettings> | ||
<AllowStartOnDemand>true</AllowStartOnDemand> | ||
<Enabled>true</Enabled> | ||
<Hidden>false</Hidden> | ||
<RunOnlyIfIdle>false</RunOnlyIfIdle> | ||
<WakeToRun>false</WakeToRun> | ||
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit> | ||
<Priority>8</Priority> | ||
</Settings> | ||
<Actions Context="Author"> | ||
<Exec> | ||
<Command>"%ProgramFiles(x86)%\MCollective\opt\facter_cef.bat"</Command> | ||
</Exec> | ||
</Actions> | ||
</Task> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@echo off | ||
setlocal enabledelayedexpansion | ||
|
||
set var_puppet_key_name="HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Puppet Labs\Puppet" | ||
set var_puppet_value_name="RememberedInstallDir" | ||
|
||
for /f "usebackq skip=1 tokens=1,2*" %%a in (`reg query %var_puppet_key_name% /v %var_puppet_value_name%`) do (set var_puppet_base_dir=%%c) | ||
|
||
set var_mcollective_base_dir=%ProgramFiles(x86)%\MCollective\ | ||
set var_mcollective_etc_dir=%ProgramData%\MCollective\etc\ | ||
|
||
set var_programfilesx86_dir=%ProgramFiles(x86)% | ||
|
||
call "%var_puppet_base_dir%bin\environment.bat" | ||
|
||
"%var_puppet_base_dir%sys\ruby\bin\ruby.exe" -I"%var_mcollective_base_dir%lib;%var_puppet_base_dir%puppet\lib;%var_puppet_base_dir%facter\lib;%var_puppet_base_dir%hiera\lib;" -- "%var_mcollective_base_dir%opt\facter_cef.rb" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
## basic config start | ||
|
||
var_cached_facts_file = ENV['ProgramData'] + '/PuppetLabs/facter/facts.d/facter_cef.yaml' | ||
|
||
var_expensive_facts_regex = [ | ||
'network_.*', | ||
'interfaces', | ||
'macaddress_.*', | ||
'netmask_.*', | ||
'ipaddress6_.*', | ||
'mtu_.*', | ||
'ipaddress_.*', | ||
'ipaddress', | ||
'ipaddress6', | ||
'netmask', | ||
'macaddress' | ||
] | ||
|
||
## basic config end | ||
|
||
## advanced config start | ||
|
||
var_facter_cmd = 'facter --no-external-dir --puppet --yaml --timing' | ||
|
||
## advanced config end | ||
|
||
## processing start | ||
require 'yaml' | ||
require 'open3' | ||
require 'tempfile' | ||
|
||
var_stdin, var_stdout, var_stderr = Open3.popen3(var_facter_cmd) | ||
|
||
var_timing_data = Array.new | ||
var_facter_data = String.new | ||
var_cache = Hash.new | ||
|
||
# ugly loop to split timing and facter yaml data into separate variables | ||
var_datatype_yaml_flag = false | ||
|
||
var_stdout.each do |var_line| | ||
if var_datatype_yaml_flag == true | ||
var_facter_data += var_line | ||
else | ||
if var_line != "--- \n" | ||
var_timing_data.push(var_line) | ||
else | ||
var_datatype_yaml_flag = true | ||
var_facter_data += var_line | ||
end | ||
end | ||
end | ||
|
||
# the rest does get loaded up as valid yaml! | ||
var_facter_data = YAML.load(var_facter_data) | ||
|
||
# in the timing data, look for matches of the expensive facts | ||
var_timing_data.each do |var_line| | ||
var_expensive_facts_regex.each do |var_regex| | ||
if var_match = Regexp.new('(' + var_regex + '): ').match(var_line) | ||
if var_facter_data[var_match[1]] | ||
# if the fact is found in the yaml data as well, remember the value | ||
var_cache[var_match[1]] = var_facter_data[var_match[1]] | ||
else | ||
# if not, assign it a non null value so that facter doesn't try and look it up. | ||
# will think it has a value. | ||
var_cache[var_match[1]] = 'UNKNOWN' | ||
end | ||
end | ||
end | ||
end | ||
|
||
var_file_handle = Tempfile.new('facter_cef_') | ||
|
||
var_file_handle.write(var_cache.to_yaml) | ||
var_file_handle.close | ||
|
||
# atomic write | ||
File.rename(var_file_handle.path, var_cached_facts_file) | ||
|
||
## processing end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
@echo off | ||
setlocal enabledelayedexpansion | ||
|
||
set var_puppet_key_name="HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Puppet Labs\Puppet" | ||
set var_puppet_value_name="RememberedInstallDir" | ||
|
||
for /f "usebackq skip=1 tokens=1,2*" %%a in (`reg query %var_puppet_key_name% /v %var_puppet_value_name%`) do (set var_puppet_base_dir=%%c) | ||
|
||
set var_mcollective_base_dir=%ProgramFiles(x86)%\MCollective\ | ||
set var_mcollective_etc_dir=%ProgramData%\MCollective\etc\ | ||
|
||
set var_programfilesx86_dir=%ProgramFiles(x86)% | ||
|
||
if not exist %ProgramData%\MCollective\etc\server.cfg ( | ||
echo ^ | ||
main_collective = mcollective^ | ||
|
||
#collectives = mcollective,gotham_collective^ | ||
|
||
libdir = !var_programfilesx86_dir!\MCollective\plugins^ | ||
|
||
logfile = %ProgramData%\MCollective\var\log\server.log^ | ||
|
||
loglevel = debug^ | ||
|
||
daemonize = 1^ | ||
|
||
^ | ||
|
||
securityprovider = psk^ | ||
|
||
plugin.psk = pass%RANDOM%word^ | ||
|
||
^ | ||
|
||
connector = rabbitmq^ | ||
|
||
direct_addressing = 1^ | ||
|
||
plugin.rabbitmq.vhost = mcollective^ | ||
|
||
^ | ||
|
||
plugin.rabbitmq.pool.1.host = rabbitmq.example.com^ | ||
|
||
plugin.rabbitmq.pool.1.user = joe^ | ||
|
||
plugin.rabbitmq.pool.1.password = pass%RANDOM%word^ | ||
|
||
plugin.rabbitmq.pool.1.port = 61613^ | ||
|
||
^ | ||
|
||
plugin.rabbitmq.pool.size = 1^ | ||
|
||
^ | ||
|
||
factsource = facter^ | ||
|
||
plugin.facter.facterlib = %ProgramData%\PuppetLabs\puppet\var\lib\facter^ | ||
|
||
^ | ||
|
||
#identity = %COMPUTERNAME%.example.com^ | ||
|
||
^ | ||
|
||
#registerinterval = 600^ | ||
|
||
#registration = agentlist^ | ||
|
||
#registration_collective = mcollective^ | ||
|
||
^ | ||
|
||
rpcaudit = 1^ | ||
|
||
rpcauditprovider = logfile^ | ||
|
||
plugin.rpcaudit.logfile = %ProgramData%\MCollective\var\log\audit.log^ | ||
|
||
^ | ||
|
||
classesfile = %ProgramData%\PuppetLabs\puppet\var\state\classes.txt^ | ||
|
||
> %ProgramData%\MCollective\etc\server.cfg | ||
) | ||
|
||
call "%var_puppet_base_dir%bin\environment.bat" | ||
|
||
"%var_puppet_base_dir%sys\ruby\bin\ruby.exe" -I"%var_mcollective_base_dir%lib;%var_puppet_base_dir%puppet\lib;%var_puppet_base_dir%facter\lib;%var_puppet_base_dir%hiera\lib;" -- "%var_mcollective_base_dir%bin\mcollectived" --config "%var_mcollective_etc_dir%server.cfg" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Ignore everything in this directory | ||
* | ||
# Except this file | ||
!.gitignore |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'> | ||
<Product Name='MCollective' Version='2.5.0002' Id='*' UpgradeCode='D1B7E318-BED6-430C-9194-9427BEA29797' Language='1033' Codepage='1252' Manufacturer='new23d'> | ||
<Package Id='*' Compressed='yes' InstallerVersion='400' /> | ||
<Media Id='1' Cabinet='mcollective' EmbedCab='yes' /> | ||
|
||
<MajorUpgrade DowngradeErrorMessage='A later version of MCollective is already installed. Setup will now exit.' /> | ||
|
||
<Property Id='PUPPETLABSINSTALLED'> | ||
<RegistrySearch Id='PuppetLabsRememberedInstallDir' Type='raw' Root='HKLM' Key='SOFTWARE\Wow6432Node\Puppet Labs\Puppet' Name='RememberedInstallDir' /> | ||
</Property> | ||
|
||
<Condition Message='Puppet from Puppet Labs is a requirement.'> | ||
PUPPETLABSINSTALLED | ||
</Condition> | ||
|
||
<Directory Id='TARGETDIR' Name='SourceDir'> | ||
<Directory Id='ProgramFilesFolder'> | ||
<Directory Id='ProgramFilesFolder_MCollective' Name='MCollective'> | ||
<Directory Id='Opt' Name='opt'> | ||
<Component Id='Daemon' Guid='59F55255-AE9C-4F2C-ACE9-89432AD065E0'> | ||
<File Source='..\opt\service.bat' KeyPath='yes' /> | ||
<ServiceInstall DisplayName='MCollective' Name='mcollective' ErrorControl='normal' Start='auto' Type='ownProcess' /> | ||
<ServiceControl Id='MCollective' Start='install' Stop='both' Remove='uninstall' Name='mcollective' Wait='yes' /> | ||
</Component> | ||
<Component Id='FacterCEF' Guid='816A2919-0BFD-41C1-A231-89D53690981C'> | ||
<File Source='..\opt\facter_cef.rb' /> | ||
<File Source='..\opt\Facter_CEF.xml' /> | ||
<File Source='..\opt\facter_cef.bat' /> | ||
</Component> | ||
</Directory> | ||
</Directory> | ||
</Directory> | ||
|
||
<Directory Id='CommonAppDataFolder'> | ||
<Directory Id='CommonAppDataFolder_MCollective' Name='MCollective'> | ||
<Directory Id='Etc' Name='etc'> | ||
<Component Id='EtcDirectory' Guid='F85D5C40-541E-44B2-99AE-A11CE906CA4C'> | ||
<CreateFolder /> | ||
</Component> | ||
</Directory> | ||
<Directory Id='Var' Name='var'> | ||
<Directory Id='Log' Name='log'> | ||
<Component Id='LogDirectory' Guid='412AF20A-9266-40D8-8592-287C6C488FCA'> | ||
<CreateFolder /> | ||
</Component> | ||
</Directory> | ||
</Directory> | ||
</Directory> | ||
<Directory Id='CommonAppDataFolder_PuppetLabs' Name='PuppetLabs'> | ||
<Directory Id='Facter' Name='facter'> | ||
<Directory Id='FactsD' Name='facts.d'> | ||
<Component Id='FacterCEFYamlFile' Guid='07E51C12-957D-428D-BC2C-B683A914B5BB'> | ||
<RemoveFile Id='FacterCEFYaml' Name='facter_cef.yaml' On="uninstall" /> | ||
</Component> | ||
</Directory> | ||
</Directory> | ||
</Directory> | ||
</Directory> | ||
</Directory> | ||
|
||
<CustomAction Id='FacterCEFScheduledTaskCreate' Directory='Opt' ExeCommand='schtasks /create /f /xml ..\opt\Facter_CEF.xml /tn Facter_CEF' Execute='deferred' Impersonate='no' /> | ||
<CustomAction Id='FacterCEFScheduledTaskDelete' Directory='Log' ExeCommand='schtasks /delete /f /tn Facter_CEF' Execute='commit' Impersonate='no' /> | ||
|
||
<InstallExecuteSequence> | ||
<Custom Action='FacterCEFScheduledTaskCreate' Before='InstallFinalize'>(NOT Installed)</Custom> | ||
|
||
<Custom Action='FacterCEFScheduledTaskDelete' Before='FacterCEFScheduledTaskCreate'>REMOVE="ALL"</Custom> | ||
</InstallExecuteSequence> | ||
|
||
<Feature Id='Default'> | ||
<ComponentGroupRef Id='Tarball' /> | ||
<ComponentRef Id='Daemon' /> | ||
<ComponentRef Id='EtcDirectory' /> | ||
<ComponentRef Id='LogDirectory' /> | ||
<ComponentRef Id='FacterCEF' /> | ||
<ComponentRef Id='FacterCEFYamlFile' /> | ||
</Feature> | ||
</Product> | ||
</Wix> |