これは私action :create
のカスタム LWRP ですが、常に実行されます。冪等のアクションを行いたい。
これが私の実装です:
action :create do
converge_by "Create [#{@new_resource}]" do
USER_NAME = @new_resource.username
USER_PASSWORD = @new_resource.password unless (@new_resource.password.nil? ||
@new_resource.password.empty?)
USER_PASSWORD = USER_NAME
DATABASE_NAME = @new_resource.database_name unless (@new_resource.database_name.nil? ||
@new_resource.database_name.empty?)
DATABASE_NAME = USER_NAME
execute "create user [#{USER_NAME}]" do
user "postgres"
exists = <<-EOH
PGPASSWORD='postgres' psql -U postgres -c "select * from pg_user where usename='#{USER_NAME}'" | grep -c #{USER_NAME}
EOH
command "PGPASSWORD='postgres' createuser -U postgres -sw #{USER_NAME}"
not_if exists, :user => "postgres"
end
execute "set-password" do
user "postgres"
command "PGPASSWORD='postgres' psql -U postgres -c \"alter role #{USER_NAME} with password '#{USER_PASSWORD}'\""
end
execute "create-database" do
user "postgres"
exists = <<-EOH
PGPASSWORD='postgres' psql -U postgres -c "select * from pg_database WHERE datname='#{DATABASE_NAME}'" | grep -c #{DATABASE_NAME}
EOH
command "PGPASSWORD='postgres' createdb -U postgres -O #{USER_NAME} -T template0 #{DATABASE_NAME}"
not_if exists, :user => "postgres"
end
end
@new_resource.updated_by_last_action(true)
end
最後の行が機能しないのはなぜ@new_resource.updated_by_last_action(true)
ですか?