[chef] RE: Re: Help - Creating a "First Run Only" Resource


Chronological Thread 
  • From: "Van Fossan,Randy" < >
  • To: < >
  • Subject: [chef] RE: Re: Help - Creating a "First Run Only" Resource
  • Date: Mon, 7 Nov 2011 14:44:24 -0500

In the examples, are they to go into a resource or a recipe?  I just
don't have enough to build on..

Example from Chef Wiki------
execute "some_command" do
command "command to run once"
notifies :create, "ruby_block[some_command_run_flag]", :immediately
not_if { node.attribute?("some_command_complete") }
end

ruby_block "some_command_run_flag" do
block do
node.set['some_command_complete'] = true
node.save
end
action :nothing
end
---------------


-----Original Message-----
From: Maxim Kulkin 
[mailto:
 
Sent: Monday, November 07, 2011 2:37 PM
To: 

Subject: [chef] Re: Help - Creating a "First Run Only" Resource

What exactly you do not understand ? First boot recipe uses attribute on
node to signal if it was already executed on that node.

On Nov 7, 2011, at 21:47, Van Fossan,Randy wrote:

> I am still learning to write cookbooks and need to Create a "First Run
Only" Resource.   I am looking at the Wiki Creating a "First Run Only"
Resource
> (http://wiki.opscode.com/pages/viewpage.action?pageId=15728818) and am
having some difficulties interpreting the example.  Does anyone have a
cookbook with a complete example?
> 
> Basically, I have a recipe (config_disk.rb) that needs to do the
following only once.
> 
> ------Begin snippet ---
> bash "Configure_Disk" do
> user "root"
> cwd "/tmp"
> code <<-EOH
> #### Partition sda (Name and Data node) /sbin/fdisk /dev/sda << EOF n 
> p
> 
> 
> w
> EOF
> /sbin/partprobe /dev/sda
> #######Partition sdb (Name and Data node)
> /sbin/fdisk /dev/sdb << EOF
> n
> p
> 1
> 
> 
> w
> EOF
> EOH
> end
> ----End of snippet-----
> 
> Thanks
>  Randy
> OCLC Inc.






Archive powered by MHonArc 2.6.16.

§