Skip to content

Instantly share code, notes, and snippets.

View spuder's full-sized avatar

Spencer Owen spuder

View GitHub Profile
@spuder
spuder / foodcritic-output.md
Created June 4, 2015 15:31
foodcritic crash
sowens-MBP:cookbooks sowen$ foodcritic ND-Webserver2012/
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/erubis-2.7.0/lib/erubis/converter.rb:132:in `scan': invalid byte sequence in UTF-8 (ArgumentError)
	from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/erubis-2.7.0/lib/erubis/converter.rb:132:in `convert_input'
	from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/erubis-2.7.0/lib/erubis/converter.rb:36:in `convert'
	from /opt/chefdk/embedded/apps/foodcritic/lib/foodcritic/template.rb:13:in `extract'
	from /opt/chefdk/embedded/apps/foodcritic/lib/foodcritic/api.rb:553:in `template_expressions_only'
	from /opt/chefdk/embedded/apps/foodcritic/lib/foodcritic/api.rb:494:in `uncached_read_ast'
	from /opt/chefdk/embedded/apps/foodcritic/lib/foodcritic/api.rb:225:in `read_ast'
	from /opt/chefdk/embedded/apps/foodcritic/lib/foodcritic/api.rb:349:in `templates_included'
@spuder
spuder / modules.md
Created June 5, 2015 01:11
beaker troubleshoot
root@ubuntu-server-1404-x64:~# puppet module list
Warning: Setting templatedir is deprecated. See http://links.puppetlabs.com/env-settings-deprecations
   (at /usr/lib/ruby/vendor_ruby/puppet/settings.rb:1139:in `issue_deprecation_warning')
/etc/puppet/modules
└── puppetlabs-stdlib (v4.6.0)
@spuder
spuder / batch.md
Last active August 29, 2015 14:22
chef remote resoruce
batch "download_neserv" do
  code <<-EOH
  SET username=#{user}
  SET password=#{password}
  net use "#{path}" %password% /user:%username%
  :copy
  copy "#{path}\\#{branch}\\#{branch}_#{version}.zip" "#{local_zip_path}"
  IF ERRORLEVEL 0 goto disconnect
 goto end
@spuder
spuder / chef-not-if.md
Created June 9, 2015 22:09
Chef not_if doesn't work on windows
owershell_script "foobar Install" do
  code <<-EOH
    sc.exe create #{foobar} binPath= #{foobar}//foobar.exe"
  EOH
  action :run
  # guard_interpreter :powershell_script
  not_if "If (Get-Service -Name foobar -ErrorAction SilentlyContinue) { return 0 } Else { return 1 }"
end
@spuder
spuder / chef.md
Last active August 29, 2015 14:23
Chef escape backslashes

I need to run this command The command only works if you have exactly one slash between foo and bar (Silly windows)

InstallUtil.exe /username=foo\bar

powershell_script "netSage Install" do
  guard_interpreter :powershell_script
  code <<-EOH
@spuder
spuder / couchebase.xml
Created June 29, 2015 23:32
Chef template default value
<?xml version="1.0"?>
<Cache>
<servers>
<% @couchbase_cache_servers.each do |server| %>
<add uri="<%= server -%>"/>
<% end %>
</servers>
<buckets>
<add name="<%= @couchbase_cache_name -%>" password="<%= @couchbase_cache_password -%>"/>
@spuder
spuder / default.rb
Last active August 29, 2015 14:23
Chef helper win_friendly_path
# Notice how log_dir starts with the correct two slashes?
# By the time it is inserted into the template, one of those slashes is removed.
# Trying to use win_friendly_path to undo that
default['iis']['log_dir'] = 'F:\\LogFiles'
@spuder
spuder / recipe.md
Last active August 29, 2015 14:24
chef win_friendly_path bug

There appears to be a bug where win_friendly_path doesn't change the path.

default.rb

default['iis']['log_dir'] = 'F:\\LogFiles'

recipe

::Chef::Recipe.send(:include, Windows::Helper)
@spuder
spuder / README.md
Last active August 29, 2015 14:25
Cookbook Dependency Problem

Nomatter what I put in my berksfile and metadata file of cookbookB, berks can not fetch the dependencies.

I don't understand why. cookbook-b is a wrapper cookbook for cookbook-a. I've been able to make other wrapper cookbooks, but those were for all cookbooks available on the supermarket. I suspect that berks won't look on github for dependencies?

cd cookbook-b
rm Berksfile.lock
berks install
Resolving cookbook dependencies...
Fetching 'coookbook-a' from http://gitlab.example.com/foo/coookbook-a.git (at v2.0.0)
@spuder
spuder / readme.md
Created July 27, 2015 17:24
chef notepad

If you try and run chef against a file that was edited in notepad, it will give the following error

No resource, method, or local variable named ` ■f' for `Chef::Recipe
[2015-07-27T13:17:23-04:00] FATAL: NameError: No resource, method, or local variable named ` ■f' for `Chef::Recipe "(che
f-apply recipe)"'
PS C:\Users\sowen> chef-client --version
Chef: 12.4.1
PS C:\Users\sowen> chef-apply 'C:\Users\sowen\Desktop\foo.rb' -l debug
[2015-07-27T13:18:11-04:00] DEBUG: Building node object for spencerau14.ndlab.local