Skip to content

Instantly share code, notes, and snippets.

Avatar

Ethan J. Brown Iristyle

  • Puppet, Inc.
  • Portland, OR
View GitHub Profile
@Iristyle
Iristyle / notes.md
Created Jul 13, 2018
Puppet::Util::Platform.windows? vs Puppet.features.microsoft_windows?
View notes.md

So we have 2 mechanisms that we use to check whether or not we're on Windows.

In this particular instance, I think we'd prefer to use Puppet::Util::Platform.windows? as I wouldn't expect any cross-platform stubbing to occur in tests.

@Iristyle
Iristyle / get-tasks-with-compat.ps1
Created Mar 28, 2018
Get scheduled tasks with compat
View get-tasks-with-compat.ps1
Get-ScheduledTask | % {
$props = [ordered]@{
TaskName = $psitem.TaskName
# note ErrorAction Ignore needed to prevent conversion problems
Compatibility = $psitem | Select -ExpandProperty Settings | Select -ExpandProperty Compatibility -ErrorAction Ignore
}
New-Object -TypeName PSObject -Property $props
}
@Iristyle
Iristyle / appv-notes.md
Last active Mar 24, 2018
Fun times with Bundler + AppVeyor!
View appv-notes.md

While documenting Bundler behavior to make the chart at https://gist.github.com/Iristyle/8a2214a6dd5aa709ba2a1abd32b4eacd, an interesting scenario was uncovered.

The following diff is a result of running the same code a day apart in AppVeyor. All dependencies downloaded / installed are exactly the same, except:

@Iristyle
Iristyle / bundler-results.md
Last active Mar 26, 2018
Windows Bundler 1.16.1 behavior when transitive dependency aws-sdk-v1 is present (that has json ~> 1.4)
View bundler-results.md
Gemfile gem fetched /
native ext built
--path specified Gemfile.lock system json bundled json gem list bundle exec gem list bundle show json
Ruby 2.1 /
json 1.8.1
gem 'json', '>= 0' fetched 1.8.6
built 1.8.6
json (1.8.6) 1.8.6 1.8.6 (1.8.6, default: 1.8.1) (1.8.6) C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/json-1.8.6
Ruby 2.4 /
json 2.0.4
gem 'json', '>= 0' fetched 1.8.6
built 1.8.6
json (1.8.6) 2.0.4 1.8.6 (default: 2.0.4, 1.8.6) (1.8.6) C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/json-1.8.6
Ruby 2.1 /<b
@Iristyle
Iristyle / triggers.md
Last active Mar 20, 2018
Scheduled Task Trigger Types
View triggers.md

Puppet Hash Definition

  • required parameter
  • example value
Type Format Example v1
TASK_TRIGGER
v2
ITrigger
schedule string enum daily
weekly
monthly
once
TriggerType Type
start_time time string HH:MM 13:21 wStartHour
wStartMinute
StartBoundary
start_date Date string YYYY-MM-DD 2011-08-31 wBeginYear
wBeginMonth
wBeginDay
StartBoundary
@Iristyle
Iristyle / test-installer.ps1
Created Feb 12, 2018
Install Puppet via MSI using CLI parameters
View test-installer.ps1
$hostname = [Net.Dns]::GetHostName()
function Install-Puppet($opts)
{
$params = @('/qn', '/i', 'pkg\puppet-agent.msi', '/l*v', 'install.log')
if ($opts.Account) { $params += "PUPPET_AGENT_ACCOUNT_USER=`"$($opts.Account)`"" }
if ($opts.Domain) { $params += "PUPPET_AGENT_ACCOUNT_DOMAIN=`"$($opts.Domain)`"" }
if ($opts.Password) { $params += "PUPPET_AGENT_ACCOUNT_PASSWORD=`"$($opts.Password)`"" }
if ($opts.Startup) { $params += "PUPPET_AGENT_STARTUP_MODE=`"$($opts.Startup)`"" }
@Iristyle
Iristyle / git-filter-for-specific-files.md
Created Jan 26, 2018
Demonstrate how to use Git to create a new repo with specific files from a current repo
View git-filter-for-specific-files.md

I tried to initially do this using the perl based cj-git-filter-branch tool from https://github.com/pflanze/chj-bin (which required ensuring Perl was viable and a few CPAN packages were installed) with a CLI invocation like:

~/source/chj/chj-bin/cj-git-filter-branch --remove-all-but-those-in ../keepers.txt -f

And a keepers.txt like:

acceptance/tests/resource/scheduled_task/should_create.rb
@Iristyle
Iristyle / Interactive-cmd-UAC-disabled.txt
Last active Jan 5, 2018
Administrator winrm vs interactive perms through whoami /all
View Interactive-cmd-UAC-disabled.txt
local
USER INFORMATION
----------------
User Name SID
============================= ============================================
knqh9q0wrbqcczw\administrator S-1-5-21-2754450856-868995602-2816174699-500
GROUP INFORMATION
@Iristyle
Iristyle / shgetfolderpath.rb
Created Oct 23, 2017
Fiddle vs Win32API for SHGetFolderPath
View shgetfolderpath.rb
require 'fiddle/import'
require 'fiddle/types'
module Win32FiddleDirectories
extend Fiddle::Importer
include Fiddle::Win32Types # adds HWND, HANDLE, DWORD type aliases
# calling this appears to hose everything up!
# dlload "shell32", "kernel32"
View msi-report-versioned-files.ps1
function Get-MSIPropertyValue
{
[CmdletBinding()]
param(
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[__ComObject]
$MSIDatabase,
[parameter(Mandatory=$true)]
You can’t perform that action at this time.