I'm having troubles trying to understand what's going on, why pure ruby code is executed first despite that the code is put last, this is a part of what the action :install contains:
action :install do
...
windows_package "#{installation_name}" do
source "#{Chef::Config[:file_cache_path]}\\#{installer_filename}"
options "INSTALLDIR=\"#{installation_path}\""
action :install
not_if {::Dir.exists?("#{installation_path}\\bin")}
end
env "MYSQL_PATH" do
value "#{installation_path}"
end
windows_path "#{installation_path}\\bin" do
action :add
end
windows_batch "Installing Service" do
code <<-EOH
set MYSQL_PATH="#{installation_path}"
call %MYSQL_PATH%\\bin\\mysqld-nt.exe --install MySQL
EOH
end
service "MySQL" do
action :start
end
service "MySQL" do
action :enable
end
change_pass_str = "call \"#{installation_path}\\bin\\mysql.exe\" -u root --execute \"UPDATE mysql.user SET Password=PASSWORD('#{root_password}') WHERE User='root';FLUSH PRIVILEGES;\""
puts change_pass_str
password_set_result = system(change_pass_str)
log !password_set_result ? "Password wasn't changed since root already have a password defined. Maybe there's still data from a previous installation." : "Password has been set!"
end
Please ignore the fact that i didn't put the variable definition, and know that they are well defined. The thing is that when this part of the lwrp is executed
change_pass_str = "call \"#{installation_path}\\bin\\mysql.exe\" -u root --execute \"UPDATE mysql.user SET Password=PASSWORD('#{root_password}') WHERE User='root';FLUSH PRIVILEGES;\""
puts change_pass_str
password_set_result = system(change_pass_str)
it can't find #{installation_path}\\bin\\mysql.exe
since it is not yet installed, in spite of that the block is at the end of the action.
Can anyone point me what is my mistake? why the other (already defined in this case in windows LWRP) resources are executed at the end instead of the begining? How can i fix it?