puppetlabs/puppet · error · ArgumentError

Cannot have both `ensure => disabled` and `flavor`

Error message

Cannot have both `ensure => disabled` and `flavor`

What it means

The package type's flavor property (OpenBSD flavors, DNF module profiles) validates against `ensure => disabled`: disabling a package while also selecting a flavor is contradictory, so ArgumentError 'Cannot have both `ensure => disabled` and `flavor`' is raised.

Source

Thrown at lib/puppet/type/package.rb:421

          super(currentvalue)
        end
      end

      def change_to_s(currentvalue, newvalue)
        if provider.respond_to?(:package_settings_change_to_s)
          provider.package_settings_change_to_s(currentvalue, newvalue)
        else
          super(currentvalue, newvalue)
        end
      end
    end

    newproperty(:flavor, :required_features => :supports_flavors) do
      desc "OpenBSD and DNF modules support 'flavors', which are
        further specifications for which type of package you want."
      validate do |value|
        if [:disabled, "disabled"].include?(@resource[:ensure]) && value
          raise ArgumentError, _('Cannot have both `ensure => disabled` and `flavor`')
        end
      end
    end

    newparam(:source) do
      desc "Where to find the package file. This is mostly used by providers that don't
        automatically download packages from a central repository. (For example:
        the `yum` provider ignores this attribute, `apt` provider uses it if present
        and the `rpm` and `dpkg` providers require it.)

        Different providers accept different values for `source`. Most providers
        accept paths to local files stored on the target system. Some providers
        may also accept URLs or network drive paths. Puppet will not
        automatically retrieve source files for you, and usually just passes the
        value of `source` to the package installation command.

        You can use a `file` resource if you need to manually copy package files
        to the target system."

View on GitHub (pinned to e227c27540)

Solutions

  1. Remove `flavor` on resources where ensure => disabled (or change ensure).
  2. Make them mutually exclusive in data: `flavor => $ensure ? { 'disabled' => undef, default => 'default' }`.
  3. Audit layers with `puppet lookup flavor --explain` and `puppet lookup ensure --explain`.
  4. For DNF modules use enable_only instead of flavor when disabling.

Example fix

// before
package { 'postgresql':
  ensure => disabled,
  flavor => 'minimal',
}

// after
package { 'postgresql':
  ensure => disabled,
}
Defensive patterns

Strategy: validation

Validate before calling

// Puppet
if $flavor != undef and $ensure == 'disabled' {
  fail('flavor cannot be combined with ensure => disabled')
}

Prevention

When it happens

Trigger: `package { 'postgresql': ensure => disabled, flavor => 'minimal' }`; Hiera data merging that sets flavor on a resource whose ensure resolves to disabled; parameterized classes combining both flags through defaults.

Common situations: Shared Hiera data applying flavor globally while some nodes disable the package; refactors flipping ensure to disabled without removing flavor; copy-paste combining flavor examples from module docs with disable recipes.

Related errors


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/13662e08bd4557ed. Report an issue: GitHub.