this piece of ruby in chef recipe:
# if datadir doesn't exist, move on default 1 if !file.exist?("/vol/postgres/data") execute "mv /var/lib/postgresql/9.1/main /vol/postgres/data" end
the result is:
executing mv /var/lib/postgresql/9.1/main /vol/postgres/data mv: inter-device move failed: `/var/lib/postgresql/9.1/main' `/vol/postgres/data/main'; unable remove target: directory
i know /vol/postgres/data
exists , directory, yet still attempts execute mv
. why?
just sure, running following standalone ruby script on same machine outputs "nomv":
if !file.exist?("/vol/postgres/data") print "mv" else print "nomv" end
i not attentive earlier, thought checking file existence in not_if
or only_if
block. problem similar 1 in question: chef lwrp - defs/resources execution order. see detailed explanation there.
your problem !file.exist?("/vol/postgres/data")
code gets executed straight away - (because it's pure ruby), before resource executed , before postgress installed.
the solution should move check not_if
block.
execute "mv /var/lib/postgresql/9.1/main /vol/postgres/data" not_if { file.exist?("/vol/postgres/data") } end
Comments
Post a Comment