Skip to content

Instantly share code, notes, and snippets.

View jpadams's full-sized avatar

Jeremy Adams jpadams

View GitHub Profile
#!/bin/bash
#
# usage is: ./make_role_groups.sh <environment_to_scan>
# example: ./make_role_groups.sh staging
#
find_guid()
{
echo $(curl -s https://$master_hostname:4433/classifier-api/v1/groups --cert $cert --key $key --cacert $cacert | python -m json.tool |grep -C 2 "$1" | grep "id" | cut -d: -f2 | sed 's/[\", ]//g')
}
@jpadams
jpadams / vra_nc_setup.sh
Last active September 8, 2017 21:51
Works even if you're using Code Manager with PE to point at control repo.
#!/bin/bash
# Note: this script does not randomize uuid for the classification group it creates, so it will create/replace the same group everytime instead of creating a new group
autosign_example_class=autosign_example
alternate_environment=dev
all_nodes_id='00000000-0000-4000-8000-000000000000'
roles_group_id='235a97b3-949b-48e0-8e8a-000000000666'
dev_env_group_id='235a97b3-949b-48e0-8e8a-000000000888'
autosign_group_id='235a97b3-949b-48e0-8e8a-000000000999'
#
### Generated by Winemaker 0.8.4
###
### Invocation command line was
### /usr/local/bin/winemaker --interactive nssm.vcproj
SRCDIR = .
SUBDIRS =
DLLS =
LIBS =
<query> = <whitespace>? from <whitespace>?
expr-or = expr-and (<whitespace> or <whitespace> expr-or)*
condexpnull = field <whitespace>? (condisnull | condisnotnull)
condisnull = <"is null">
<dottedfield> = "facts" | "trusted" | "parameters"
<fieldlist> = (field | function) (<whitespace>? <","> <whitespace>? fieldlist)?
condexpression = condexpregexp | condexpregexparray | condexpinequality | condexpmatch | condexpin
<condin> = "in"
true = <"true">
<fieldpath> = <"."> (quotedfield | standardfield | matchfield) fieldpath?
<lparens> = '(';
<rparens> = ')';
<lbrace> = '{';
<rbrace> = '}';
<lbracket> = '[';
<rbracket> = ']';
boolean = true | false;
true = <"true">;
false = <"false">;
integer = [negative], digits;
# install.ps1 : This powershell script installs the puppet-agent package from a Puppet Enterprise master
# you could call this script like this:
# install.ps1 main:certname=foo custom_attributes:challengePassword=SECRET extension_requests:pp_role=webserver
[CmdletBinding()]
Param(
[Parameter(Mandatory = $false, ValueFromRemainingArguments = $true)]
[String[]]
# This value would be $null when no parameters are passed in; however, a PS2 bug causes foreach to iterate once
# over $null, which is undesirable. Setting the default to an empty array gets around that PS2 bug.
2017-05-19 12:46:26.642+0000 [http-nio-127.0.0.1-8280-exec-47] INFO {} [ExecutionController] Executing wf: 24ad4ae5-723b-4e10-b344-9bea7a742217 traceId: HW9aYtef
2017-05-19 12:46:26.647+0000 [http-nio-127.0.0.1-8280-exec-47] INFO {} [Execution] Executing workflow 'Purge PE Agent Node'
2017-05-19 12:46:26.651+0000 [http-nio-127.0.0.1-8280-exec-47] INFO {} [Execution] Invoking workflow handler.8aa0cc075c17fbcc015c20beaf570171
2017-05-19 12:46:26.679+0000 [http-nio-127.0.0.1-8280-exec-36] INFO {} [ManagedTokenRegistryImpl] Updating SecureToken with id: 8aa0cc075c17fbcc015c20beaf2a016e
2017-05-19 12:46:26.680+0000 [http-nio-127.0.0.1-8280-exec-36] INFO {} [ManagedTokenRegistryImpl] SecureToken updated successfully for id: 8aa0cc075c17fbcc015c20beaf2a016e
2017-05-19 12:46:27.671+0000 [WorkflowExecutorPool-Thread-11] INFO {[email protected]:Purge PE Agent Node:24ad4ae5-723b-4e10-b344-9bea7a742217:token=8aa0cc075c17fbcc015c20beaf570171:context=HW9aYtef} [WorkflowHandler] Starting workflow 'Purge PE
[root@tse-puppetmaster2-prod ~]# puppet query 'inventory[certname] { facts.os.name = "windows" }' | ./jq '.[].certname' | wc -l
69
[root@tse-puppetmaster2-prod ~]# puppet query 'inventory[certname] { facts.os.name = "windows" and nodes { deactivated is null } }' | ./jq '.[].certname' | wc -l
1
require 'json'
fact_to_lookup = ARGV.shift
vra_facts = JSON.parse(%x(/opt/puppetlabs/bin/facter puppet_vra_properties -j))
vra_prop = "Puppet.VRA.Prop.#{fact_to_lookup}"
puts vra_facts["puppet_vra_properties"][vra_prop]
require 'json'
require 'tempfile'
fact_to_change = ARGV.shift
new_value = ARGV.shift
vra_facts_file_path = "/etc/puppetlabs/facter/facts.d/puppet_vra_facts.json"
vra_facts = JSON.parse(%x(/opt/puppetlabs/bin/facter puppet_vra_properties -j))
vra_prop = "Puppet.VRA.Prop.#{fact_to_change}"
vra_facts["puppet_vra_properties"][vra_prop] = new_value