Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete property value #18

Open
amateo opened this issue Jul 11, 2019 · 2 comments
Open

Delete property value #18

amateo opened this issue Jul 11, 2019 · 2 comments

Comments

@amateo
Copy link

amateo commented Jul 11, 2019

Hi,

I'm deploying a custom type to configure nagios contacts with augeas.

If I'm understanding well, according to http://augeasproviders.com/documentation/development.html if I want to be to remove a property I should use the :rm_node option in the accesor.

In my type I have the property defined as:

newproperty(:service_notification_options) do
    desc 'Nagios configuration file parameter.'
    validate do |value|
      if !value.match?(/^([wucrfsn](,[wucrfsn])*)?$/) then
        raise ArgumentError, "service_notification_options must be a comma separated list of 'w', 'u', 'c', 'r', 'f', 's', 'n' (#{value} provided)"
      end
    end
  end
end

and in the provider I get:

attr_aug_accessor(:service_notification_options,
                    :label => 'service_notification_options',
                    :type => :string,
                    :rm_node => true,
                   )

but with this code I have tried to remove the service_notification_options of a contact, but I can't. The contact in my file is:

define contact {
name fulanito
contact_name fulanito
can_submit_commands 1
email [email protected]
retain_nonstatus_information 1
service_notification_options w
}

I have tried not using the service_notification_options in the puppet resource and passing an empty value, like:

um_nagios_contact {'fulanito':
  target                       => '/tmp/contacts.cfg',
  contact_name                 => 'fulanito',
  email                        => '[email protected]',
  can_submit_commands          => 1,
  retain_nonstatus_information => 1,
  service_notification_options => '',
}

or

um_nagios_contact {'fulanito':
  target                       => '/tmp/contacts.cfg',
  contact_name                 => 'fulanito',
  email                        => '[email protected]',
  can_submit_commands          => 1,
  retain_nonstatus_information => 1,
  service_notification_options => undef,
}

How is the correct way to handle property removal? Or do I have to code myself the writer for the property?

@raphink
Copy link
Member

raphink commented Jul 11, 2019

Two options have been considered to fix this:

@amateo
Copy link
Author

amateo commented Jul 11, 2019

I think they are not exclusive. #20 is only valid when options could be provided as an array (you could use some of them separated by ,) which is not always possible. There are properties that are atomic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants