Version information
This version is compatible with:
- FreeBSD
Start using this module
Add this module to your Puppetfile:
mod 'ptomulik-bsdportconfig', '0.2.4'
Learn more about managing modules with a PuppetfileDocumentation
bsdportconfig
Configure build options for FreeBSD ports.
Warning
Bsdportconfig was not developed for last few years and may not work with recent FreeBSD releases. I'm not going to develop it further, as there is ptomulik/portsng, which handles build options, ports maintenance (install/uninstall/update) and is a mature and tested module.
Table of Contents
Overview
This module implements a bsdportconfig resource which maintains build options for packages installed with BSD ports.
Module Description
The bsdportconfig module helps to configure BSD ports.
Installation and de-installation of FreeBSD ports is handled quite well by
package
resource from puppet's core. However, it has no way to
set configuration options for ports (no make config
stage), and always
installs packages with their default options (or with manually pre-set
options).
This module tries to fill this gap. It helps to ensure, that certain configuration options are set (or unset) for certain ports. You may chain the bsdportconfig resource with package to achieve automatic configuration of ports before they get installed.
The module supports only the on/off options.
Setup
What Bsdportconfig affects
This module affects:
- options for given ports, it's done by modifying options files
$PORT_DBDIR/*/options.local
, where$PORT_DBDIR='/var/db/ports'
by default, - make command is used to search ports and retrieve port characteristics,
these invocations of
make
are read-only and should not affect your system by their own,
Setup Requirements
You may need to enable pluginsync in your puppet.conf.
Beginning with Bsdportconfig
Note: the resource writes to file only the options listed in options
parameter. Other options do are not written to options files.
Example: ensure that www/apache22
is configured with SUEXEC
and CGID
modules:
bsdportconfig { 'www/apache22': options => { 'SUEXEC'=>on, 'CGID'=>on } }
Example: ensure that www/apache22
is configured without CGID
module:
bsdportconfig { 'www/apache22': options => { 'CGID'=>off } }
Example: install www/apache22
package with SUEXEC
module enabled:
bsdportconfig { 'www/apache22': options => { 'SUEXEC'=>on } }
package { 'www/apache22': require => Bsdportconfig['www/apache22'] }
Example: since version 0.1.6 you may use portnames to identify ports:
bsdportconfig { 'apache22': options => {'SUEXEC'=>on} }
Example: since version 0.2.0 pkgnames are also supported:
bsdportconfig { 'apache22-2.2.25': options => {'SUEXEC'=>on} }
Usage
Resource type: bsdportconfig
Set build options for BSD ports.
TERMINOLOGY
We use the following terminology when referring ports/packages:
- a string in form
'apache22'
or'ruby'
is referred to as portname - a string in form
'apache22-2.2.25'
or'ruby-1.8.7.371,1'
is referred to as a pkgname - a string in form
'www/apache22'
or'lang/ruby18'
is referred to as a port origin
See http://www.freebsd.org/doc/en/books/porters-handbook/makefile-naming.html
Port origins are used as primary identifiers for bsdportconfig instances. It's recommended to use origins or pkgnames to identify ports.
AMBIGUITY OF PORTNAMES
Accepting portnames (e.g. apache22
) as the name
parameter was introduced for convenience in 0.2.0. However, portnames in
this form are ambiguous, meaning that port search may find multiple ports
matching the given portname. For example 'ruby'
package has three ports
at the time of this writing (2013-08-30): ruby-1.8.7.371,1
,
ruby-1.9.3.448,1
, and ruby-2.0.0.195_1,1
with origins lang/ruby18
,
lang/ruby19
and lang/ruby20
respectively. If you pass a portname which
matches multiple ports, transaction will fail with a message such as:
Error: Could not prefetch bsdportconfig provider 'ports': found 3 ports with name 'ruby': 'lang/ruby18', 'lang/ruby19', 'lang/ruby20'
Parameters within bsdportconfig
:
name (required)
Reference to a port. A portname, pkgname name or origin may be passed as
the name
parameter (see TERMINOLOGY in resource description).
If the name has form 'category/subdir' it is treated as an origin. Otherwise,
the provider tries to find matching port by pkgname and if it fails, by
portname. Note, that portnames are ambiguous, see AMBIGUITY OF
PORTNAMES in the resource description.
options (optional)
Options for the package. This is a hash with keys being option names and values
being 'on'/'off'
strings.
Limitations
These are limitation I see at the moment:
- tested manually on FreeBSD only - any feedback welcome from other OSes,
- unit tests for provider are still missing,
- only on/off options are currently supported, more knowledge about BSD ports is necessary (are there other option types?)
- only options from option files (
/var/db/ports/*/options{,.local}
) are taken into account when retrieving current resource state, - we no longer use public
make showconfig
interface to read option values (it was too slow); the options are retrieved from options files only; this may have some limitations now, and may cause some bugs in future - the algorithm used to read files resembles what was seen in ports' Makefiles, but it was also seen, that the algorithm used by ports is going to be changed (so we may desync at some point)
Development
Project is held on GitHub:
https://github.com/ptomulik/puppet-bsdportconfig
Feel free to submit issue reports to issue tracker or create pull requests.
Types in this module release
2017-11-09 Pawel Tomulik ptomulik@meil.pw.edu.pl
- release 0.2.4
- warn in README.md that bsdportconfig is not actively developed
- switch from Modulefile to metadata.json
- updated testing machinery to work after these four years 2017-11-09 Kim Jahn (mookie-)
- [PR #2] Puppet.newtype is deprecated since puppet 4 - use Puppet::Type.newtype instead 2013-09-01 Pawel Tomulik ptomulik@meil.pw.edu.pl
- release 0.2.3
- corrections to documentation 2013-09-01 Pawel Tomulik ptomulik@meil.pw.edu.pl
- release 0.2.2
- handle empty array arguments in search_ports_by_xxx()
- corrected terminology in docs 2013-08-31 Pawel Tomulik ptomulik@meil.pw.edu.pl
- release 0.2.1
- several optimizations
2013-08-30 Pawel Tomulik ptomulik@meil.pw.edu.pl- when looking for all resource instances, first list all ports and then select only those for which options file(s) exist(s) - this is opose to what we had previously (scanning options files first); this eliminates the need for double scanning of options files, cumbersome port searches and querying for make variables, - querying for make variables (such as OPTIONS_FILE) is no longer performed; this information is now obtained by other means
- release 0.2.0
- module totally revamped:
2013-08-27 Pawel Tomulik ptomulik@meil.pw.edu.pl- reimplemented bsdportconfig to be prefetch/flush resource - most details are shifted to a new Puppet::Util::Bsdportconfig module, - removed $portsdir and $port_dbdir params, these are class attributes now, - the resource is no longer ensurable, the $ensure property was removed, - make -V is used internally to retrieve resource parameters, - make showconfig is no longer used to read current options, - current options are retrieved only from the options files, - options are written to "options.local" instead of "options", - options not listed by user in '$options' are not written to a file, - optimizations are added to reduce number of calls to external commands, - added validation of the $name parameter - unit tests adapted to new implementation
- release 0.1.6
- add support for plain package names (witohut origin) 2013-08-22 Pawel Tomulik ptomulik@meil.pw.edu.pl
- release 0.1.5
- minor corrections to README.md 2013-08-22 Pawel Tomulik ptomulik@meil.pw.edu.pl
- release 0.1.4
- small corrections to ports.rb and README.md 2013-07-06 Pawel Tomulik ptomulik@meil.pw.edu.pl
- release 0.1.3
- fixed lib/puppet/provider/bsdportconfig/ports.rb - delete_if was used as a global function 2013-07-06 Pawel Tomulik ptomulik@meil.pw.edu.pl
- release 0.1.2
- corrections to README.md 2013-07-05 Pawel Tomulik ptomulik@meil.pw.edu.pl
- release 0.1.1 2013-07-05 Pawel Tomulik ptomulik@meil.pw.edu.pl
- corrections to README.md
- fixed unit test to expect correct exception types 2013-07-05 Pawel Tomulik ptomulik@meil.pw.edu.pl
- initial implementation, ver. 0.1.0
Copyright (C) 2013 Paweł Tomulik <ptomulik@meil.pw.edu.pl>. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.