Step 2. Use it
Other resources to supplement step 1 and 2:
http://gitimmersion.com/
http://git-scm.com/book/en/Getting-Started
http://www.git-tower.com/learn/
Snippets of Productivity from the jack of all traits - aka release engineer.
http://gitimmersion.com/
http://git-scm.com/book/en/Getting-Started
http://www.git-tower.com/learn/
include_recipe "foo::bar" do not_if { ::File.exists?("/etc/foo/bar") } end/\ That simple does't work, although it'd be awesome if it did (seems like a consistency thing to me). Reason for that is include_recipe is a method and not a resource. Which means it's evaluated at the compilation phase, and not at execution (which makes sense from building the resource collection perspective)So, if you do want a conditional include_recipe, you want to do something like this instead:
some_variable = {some logic to check for some state on a system}include_recide 'foo::bar' unless some_variableSituation where this becomes super useful for example, is on windows, for chef runs which need to reboot a server and go on:include_recipe 'cookbook::recipe' unless reboot_pending?
Great link:http://stackoverflow.com/questions/15961496/is-it-possible-to-chef-include-recipe-and-indicate-only-if-not-if-condition
The bug I filed on the issue and the resulting discussion:
https://tickets.opscode.com/browse/CHEF-5342
Toodles/
default['download_dir'] = '/var/windows/rocks'
directory node['download_dir'] doUnit test (traditional):
owner "root"
group "root"
mode 0755
action :create
recursive true
end
it 'create directory' do
expect(chef_run).to create_directory('/var/windows/rocks')
.with_owner('root')
.with_group('root')
.with_mode(0755)
end
it 'create directory' do
expect(chef_run).to create_directory(chef_run.node['download_dir'])
.with_owner('root')
.with_group('root')
.with_mode(0755)
end
/> knife kitchen create wsus (or knife cookbook create wsus)Your unit test would look very generic:
it 'installs some prerequisite that came with windows' do
end
it 'downloads some prereq that didnt come with windows' do
end
it 'installs the downloaded prereq' do
end
etc...Your integration tests on the other hand, would look very specific - Because you know ahead of time what constitutes a functional WSUS server.
describe package('wsus') do
it { should be_installed }
end
describe service('wsus') do
it { should be_enabled }
it { should be_running }
end
describe port(3859) do
it { should be_listening }
end
etc...
The password entered is longer than 14 characters. Computers with Windows prior to Windows 2000 will not be able to use his account. Do you want to continue this operation? (Y/N) [Y]:I nuked three boxes to find out my password was too long...
net user /add $user $password /yesfyi: both /y and /yes work, and no matter how many times you type net help you wont get the answer you're looking for.
<powershell> #https://gist.github.com/vinyar/6735863;
"[System Access]" | out-file c:\delete.cfg; "PasswordComplexity = 0" | out-file c:\delete.cfg -append; "[Version]" | out-file c:\delete.cfg -append; 'signature="$CHICAGO$"' | out-file c:\delete.cfg -append; secedit /configure /db C:\Windows\security\new.sdb /cfg c:\delete.cfg /areas SECURITYPOLICY; $user="UsernameGoesHere"; $password = "UserPasswordGoestHere"; net user /add $user $password; net localgroup Administrators /add $user; winrm quickconfig -q; Enable-PSRemoting -force; winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="300"}'; winrm set winrm/config '@{MaxTimeoutms="1800000"}'; winrm set winrm/config/service '@{AllowUnencrypted="true"}'; winrm set winrm/config/service/auth '@{Basic="true"}'; winrm set winrm/config/service/auth '@{CredSSP="true"}'; netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" profile=public protocol=tcp localport=5985 new remoteip=any;</powershell>
brew install pcre
CD to the folder where you're breaking
pcregrep --color='auto' -r -n "[^\x00-\x7F]" .
pcregrep --color='auto' -r -n "[\x80-\xFF]" .
git clone https://github.com/stackforge/cookbook-openstack-common
git checkout 5e1a812a38c19a45b774862345f552c41836606f
pcregrep --color='auto' -r -n "[\x80-\xFF]" .
[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
PS C:\chef> Add-WindowsFeature OOB-WSUSWARNING: Installation of 'Windows Server Update Services' is not supported on the command line. Skipping...
"web-server", "Web-Asp-Net", "Web-Windows-Auth", "Web-Metabase", "File-Services" | foreach {if (!(Get-WindowsFeature $_)){add-windowsfeature $_}}
https://github.com/vinyar/wsus
https://github.com/vinyar/wsus/blob/master/recipes/configure_wsus.rb

gem cleanupB - nuke everything and start for scratch.
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
https://github.com/misheska/basebox-packer
openssl sha1 c:\Images\raw\7601.17514.101119-1850_x64fre_server_eva
l_en-us-GRMSXEVAL_EN_DVD.iso
http://www.microsoft.com/en-us/download/details.aspx?id=11533
packer build -only=virtualbox-iso -var 'iso_url=C:\Images\raw\7601.17514.101119-1850_x64fre_server_eval_en-us-GRMSXEVAL_EN_DVD.iso' -var 'iso_checksum=beed231a34e90e1dd9a04b3afabec31d62ce3889' win2008r2-enterprise.json
______________________________________
/ The best way to learn Chef is to use \
\ Chef. --Me /
--------------------------------------
\
\
\
.--,--.
`. ,.'
|___|
:o o: O
_`~^~'_ |
/' ^ `=)
.' _______ '~|
`(<=| |= /'
| |
|_____|
~~~~~~ ===== ~~~~~~~~
_________________________________________
/ Actually, my goal is to have a sandwich \
\ named after me. /
-----------------------------------------
\
\
\
.--,--.
`. ,.'
|___|
:o o: O
_`~^~'_ |
/' ^ `=)
.' _______ '~|
`(<=| |= /'
| |
|_____|
~~~~~~ ===== ~~~~~~~~
http://aws.amazon.com/powershell/
Get-Module -ListAvailableStep 3.
ImportSystemModules
Set-AWSCredentials
(Get-EC2ImageByName WINDOWS_2008_BASE).imageid
http://releaseengineer.blogspot.com/2013/09/managing-aws-with-powershell.html
.chefAnd you want to share them between two different Orgs - lets say, getchef.com chef server, and a private Server behind 13 firewalls and 14 VPNs..
.kitchen (maybe, maybe not)
cookbooks
environments
roles
spec (maybe?, maybe not yet)
etc..
git init (initialize bare git repo)You just placed your configs under version control in 'master' branch. YAY (*think of Dallas cheer leaders*)
git add . (add all files to repo)
git commit -m 'bla' (commit files to git repo)
git checkout -b local master (you just cloned master into local - good idea to have this as a backup of master)git checkout -b russia master (you just cloned master into russia)git checkout russia (switch to working on a specific branch)Add new .PEM files (your validator/pem may have different names.)Make changes to knife.rb (URL and if needed, file names. The rest should stay the same)Connect to the VPN's and/or whatever else. Test the new connections. (knife cookbook show)git add .git commit -m 'bbbla'
`auditpol /get /subcategory:\"#{@category}\"`.match(/#{test}/i)
or
`auditpol /get /subcategory:\"#{@category}\"`.downcase.match(/#{test}/)
Benchmark.measurerequire 'benchmark'
require 'bigdecimal/math'
# calculate pi to 10k digits
puts Benchmark.measure { BigMath.PI(10_000) }
More here: http://rubylearning.com/blog/2013/06/19/how-do-i-benchmark-ruby-code/Enjoy(Get-EC2Instance |? {$_.RunningInstance.keyname -like '<YOUR KEY NAME>'}).RunningInstance | select instanceid, PublicDnsName, IpAddress, @{Label="password";Expression={Get-EC2PasswordData $_.instanceid -PemFile '<Path to your .PEM file...C:\Bla\bla.pem>'}}, @{label="test";expression={(Get-EC2Instance $_.instanceid).RunningInstance.Tag.value}} | ft -autosize
only_if { WMI::Win32_Service.find(:first,:conditions => {:name => 'chef-client'}).nil? }
http://technet.microsoft.com/en-us/library/ff730935.aspx
Download here: http://www.microsoft.com/en-us/download/details.aspx?id=24121
Powershell 3 (Server 2008+) gives you the answer for free!!!!
Example1: Get-CimClass -MethodName *bios*
Example2: Get-CimClass -ClassName *bios*
$string64 = gc .\aws-userdata.ps1 -Encoding byte
$string64_string = [System.Convert]::ToBase64String($string64)
$string64_string
New-EC2Instance -ImageId ami-monkey -MinCount 1 -MaxCount 1 -keyname monkey -InstanceType m1.medium -Verbose -UserData $string64_string
Set-AWSCredentials
note: http://docs.aws.amazon.com/powershell/latest/userguide/pstools-appendix-signup.html
note: http://docs.aws.amazon.com/powershell/latest/userguide/specifying-your-aws-credentials.html
(Get-EC2ImageByName windows_2008_base).imageid
Get-EC2PasswordData -InstanceId $c.RunningInstance.instanceid -PemFile 'C:\Users\monkeys\monkey.pem'
or in case of multiple boxes just make a loop
help New-EC2Instance -full
PS\> openssl rand -base64 512
vq6liIBbS0vy5XXUQiknc8Mw/Bzm5YwjYJKkv34wns0w7OGXcXpXN4mutLmlcJ7h
N7P8557UtZW2JPwhrh6KbrtqK6SzvQK0uZvAejt074gOS0yWkVvnQC6/y4GWpfkA
l93McZpiHB7dAUxglHWPdA2u3+wYfJMt4VkCYAFTqyDyFyRxhi9KWhRdE55OyZQz
P92tVM8Vjo7rQVroDdW/SvQTPklAzJcwbubuBCfXvENWwhcXFEOyLhjftoxSEojR
qTraYr5J6CfMs9ELedRKjEUgHeXcnarBf0BbjliDwzeVQ7DcFGeq6i4aRed4U+1X
OuH5ewOI2qqrY3sQtWnG52X2BYWhi8Bs0G6h1SVvn7LsCLO3HGjB/cyLcujYQpcv
HMw8EXXndOvSXMif/N66RjRbafn0ZNjlCB1KtdNIy8y7gPJCkf6UbJuypZGWHlnd
wktJV1L4S7kKNKyaDX+9tZoTiZhN50qTYFZ+dQ9E5ItIBxoHc5UuQvK334nm8y70
Czpq1lfj1S9CSEvkcCaMkOnZOx+mb1rPcIm4fg6pA+F10m1t4Eph4m3QLxY7H4RE
yfxsZhWbE+I/epsODOeVi3VzHzz3UuNKuA+RvLD2U8QGDgyl9DRIgKGmMaShN7oa
6+OWoKeX4spSCkFIPwuPlcLAkVSBDEIrwlAIi+9hQr8=
PS\> -join $(openssl rand -base64 512)
remove-Item alias:cd
new-alias cd pushd
"remove-Item alias:cd;new-alias cd pushd" |out-file $profile -append