Skip to content

Instantly share code, notes, and snippets.

@ipcrm
ipcrm / test.ts
Created February 21, 2019 14:45
quick param example
const validation: BaseParameter = {
type: "string",
required: true,
};
const trueFalse: BaseParameter = {
...validation,
type: {
kind: "single",
options: [
@ipcrm
ipcrm / quickloop.ts
Created February 20, 2019 15:57
polling
// Starting polling
const result = new Deferred<string>();
const timer = setInterval(async () => {
...
const deploymentStatus = await httpClient.exchange<any>(`${someurl}/${somepath}`, {
method: HttpMethod.Get,
headers: {
Accept: "application/json",
},
});
@ipcrm
ipcrm / thing.ts
Last active February 20, 2019 15:02
interface BitbucketWebhookResponse {
id: number;
name: string;
createdDate: number;
updatedDate: number;
events: string[];
configuration: any;
url: string;
active: boolean;
}
@ipcrm
ipcrm / message.ts
Last active December 6, 2018 12:52
Messagemaker
export const messageMaker: MessageMaker = params => {
return {
attachments: [
{
text: params.text,
color: "#45B254",
fallback: "Fingerprint Update",
mrkdwn_in: ["text"],
actions: [
actionableButton(
@ipcrm
ipcrm / switch_control_repo.pp
Created May 14, 2018 14:53
switch-control-repo
node_group { 'PE Master':
ensure => 'present',
classes => {
'pe_repo' => {},
'pe_repo::platform::el_7_x86_64' => {},
'pe_repo::platform::windows_x86_64' => {},
'puppet_enterprise::profile::master' => {
'code_manager_auto_configure' => true,
'r10k_private_key' => '/etc/puppetlabs/puppetserver/ssh/id-control_repo.rsa',
'r10k_remote' => 'https://gitlab.com/ipcrm/cd4pe-hol-cr.git',
@ipcrm
ipcrm / e.rb
Created December 11, 2017 16:16
Example group_merge
module Puppet::Parser::Functions
newfunction(:group_merge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
Recursively merges two or more hashes together and returns the resulting hash.
For example:
$hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }
$hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } }
$merged_hash = group_merge($hash1, $hash2)
# The resulting hash is equivalent to:
@ipcrm
ipcrm / example.sh
Last active December 2, 2017 00:37
Get list of Profiles or Roles for a given certname (PQL)
puppet query \
'resources[title]{ (title ~ "^Profile*" or title ~ "^Role*" ) and certname = "master.inf.puppet.vm" group by certname,title }'\
| jq '.. | .title?'
```
"Profile::App::Webserver::Apache"
"Profile::App::Webserver::Apache::Php"
"Profile::Platform::Baseline"
"Profile::Platform::Baseline::Linux"
"Profile::Platform::Baseline::Linux::Firewall"
@ipcrm
ipcrm / test.rb
Last active December 2, 2017 00:27
Ruby: Query PDB Report Data
require 'puppetdb'
client = PuppetDB::Client.new({:server => 'http://localhost:8080'})
response = client.request( '', 'reports[certname,logs]{ latest_report? = true and facts { name = "role" and value = "test" } }')
response.data.each do |c|
c["logs"]["data"].each do |l|
printf "%-30s %s\n" % [ c["certname"].rstrip(), l["message"].split(/[\[,\]]/)[1] ] if l["message"].include?('Echo')
end
end
@ipcrm
ipcrm / libcheck.rb
Created October 10, 2017 22:18
FIM Facter Example
Facter.add(:libcheck) do
require 'digest'
require 'yaml'
begin
digests = YAML.load(File.open('/Users/ipcrm/adhoc/fim/digest.yaml'))
rescue
exists = false
digests = {}
end
@ipcrm
ipcrm / example.pp
Created September 22, 2017 20:47
Artifactory Fetch Archive - Puppet
$nameo = 'image001.jpg'
$fetch_url = "http://example.server.com:8081/artifactory/test/${nameo}"
$full_path = "/var/tmp/${nameo}"
$auth_string = 'admin:AP9YvfPYaxXS1phVhRJij6CJmBH'
$install_path = '/var/tmp'
$md5 = 'a4e2e68667e459a729ff5bc4609d8ba4'
file { "${full_path}.md5":
ensure => present,
content => "${md5} ${full_path}",