puppetlabs/puppet · error · ArgumentError
Cannot have both `enable_only => true` and `flavor`
Error message
Cannot have both `enable_only => true` and `flavor`
What it means
The package type's enable_only parameter (DNF module enablement without install) validates against flavor: `enable_only => true` together with a selected flavor/profile is contradictory and raises 'Cannot have both `enable_only => true` and `flavor`'. The same validate block separately rejects ensure => disabled combined with enable_only.
Source
Thrown at lib/puppet/type/package.rb:520
newvalues(:true, :false)
end
newparam(:enable_only, :boolean => false, :parent => Puppet::Parameter::Boolean) do
desc <<-EOT
Tells `dnf module` to only enable a specific module, instead
of installing its default profile.
Modules with no default profile will be enabled automatically
without the use of this parameter.
Conflicts with the `flavor` property, which selects a profile
to install.
EOT
defaultto false
validate do |value|
if [true, :true, "true"].include?(value) && @resource[:flavor]
raise ArgumentError, _('Cannot have both `enable_only => true` and `flavor`')
end
if [:disabled, "disabled"].include?(@resource[:ensure])
raise ArgumentError, _('Cannot have both `ensure => disabled` and `enable_only => true`')
end
end
end
newparam(:install_only, :boolean => false, :parent => Puppet::Parameter::Boolean, :required_features => :install_only) do
desc <<-EOT
It should be set for packages that should only ever be installed,
never updated. Kernels in particular fall into this category.
EOT
defaultto false
end
newparam(:install_options, :parent => Puppet::Parameter::PackageOptions, :required_features => :install_options) do
desc <<-EOT
An array of additional options to pass when installing a package. TheseView on GitHub (pinned to e227c27540)
Solutions
- Drop one of the pair: either `enable_only => true` with no flavor, or `flavor => '...'` with a normal ensure.
- Gate flavor in data: `flavor => $enable_only ? { true => undef, default => 'development' }`.
- Check `puppet lookup enable_only` / `puppet lookup flavor` per node to find which layer sets each.
- If the intent is 'enable the default profile', use enable_only alone.
Example fix
// before
package { 'nodejs':
provider => 'dnf',
enable_only => true,
flavor => 'development',
}
// after
package { 'nodejs':
provider => 'dnf',
enable_only => true,
} Defensive patterns
Strategy: validation
Validate before calling
// Puppet
if $enable_only in [true, :true, 'true'] and $flavor != undef {
fail('enable_only cannot be combined with flavor')
} Prevention
- Pick one of enable_only or flavor per DNF module package.
- Gate flavor in data on the enable_only value.
- Check which Hiera layer sets each key with puppet lookup --explain.
When it happens
Trigger: `package { 'nodejs': provider => dnf, enable_only => true, flavor => 'development' }`; Hiera defaults setting flavor for all DNF module packages while one resource adds enable_only => true; modules templating both flags from one data hash.
Common situations: DNF module workflows migrating from flavor-based installs to enable-only; layered Hiera data written by different teams each owning one key; copy-pasted examples from module READMEs that include both attributes.
Related errors
- Cannot have both `ensure => disabled` and `flavor`
- Modules are not supported on DNF versions lower than 3.0.1
- The ssl_context and include_system_store parameters are mutu
- Find %{uri} resulted in 404 with the message: %{body}
- Cannot have both 'forcelocal' and 'ia_load_module' at the sa
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/a62da323a11d2362.
Report an issue: GitHub.