[chef] Re: Re: Re: only_if and not_if guard


Chronological Thread 
  • From: Morgan Blackthorne < >
  • To: " " < >
  • Subject: [chef] Re: Re: Re: only_if and not_if guard
  • Date: Thu, 12 Dec 2013 05:39:58 -0800

Removing the block in this case means removing the curly braces { }.

--
~*~ StormeRider ~*~

"Every world needs its heroes [...] They inspire us to be better than we are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... http://bit.ly/Ps3uSS


On Thu, Dec 12, 2013 at 5:12 AM, Ravindra Chandrakar < " target="_blank"> > wrote:
Thanks Brain.

My final goal is to create database only if database does not exist,
otherwise create it.

When you said "leave out the block", do you want to say remove the
not_if? Could you please help me understanding this?

Thanks,
Ravi

On 12/12/13, Brian Fletcher < "> > wrote:
> Hi Ravi,
>
> From my understanding:
>
>  - you pass a block to not_if when you are running ruby code
>  - You pass a string to not_if to execute from the shell
>
> See here http://docs.opscode.com/resource_common.html#guards
>
> It looks to me like you want to execute from the shell. So you could try
> leave out the block and see what happens.
>
>   execute "Create_DB" do
>     command "sqlcmd -S server -i C:\createDB.sql -o C"\Create_db.log"
>     not_if "sqlcmd -U user -P secret -S server -b -Q \"select Count (*)
> from master.dbo.sysdatabases WHERE name = 'myDB'\""
>   end
>
>
> Thanks,
>
> Brian
>
>
>
> On 12/12/2013 12:26, "Ravindra" < "> > wrote:
>
>>Hello All,
>>
>>I'm writing a recipe where I'm trying to create a database in MSSQL. I've
>>written and execute resource, which is working fine. Now I want it to be
>>executed conditionally, if database exist do not execute the resource.
>>Irrespective of the condition the resource is getting executed every time.
>>
>>The resource I'm using is given below.
>>
>>execute "Create_DB" do
>>   command "sqlcmd -S server -i C:\createDB.sql -o C"\Create_db.log"
>>   not_if { "sqlcmd -U user -P secret -S server -b -Q \"select Count (*)
>>from
>>master.dbo.sysdatabases WHERE name = 'myDB'\""
>>end
>>
>>
>>Am I doing anything wrong here?
>>
>>Thanks
>>Ravi
>
>




Archive powered by MHonArc 2.6.16.

§