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

Fix FreeBSD support #32

Merged
merged 5 commits into from Feb 26, 2023
Merged

Fix FreeBSD support #32

merged 5 commits into from Feb 26, 2023

Conversation

evgeni
Copy link
Member

@evgeni evgeni commented Feb 25, 2023

Pull Request (PR) description

This Pull Request (PR) fixes the following issues

@evgeni
Copy link
Member Author

evgeni commented Feb 25, 2023

normally, I'd say a new OS is "enhancement", but we had FreeBSD in the metadata.json before, it was just not working.

@evgeni
Copy link
Member Author

evgeni commented Feb 25, 2023

lol, and now I see #24 -.-

@evgeni evgeni force-pushed the freebsd branch 2 times, most recently from eae4129 to 7929826 Compare February 25, 2023 12:40
@evgeni
Copy link
Member Author

evgeni commented Feb 25, 2023

Interestingly, this still fails

Failures:

  1) mosquitto with default parameters behaves like an idempotent resource applies a second time without changes
     Failure/Error: raise CommandFailure, "Host '#{self}' exited with #{result.exit_code} running:\n #{cmdline}\nLast #{@options[:trace_limit]} lines of output were:\n#{result.formatted_output(@options[:trace_limit])}"
     Beaker::Host::CommandFailure:
       Host 'freebsd12-64-1' exited with 2 running:
        puppet apply --debug --detailed-exitcodes /tmp/apply_manifest_143950209.pp.XXXXXX.zhu3ugQz
       Last 100 lines of output were:
       	Debug: Facter: Loading all internal facts
       	Debug: Facter: List of resolvable facts: [#<Facter::SearchedFact:0x00000008068e5dd8 @name="domain", @fact_class=Facts::Freebsd::Networking::Domain, @user_query="domain", @type=:legacy, @file=nil>]
       	Debug: Facter: Loading external facts
       	Debug: Facter: Searching fact: domain in all custom facts
       	Debug: Facter: Loading custom facts
       	Debug: importing '/usr/local/etc/puppet/modules/mosquitto/manifests/init.pp' in environment production
       	Debug: importing '/usr/local/etc/puppet/modules/stdlib/manifests/init.pp' in environment production
       	Debug: Automatically imported mosquitto from mosquitto into production
       	Debug: importing '/usr/local/etc/puppet/modules/mosquitto/manifests/install.pp' in environment production
       	Debug: Automatically imported mosquitto::install from mosquitto/install into production
       	Debug: importing '/usr/local/etc/puppet/modules/mosquitto/manifests/config.pp' in environment production
       	Debug: Automatically imported mosquitto::config from mosquitto/config into production
       	Debug: Scope(Class[Mosquitto::Config]): Retrieving epp template mosquitto/mosquitto.conf.epp
       	Debug: importing '/usr/local/etc/puppet/modules/mosquitto/manifests/service.pp' in environment production
       	Debug: Automatically imported mosquitto::service from mosquitto/service into production
       	Debug: Adding relationship from Class[Mosquitto::Install] to Class[Mosquitto::Config] with 'before'
       	Debug: Adding relationship from Class[Mosquitto::Config] to Class[Mosquitto::Service] with 'notify'
       	Notice: Compiled catalog for freebsd12-64-1 in environment production in 0.03 seconds
       	Debug: Found in cache :production (ttl = 0 sec)
       	Debug: /Package[mosquitto]: Provider pkgng does not support features targetable; not managing attribute command
       	Debug: /Package[mosquitto]: Provider pkgng does not support features install_only; not managing attribute install_only
       	Debug: /Package[mosquitto]: Provider pkgng does not support features virtual_packages; not managing attribute allow_virtual
       	Debug: /Service[mosquitto]: Provider freebsd does not support features manages_logon_credentials; not managing attribute logonpassword
       	Debug: Facter: resolving fact with user_query: operatingsystem
       	Debug: Facter: Searching fact: operatingsystem in file: operatingsystem.rb
       	Debug: Facter: Searching fact: operatingsystem in core facts and external facts
       	Debug: Facter: Loading all internal facts
       	Debug: Facter: List of resolvable facts: [#<Facter::SearchedFact:0x00000008064f4ee0 @name="operatingsystem", @fact_class=Facts::Freebsd::Os::Name, @user_query="operatingsystem", @type=:legacy, @file=nil>]
       	Debug: Facter: Loading external facts
       	Debug: Facter: fact "operatingsystem" has resolved to: FreeBSD
       	Debug: /Service[mosquitto]: Provider freebsd does not support features configurable_timeout; not managing attribute timeout
       	Debug: Creating default schedules
       	Debug: Loaded state in 0.00 seconds
       	Info: Using environment 'production'
       	Debug: Loaded state in 0.00 seconds
       	Info: Applying configuration version '1677332393'
       	Debug: /Stage[main]/Mosquitto::Install/before: before to Class[Mosquitto::Config]
       	Debug: /Stage[main]/Mosquitto::Config/notify: notify to Class[Mosquitto::Service]
       	Debug: Facter: resolving fact with user_query: operatingsystem
       	Debug: Facter: Searching fact: operatingsystem in file: operatingsystem.rb
       	Debug: Facter: Searching fact: operatingsystem in core facts and external facts
       	Debug: Facter: Loading all internal facts
       	Debug: Facter: List of resolvable facts: [#<Facter::SearchedFact:0x000000080682e278 @name="operatingsystem", @fact_class=Facts::Freebsd::Os::Name, @user_query="operatingsystem", @type=:legacy, @file=nil>]
       	Debug: Facter: Loading external facts
       	Debug: Facter: fact "operatingsystem" has resolved to: FreeBSD
       	Debug: Prefetching pkgng resources for package
       	Debug: Executing: '/usr/local/sbin/pkg query -a %n %v %o'
       	Debug: Executing: '/usr/local/sbin/pkg version -voRL='
       	Debug: Facter: resolving fact with user_query: operatingsystem
       	Debug: Facter: Searching fact: operatingsystem in file: operatingsystem.rb
       	Debug: Facter: Searching fact: operatingsystem in core facts and external facts
       	Debug: Facter: Loading all internal facts
       	Debug: Facter: List of resolvable facts: [#<Facter::SearchedFact:0x0000000804ff0d00 @name="operatingsystem", @fact_class=Facts::Freebsd::Os::Name, @user_query="operatingsystem", @type=:legacy, @file=nil>]
       	Debug: Facter: Loading external facts
       	Debug: Facter: fact "operatingsystem" has resolved to: FreeBSD
       	Debug: Facter: resolving fact with user_query: operatingsystem
       	Debug: Facter: Searching fact: operatingsystem in file: operatingsystem.rb
       	Debug: Facter: Searching fact: operatingsystem in core facts and external facts
       	Debug: Facter: Loading all internal facts
       	Debug: Facter: List of resolvable facts: [#<Facter::SearchedFact:0x000000080512b0d0 @name="operatingsystem", @fact_class=Facts::Freebsd::Os::Name, @user_query="operatingsystem", @type=:legacy, @file=nil>]
       	Debug: Facter: Loading external facts
       	Debug: Facter: fact "operatingsystem" has resolved to: FreeBSD
       	Debug: Facter: resolving fact with user_query: operatingsystem
       	Debug: Facter: Searching fact: operatingsystem in file: operatingsystem.rb
       	Debug: Facter: Searching fact: operatingsystem in core facts and external facts
       	Debug: Facter: Loading all internal facts
       	Debug: Facter: List of resolvable facts: [#<Facter::SearchedFact:0x0000000805cd2cd0 @name="operatingsystem", @fact_class=Facts::Freebsd::Os::Name, @user_query="operatingsystem", @type=:legacy, @file=nil>]
       	Debug: Facter: Loading external facts
       	Debug: Facter: fact "operatingsystem" has resolved to: FreeBSD
       	Debug: Service[mosquitto](provider=freebsd): Could not find mosquitto in /etc/rc.d
       	Debug: Executing: '/usr/local/etc/rc.d/mosquitto onestatus'
       	Debug: Executing: '/usr/local/etc/rc.d/mosquitto rcvar'
       	Debug: Service[mosquitto](provider=freebsd): rcvar value is YES
       	Debug: Service[mosquitto](provider=freebsd): Is enabled
       	Debug: Facter: resolving fact with user_query: osfamily
       	Debug: Facter: Searching fact: osfamily in file: osfamily.rb
       	Debug: Facter: Searching fact: osfamily in core facts and external facts
       	Debug: Facter: Loading all internal facts
       	Debug: Facter: List of resolvable facts: [#<Facter::SearchedFact:0x0000000805db0a08 @name="osfamily", @fact_class=Facts::Bsd::Os::Family, @user_query="osfamily", @type=:legacy, @file=nil>]
       	Debug: Facter: Loading external facts
       	Debug: Facter: fact "osfamily" has resolved to: FreeBSD
       	Debug: Executing: '/usr/local/etc/rc.d/mosquitto onestart'
       	Debug: Executing: '/usr/local/etc/rc.d/mosquitto rcvar'
       	Debug: Service[mosquitto](provider=freebsd): rcvar value is YES
       	Debug: Service[mosquitto](provider=freebsd): Is enabled
       	Notice: /Stage[main]/Mosquitto::Service/Service[mosquitto]/ensure: ensure changed 'stopped' to 'running'
       	Debug: /Service[mosquitto]: The container Class[Mosquitto::Service] will propagate my refresh event
       	Info: /Service[mosquitto]: Unscheduling refresh on Service[mosquitto]
       	Debug: Class[Mosquitto::Service]: The container Stage[main] will propagate my refresh event
       	Debug: Class[Mosquitto::Service]: The container Class[Mosquitto] will propagate my refresh event
       	Debug: Class[Mosquitto]: The container Stage[main] will propagate my refresh event
       	Debug: Finishing transaction 14280
       	Debug: Storing state
       	Debug: Pruned old state cache entries in 0.00 seconds
       	Debug: Stored state in 0.00 seconds
       	Notice: Applied catalog in 0.50 seconds
       	Debug: Applying settings catalog for sections reporting, metrics
       	Debug: Finishing transaction 17820
       	Debug: Received report to process from freebsd12-64-1
       	Debug: Processing report from freebsd12-64-1 with processor Puppet::Reports::Store
       
     Shared Example Group: "an idempotent resource" called from ./spec/acceptance/mosquitto_spec.rb:7
     # ./vendor/bundle/ruby/3.1.0/gems/beaker-4.39.0/lib/beaker/host.rb:396:in `exec'
     # ./vendor/bundle/ruby/3.1.0/gems/beaker-4.39.0/lib/beaker/dsl/helpers/host_helpers.rb:83:in `block in on'
     # ./vendor/bundle/ruby/3.1.0/gems/beaker-4.39.0/lib/beaker/shared/host_manager.rb:129:in `run_block_on'
     # ./vendor/bundle/ruby/3.1.0/gems/beaker-4.39.0/lib/beaker/dsl/patterns.rb:37:in `block_on'
     # ./vendor/bundle/ruby/3.1.0/gems/beaker-4.39.0/lib/beaker/dsl/helpers/host_helpers.rb:63:in `on'
     # ./vendor/bundle/ruby/3.1.0/bundler/gems/beaker-puppet-128ee4654065/lib/beaker-puppet/helpers/puppet_helpers.rb:529:in `block in apply_manifest_on'
     # ./vendor/bundle/ruby/3.1.0/gems/beaker-4.39.0/lib/beaker/shared/host_manager.rb:129:in `run_block_on'
     # ./vendor/bundle/ruby/3.1.0/gems/beaker-4.39.0/lib/beaker/dsl/patterns.rb:37:in `block_on'
     # ./vendor/bundle/ruby/3.1.0/bundler/gems/beaker-puppet-128ee4654065/lib/beaker-puppet/helpers/puppet_helpers.rb:457:in `apply_manifest_on'
     # ./vendor/bundle/ruby/3.1.0/gems/voxpupuli-acceptance-1.2.0/lib/voxpupuli/acceptance/examples.rb:9:in `block (2 levels) in <top (required)>'

  2) mosquitto with default parameters Service "mosquitto" is expected to be running
     Failure/Error: it { is_expected.to be_running }
       expected Service "mosquitto" to be running
       
     # ./spec/acceptance/mosquitto_spec.rb:12:in `block (4 levels) in <top (required)>'

  3) mosquitto with default parameters Port "1883" is expected to be listening
     Failure/Error: it { is_expected.to be_listening }
       expected Port "1883" to be listening
       
     # ./spec/acceptance/mosquitto_spec.rb:17:in `block (4 levels) in <top (required)>'

Finished in 12.55 seconds (files took 56.97 seconds to load)
5 examples, 3 failures

Failed examples:

rspec './spec/acceptance/mosquitto_spec.rb[1:1:1:2]' # mosquitto with default parameters behaves like an idempotent resource applies a second time without changes
rspec ./spec/acceptance/mosquitto_spec.rb:12 # mosquitto with default parameters Service "mosquitto" is expected to be running
rspec ./spec/acceptance/mosquitto_spec.rb:17 # mosquitto with default parameters Port "1883" is expected to be listening

Fore some reason Puppet doesn't want to actually start the service

@evgeni
Copy link
Member Author

evgeni commented Feb 25, 2023

For some reason, the service is not started after this:

    # puppet resource service mosquitto ensure=running -v
    Notice: /Service[mosquitto]/ensure: ensure changed 'stopped' to 'running'
    Info: /Service[mosquitto]: Unscheduling refresh on Service[mosquitto]
    service { 'mosquitto':
      ensure   => 'stopped',
      provider => 'freebsd',
    }

@evgeni
Copy link
Member Author

evgeni commented Feb 25, 2023

so it turns out, it defaults to log to stderr, which, uh, doesn't work well if it gets executed by puppet and shit crashes.
logging to syslog makes things nice and tidy

@smortex smortex changed the title FreeBSD support Fix FreeBSD support Feb 25, 2023
@smortex smortex added the bug Something isn't working label Feb 25, 2023
Copy link
Member

@smortex smortex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see minor issues like no way to override default_config, but maybe it is not something that will annoy anybody, and if so they will be happy to find a working module before hitting this anyway, so LGTM!

@evgeni
Copy link
Member Author

evgeni commented Feb 25, 2023

Yeah, I don't like that default_config too much either, but it makes things work… 🤷‍♀️

@evgeni
Copy link
Member Author

evgeni commented Feb 25, 2023

as an alternative we could make this non empty on FreeBSD?

Array[String[1]] $config = [],

@smortex
Copy link
Member

smortex commented Feb 25, 2023

I think that it is good enough for now.

If you want to improve further, something that allow a user to override some defaults without loosing the others would be the best. This is generally done by having independent parameters, with system dependent default values in Hiera (so a breaking change).

I am not a user of Mosquitto so I do not know what config can look like. In some case it is not possible to go this way, for example the mysql module has 2 parameters, one to add settings and one to replace all settings (needed when you don't one of the default values).

In either case, it is a lot of changes and not really related to this PR which just fix FreeBSD support.

especially the unconditional `else` breaks on FreeBSD which has no
iproute
otherwise `service mosquitto status` doesn't work
otherwise the service doesn't properly start up when run by puppet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants