1

I have a complicated software stack that I manage with 2 recipes.

recipe[stack::foo]
recipe[stack::bar]

foo is installed on every server, whereas bar is installed on only a subset of servers. bar depends on the file and service foo.

recipe[stack::foo]

  file 'fooFile' do
    source 'somewhere'
    notifies :restart, service[barService] #bar needs to be restart first, if it is present
    notifies :restart, service[fooService]
  end

  service 'fooService' do
    action :start
  end

recipe[stack::bar]

  file 'barFile' do
    source 'somewhere'
  end

  service 'barService' do
    action :start
  end

Is it possible to make a conditional dependency, so that if the bar recipe is present on the node, it will restart it. If it isn't, it will skip it.

I'm trying something like this

  file 'fooFile' do
    source 'somewhere'
    notifies :restart, service[barService] if exists? "service[barService]" 
    notifies :restart, service[fooService]
  end
spuder
  • 1,725
  • 3
  • 26
  • 42

1 Answers1

2

Answered in IRC, and user spuder informed that double-asking is not encouraged.

tl;dr use resources() or check the run list.

coderanger
  • 858
  • 4
  • 13