- From: Brian Fletcher <
>
- To: "
" <
>
- Subject: [chef] Re: only_if and not_if guard
- Date: Thu, 12 Dec 2013 12:49:15 +0000
- Accept-language: en-IE, en-US
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.