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
require 'chef' | |
Chef::Config.from_file('/path/to/knife.rb') | |
hide_by_mins = 15700 | |
query = "*:*" | |
opts = { filter_result: | |
{ name: ["name"], ipaddress: ["ipaddress"], ohai_time: ["ohai_time"], | |
run_list: ["run_list"], platform: ["platform"], | |
platform_version: ["platform_version"], chef_environment: ["chef_environment"] } } |
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
Function DownloadFileFromWeb($url, $file) | |
{ | |
Write-Host "Downloading $file..." | |
[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} | |
(New-Object System.Net.WebClient).DownloadFile($url,$file) | |
} | |
Function InstallChefClient($installer) | |
{ | |
Write-Host "Installing Chef Client..." |
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
#!/bin/bash | |
set -e | |
# Customize all these values | |
# youre source/destination keys and | |
# configs will differ | |
BACKUPDIR="backups" | |
BACKUPLOG="./migration_backup.log" | |
RESTORELOG="./migration_restore.log" |
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
#!/bin/bash | |
set -x | |
# Customize all these values | |
# youre source/destination keys and | |
# configs will differ | |
BACKUPDIR="backups" | |
SRCWEBUIKEY="conf/src_webui_priv.pem" | |
DSTWEBUIKEY="conf/dst_webui_priv.pem" |
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
#!/usr/bin/env ruby | |
require 'chef' | |
require 'thread' | |
require 'optparse' | |
ARGV << '-h' if ARGV.length != 4 | |
options = {} | |
OptionParser.new do |opts| |
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
control 'check-directories' do | |
directories = Dir.glob('/private/tmp/**/**') | |
directories.each do |d| | |
describe directory(d) do | |
it { should exist } | |
end | |
end | |
end | |
control 'test-the-directoies' do |
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
# Upload a profile | |
$ curl -X POST "https://automate-server.test/compliance/profiles/jmiller" \ | |
-H "chef-delivery-enterprise: brewinc" -H "chef-delivery-user: jmiller" \ | |
-H "chef-delivery-token: tzwlbWMtgBC0lo6sxkAYKSShxSJEohnU7IAE4NCUGCg=" \ | |
--form "file=@/Users/jmiller/Devel/compliance-profiles/ssh.tar.gz" -k -D - | |
HTTP/1.1 100 Continue | |
HTTP/1.1 200 OK | |
Server: openresty |
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
Inspec Profile storage in Automate requires Automate >= 0.6.6, inspec >= 1.7.0 | |
# login via inspec cli with data collector token | |
inspec compliance login_automate https://automate-server.test --insecure true --user admin --dctoken 93a49a4f2482c64126f7b6015e6b0f30284287ee4054ff8807fb63d9cbd1c506 --ent brewinc | |
# get user token | |
delivery token -u jmiller -s automate-server.test -e brewinc | |
# login with user token | |
inspec compliance login_automate https://automate-server.test --insecure true --user jmiller --usertoken tzwlbWMtgBC0lo6sxkAYKSShxSJEohnU7IAE4NCUGCg= --ent brewinc |
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
Here we have two resources and an if statement. | |
The bug happens because the ::File.exist? check will run at compile time, and even though it is | |
after the file resource, at that point in the execution the file hasn’t actually been written yet. | |
The solution in this case is to use an only_if guard like: | |
file '/foo' do | |
content 'bar' | |
end | |
execute 'myapp /foo' do |
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
afile = '/foo.txt' | |
file afile do | |
content 'bar' | |
end | |
if ::File.exist?(afile) | |
execute "myapp #{afile}" | |
end |