Skip to content

Mask is not idempotent #3

@petems

Description

@petems

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions