The code to detect if a command is already present could be extended to be parsed to check it's current state:
def self.status?
begin
systemctl('status', "#{name}")
return true
rescue Puppet::ExecutionFailure => e
return false
end
end
Right now, if you use something like mask, it will not be idempotent:
systemctl {'ctrl-alt-del.target':
command => 'mask',
}
/Stage[main]/Profiles::Base::Disable_cad/Systemctl[ctrl-alt-del.target]/ensure: created
With some extension and the addition of an self.instances class, you could actually retrieve the current state of the service and give that as the value, so it only runs once.
This would also mean that you could do:
puppet resource systemctl ctrl-alt-del.target on the command line to get the current value of something as Puppet code
The code to detect if a command is already present could be extended to be parsed to check it's current state:
Right now, if you use something like mask, it will not be idempotent:
With some extension and the addition of an
self.instancesclass, you could actually retrieve the current state of the service and give that as the value, so it only runs once.This would also mean that you could do:
puppet resource systemctl ctrl-alt-del.targeton the command line to get the current value of something as Puppet code