Reputation: 862
I have a part in init.pp, that starts my app:
systemd::service {'app':
user => 'java',
exec => "${java_home}/bin/java \
-server \
'-XX:OnOutOfMemoryError=\\'kill -9 %%p\\'' \
-Dmw.config=/etc/app/app.config \
-cp /usr/share/app/app.jar ru.app.main.Main app",
}
The newer version of the app.jar starts differently. There's a way, stop the puppet on the nodes, deregister the node from the consul, start the puppet with the new init.pp, and put that node back to the consul. But that just doesn't feel right.
Is there a way to put some "if" in there so I'd be able to make smooth transitions back and forth depending on my app's version or any other field?
Upvotes: 2
Views: 63
Reputation: 862
found it
if $app_v2 == 'true' {
systemd::service {'app':
user => 'java',
exec => "${java_home}/bin/java \
-server \
'-XX:OnOutOfMemoryError=\\'kill -9 %%p\\'' \
-Dmw.config=/etc/app/app_new.config \
-cp /usr/share/app/app.jar ru.app.main.App app",
}
} else {
systemd::service {'app':
user => 'java',
exec => "${java_home}/bin/java \
-server \
'-XX:OnOutOfMemoryError=\\'kill -9 %%p\\'' \
-Dmw.config=/etc/app/app.config \
-cp /usr/share/app/app.jar ru.app.main.Main app",
}
}
and for getting app_v2 flag, add to /lib/facter/app_v2.rb
require 'facter'
Facter.add(:app_v2) do
confine :kernel => :Linux
setcode do
result = false
if Facter::Core::Execution.exec('dpkg -l | grep app|awk \'{print$3}\'| cut -c1') == '2'
result = true
end
result
end
end
Upvotes: 1