How to use chef to update-alternatives for java using execute?

前端 未结 2 949
我寻月下人不归
我寻月下人不归 2020-12-17 06:16

I am having syntax errors and I am unsure how to resolve them. In the roles file I have defined the fallowing:

default_attributes(
  \'jdk\' => {
    \'v         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-17 06:48

    You should escape all double quotes in your command string, because it starts and ends with double quotes.

    There is no action :creates for execute resource. The action should be :run.

    execute "update_alt_java" do
      command "update-alternatives --install \"/usr/bin/java\" \"java\" \"#{node['java']['home']}/bin/java\" 1"
      action :run
    end
    

    But you don't want to run this resource on every chef run, so you should come up with some kind of condition, when it should be run (using only_if, not_if statements).

提交回复
热议问题