Weird issue with provider condition evaluations


#1

below is a truncated example of our provider that allows us to create volumes that may or may not be block encrypted.

this is iterated in the recipe across several volumes… /dev/sdr, /dev/sqs… etc.

what we’re seeing is that the when it runs for the first volume… everything works great… but the value for our device variable, which should be recalculated for each volume (as each volume is a separate resource call) is not being updated.

so… the check for xfs volume /dev/sdr would look like…

xfs_admin -l /dev/sdr 2>&1 | grep ‘unexpected XFS SB magic number’

…but when the check is executed for /dev/sds… it is running…

xfs_admin -l /dev/sdr 2>&1 | grep ‘unexpected XFS SB magic number’

…when it should be running…

xfs_admin -l /dev/sds 2>&1 | grep ‘unexpected XFS SB magic number’

this worked for us in chef 0.9… but in 0.10 we are now seeing this issue where the local device variable seems to not get updated with subsequent resource calls.

any ideas?

thanks in advance!

here is our provider code…


action :create do

    device = ""   
    #if crypto_passphrase is not nil, set up encryption
    if new_resource.crypto_passphrase   

	...do all the encryption stuff...

        device = dev_mapper
    elsif
        device = new_resource.device
    end

    #if volume is blank then format it as new_resource filesystem
    execute "create_#{new_resource.file_system}_volume" do
        command "mkfs.#{new_resource.file_system} #{device}"
        action :run
        only_if "xfs_admin -l #{device} 2>&1 | grep 'unexpected XFS SB magic number'" if new_resource.file_system == "xfs"
        only_if "tunefs2 -l  #{device} 2>&1 | grep 'Bad magic number in super-block'" if new_resource.file_system == "ext3"
    end

end


#2

Seeing the recipe code calling this provider would be useful…

On Dec 21, 2011, at 17:59, Jeremy Winters jeremy.winters@full360.com
wrote:

below is a truncated example of our provider that allows us to create
volumes that may or may not be block encrypted.

this is iterated in the recipe across several volumes… /dev/sdr,
/dev/sqs… etc.

what we’re seeing is that the when it runs for the first volume…
everything works great… but the value for our device variable, which *
should* be recalculated for each volume (as each volume is a separate
resource call) is not being updated.

so… the check for xfs volume /dev/sdr would look like…

xfs_admin -l /dev/sdr 2>&1 | grep ‘unexpected XFS SB magic number’

…but when the check is executed for /dev/sds… it is running…

xfs_admin -l /dev/sdr 2>&1 | grep ‘unexpected XFS SB magic number’

…when it should be running…

xfs_admin -l /dev/sds 2>&1 | grep ‘unexpected XFS SB magic number’

this worked for us in chef 0.9… but in 0.10 we are now seeing this issue
where the local device variable seems to not get updated with subsequent
resource calls.

any ideas?

thanks in advance!

here is our provider code…


action :create do

    *device* = ""
    #if crypto_passphrase is not nil, set up encryption
    if new_resource.crypto_passphrase

…do all the encryption stuff…

        *device* = dev_mapper
    elsif
        *device* = new_resource.device
    end

    #if volume is blank then format it as new_resource filesystem
    execute "create_#{new_resource.file_system}_volume" do
        command "mkfs.#{new_resource.file_system} #{device}"
        action :run
        only_if "xfs_admin -l #{*device*} 2>&1 | grep 'unexpected XFS

SB magic number’" if new_resource.file_system == "xfs"
only_if “tunefs2 -l #{device} 2>&1 | grep ‘Bad magic number
in super-block’” if new_resource.file_system == "ext3"
end

end