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
if File.exists?("/usr/ports") | |
execute "Update Ports Tree" do | |
command <<-EOS | |
sed -e 's/\\[ ! -t 0 \\]/false/' /usr/sbin/portsnap > /tmp/portsnap | |
chmod +x /tmp/portsnap | |
/tmp/portsnap update | |
EOS | |
end | |
else | |
execute "Create Ports Tree" 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
#!/bin/sh | |
# PROVIDE: ec2_fetchkey | |
# REQUIRE: NETWORKING | |
# BEFORE: LOGIN ec2_firstboot | |
# Define ec2_fetchkey_enable=YES in /etc/rc.conf and create /root/firstboot | |
# to enable SSH key fetching when the system next boots. | |
# | |
: ${ec2_fetchkey_enable=NO} |
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
# | |
# Author:: Adam Jacob (<[email protected]>) | |
# Author:: John Keiser (<[email protected]>) | |
# Copyright:: Copyright (c) 2012 Opscode, Inc. | |
# License:: Apache License, Version 2.0 | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# |
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
# If the host has ganglia in the run_list, install the mongo plugin | |
# In Chef 11 node.recipe? returns true for the run_list and expanded_runlist (node[:recipes]) | |
# In Chef 10 node.recipe? returns true for the run_list and already loaded recipes (seen_recipes) | |
# -- I believe on Chef 10 node.recipe? does not evaluated the expanded run_list so you want node[:recipes] too | |
if node.recipe?("ganglia::default") or node[:recipes].include?("ganglia::default") | |
# Make sure we've already executed the ganglia recipe in this run to get the ganglia_python LWRP | |
include_recipe "ganglia::default" | |
ganglia_python "mongodb" do | |
action :enable | |
end |
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
# Downloading a chef cookbook from a git repository | |
btm@btm-mbp-dev:~/devel/chef-repo/cookbooks [master] $ wget https://github.com/opscode-cookbooks/apache2/archive/master.zip | |
[snip] | |
2013-02-20 09:43:44 (349 KB/s) - `master.zip' saved [142580/142580] | |
btm@btm-mbp-dev:~/devel/chef-repo/cookbooks [master] $ unzip master.zip | |
Archive: master.zip | |
[snip] | |
btm@btm-mbp-dev:~/devel/chef-repo/cookbooks [master] $ mv apache2-master apache2 | |
btm@btm-mbp-dev:~/devel/chef-repo/cookbooks [master] $ knife cookbook upload apache2 |
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
$ gem list ohai | |
*** LOCAL GEMS *** | |
ohai (6.14.1, 6.14.0, 6.14.0.rc.1, 0.6.12) | |
$ cat /tmp/test.rb | |
chef_gem "ohai" do | |
version ">= 6.16.0" | |
end | |
$ sudo chef-apply /tmp/test.rb |
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
# Accessing dmi information in the chef-shell | |
# must use 'sudo shef' or 'sudo chef-shell' for dmidecode | |
chef > if node[:dmi] && node[:dmi][:system] && node[:dmi][:system][:manufacturer] =~ /VMware/ | |
chef ?> puts "On a VMWare Guest" | |
chef ?> end | |
On a VMWare Guest | |
=> nil | |
chef > node.automatic[:dmi] = nil | |
=> nil |
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
def configure_session | |
list = case config[:manual] | |
when true | |
@name_args[0].split(" ") | |
when false | |
r = Array.new | |
q = Chef::Search::Query.new | |
@action_nodes = q.search(:node, @name_args[0])[0] | |
@action_nodes.each do |item| | |
# we should skip the loop to next iteration if the item returned by the search is nil |
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 | |
# Copyright 2012 Opscode <[email protected]> | |
# | |
# Licensed to the Apache Software Foundation (ASF) under one | |
# or more contributor license agreements. See the NOTICE file | |
# distributed with this work for additional information | |
# regarding copyright ownership. The ASF licenses this file | |
# to you under the Apache License, Version 2.0 (the | |
# "License"); you may not use this file except in compliance | |
# with the License. You may obtain a copy of the License at |
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 | |
# Copyright 2012 Opscode <[email protected]> | |
# | |
# Licensed to the Apache Software Foundation (ASF) under one | |
# or more contributor license agreements. See the NOTICE file | |
# distributed with this work for additional information | |
# regarding copyright ownership. The ASF licenses this file | |
# to you under the Apache License, Version 2.0 (the | |
# "License"); you may not use this file except in compliance | |
# with the License. You may obtain a copy of the License at |