Giter Club home page Giter Club logo

puppet-pkgng's Introduction

Puppet-pkgng

Build Status Puppet Forge Puppet Forge - downloads Puppet Forge - endorsement Puppet Forge - scores

The package provider that matured in this repository has been merged upstream into the core Puppet package providers. As of puppet 4.1, you can enjoy the fruits of the pkgng provider without this module. This module now remains to manage pkg.conf, extra package repositories etc.

If you are looking to build your own PkgNG packages, you may also want to look at the poudriere module.

Upgrading Requirements

To use the 1.x or newer version of this module, ensure that you are running Puppet 4.1 or higher. Any of the pkgng_* facts that were employed outside of this repository should be re-evaluated. Those facts are no longer distributed with this module.

If you are using a Package override to specify that pkgng should be used as the provider, this should no longer be required as the pkgng provider is now the default for FreeBSD.

The latest release of this module to contain the package provider is 0.4.0.

Installation

The easiest way to install is to install from the forge.

puppet module install puppet/pkgng

Then to configure your system to use PkgNG with all default settings, a simple include will do.

include pkgng

You may wish to override settings though, to do this simply use it as a class:

class { 'pkgng':
  purge_repos_d => false,
  options       => [
    'PKG_ENV : {',
    ' http_proxy: "http://proxy:3128"',
    '}',
  ],
}

By default, this module will erase user-defined repository not managed by Puppet. To disable this behaviour you can use the example above of setting purge_repos_d to false.

Disabling the FreeBSD default repository is done with:

pkgng::repo { 'FreeBSD':
  enabled => false,
}

Using specific repositories is as simple as a Puppet resource.

pkgng::repo { 'pkg.freebsd.org': }  # You'll want this one!
pkgng::repo { 'my.own.repo': }      # You can then specify more...

Installation via R10K

You can also clone this repo to somewhere in your modulepath, or use something like r10k to deploy your modules. R10k is sweet. For those not familiar, check out Finch's blog post on the subject of module deployment.

To track the git repository, a line in your Puppetfile that looks something like the following should get you started.

mod 'pkgng', :git => 'git://github.com/xaque208/puppet-pkgng.git', :ref => '1.0.0'

Installation via Librarian-Puppet

Installation via Librarian-Puppet is straight forward, simply add the following to your Puppetfile

mod 'zleslie/pkgng'

Usage

Once the module is installed, you can simply install package resources.

package { 'curl': }

With multiple repositories defined, a package can be installed from a specific repo by giving a URN locator for that repository like this.

pkgng::repo { 'my.own.repo': }

package { 'puppet':
  source => 'urn:freebsd:repo:my.own.repo',
}

If you have multiple repos providing the same package you can prefer one repo over the other by increasing the priority. The default priority is 0 and higher priorities are preferred.

pkgng::repo { 'pkg.freebsd.org': }
pkgng::repo { 'my.own.repo':
  priority => 10,
}

package {'curl': }

With the above config if the 'curl' package exists in both repositories it would be installed from my.own.repo

Contributing

Please help make this module better. Send pull request, file issues, be mindful of the tests and help improve where you can.

For any provider changes, please submit those directly to core Puppet.

Thanks

Thanks to all contributors who helped mature the provider and helped it graduate from this module into core Puppet. Its maintenance will also require community attention.

puppet-pkgng's People

Contributors

aduitsis avatar b4ldr avatar bastelfreak avatar bwalex avatar dhoppe avatar ekohl avatar fraenki avatar geoffgarside avatar georgepearman avatar igalic avatar jdmulloy avatar kubicek avatar langseth avatar leepa avatar m8t avatar maxadamo avatar olevole avatar rmelcer avatar sathieu avatar sc68cal avatar skoef avatar smortex avatar strangelittlemonkey avatar tdb avatar zachfi avatar zilchms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

puppet-pkgng's Issues

ASSUME_ALWAYS_YES=1 generates an error

ASSUME_ALWAYS_YES=1 in is no longer valid (in lib/facter/pkgng.rb). I'm running pkg-1.3.5.1 on FreeBSD 10.0), it generates an error:

pkg: Invalid type for environment variable ASSUME_ALWAYS_YES, got 1, while expecting a boolean

So that needs to be ASSUME_ALWAYS_YES=true, probably conditional on the pkg version. I'm not exactly sure as of which version of pkg this became an error.

PACKAGESITE keeps coming back

For some reason, on many of my boxes, it seems that the PACKAGESITE keeps inserting itslef, which may mean that the package version detection not working correctly.

Info: Applying configuration version '6c81e13'
Notice: /Stage[main]/Pkgng/File[/usr/local/etc/pkg.conf]/content:
--- /usr/local/etc/pkg.conf     2014-02-09 21:07:28.346356781 -0800
+++ /tmp/puppet-file20140212-99440-pvyb3q       2014-02-12 20:49:20.122557573 -0800
@@ -1,3 +1,2 @@
-PACKAGESITE: pkg+http://pkg.FreeBSD.org/${ABI}/latest
 PKG_DBDIR: /var/db/pkg
 PKG_CACHEDIR: /var/cache/pkg

Notice: /Stage[main]/Pkgng/File[/usr/local/etc/pkg.conf]/content: current_value {md5}278a688261955fb7d896fcde9008aefc, should be {md5}3544a4e54f064e6ac0676c57c2648838 (noop)
Info: /Stage[main]/Pkgng/File[/usr/local/etc/pkg.conf]: Scheduling refresh of Exec[pkg update]
Notice: /Stage[main]/Pkgng/Exec[pkg update]: Would have triggered 'refresh' from 1 events
Notice: Class[Pkgng]: Would have triggered 'refresh' from 2 events
Notice: Stage[main]: Would have triggered 'refresh' from 1 events
Notice: Finished catalog run in 27.96 seconds

pkg in alternate locations

Currently, this assumes that pkg is located in /usr/local. The ports system allows users to change this location with the LOCALBASE knob in make.conf, which I have done. Of course, the module fails because there are several "/usr/local"s hard-coded.

I'm fairly new to Puppet, but I couldn't wrap my head around how best to implement this as a user-configurable setting. I don't think that automatically using LOCALBASE from /etc/make.conf is safe, because this won't necessarily be set if ports are 100% installed from binary packages.

version pinning not working

when i set 'ensure => [version number]' on a package, a package of a different version gets installed. e.g.

package {
'openssl':
ensure => '1.0.1_9';
}

however, 1.0.1_11 gets installed. on the next puppet run, puppet returns:
Notice: /Stage[main]/Site::Freebsd/Package[openssl]/ensure: ensure changed '1.0.1_11' to '1.0.1_9'

but does not actually downgrade the package.

Code not in sync with puppet Forge?

It looks like the forge.puppet.com module is the code from 1.1.1 but with a 1.2.0 version string. Something doesn't add up.

puppet module install --modulepath /usr/local/etc/puppet/code/site_modules zleslie-pkgng

If I look at the first few lines of manifests/init.pp from the Forge module:

class pkgng (
  Pattern[/^\/.*/] $pkg_dbdir     = $pkgng::params::pkg_dbdir,
  Pattern[/^\/.*/] $pkg_cachedir  = $pkgng::params::pkg_cachedir,
  Pattern[/^\/.*/] $portsdir      = $pkgng::params::portsdir,
  Array            $options       = [],
  Boolean          $purge_repos_d = true,
  Hash             $repos         = {},
) inherits pkgng::params {

Whereas the Github code shows:

class pkgng (
  Stdlib::Absolutepath $pkg_dbdir     = $pkgng::params::pkg_dbdir,
  Stdlib::Absolutepath $pkg_cachedir  = $pkgng::params::pkg_cachedir,
  Stdlib::Absolutepath $portsdir      = $pkgng::params::portsdir,
  Array[String]        $options       = [],
  Boolean              $purge_repos_d = true,
  Hash                 $repos         = {},
) inherits pkgng::params {

I noticed this difference because my Puppet installation kept adding WITH_PKGNG=YES to make.conf over and over again. Which is the behavior of 1.1.1.

only use package name in install command

it seems that in pkgng, origin and version cannot both be passed to pkg install. for example, if a module sets $package_name = security/xinetd, and we also want to set ensure => 2.3.15_1, the command pkg install -qy security/xinetd-2.3.15_1 fails. pkg install -qy security/xinetd works, as does pkg install -qy xinetd-2.3.15_1, but it doesn't with both origin and version set.

around line 93 of lib/puppet/provider/package/pkgng.rb, adding this should strip out origin when it is specified:
installname = installname.split('/').last.

version 0.0.5 keeps creating/updating packages

I upgraded 0.0.4 to 0.0.5, had to downgrade back to 0.0.4. When running 'puppet agent -t' after upgrade it keeps saying:

Notice: /Stage[main]/Pw::Fbsd::Vim-lite/Package[vim-lite]/ensure: created

That's for every package installed on the system via puppet, every time puppet runs, not only the first time after module upgrade.

What's worse, my packages are defined with 'ensure => present', but this caused some of them to be upgraded, like tmux (from /var/log/messages):

Aug 7 12:50:47 host puppet-agent[58929]: (/Stage[main]/Pw::Fbsd::Arping/Package[arping]/ensure) created
Aug 7 12:50:47 host pkg: tmux upgraded: 1.8 -> 1.8_1
Aug 7 12:50:47 host puppet-agent[58929]: (/Stage[main]/Pw::Fbsd::Tmux/Package[tmux]/ensure) created
Aug 7 12:50:47 host puppet-agent[58929]: (/Stage[main]/Pw::Fbsd::Lsof/Package[lsof]/ensure) created

However, dependencies that are not explicitly defined in puppet (like expat) were not upgraded.

Fix command pkg update --quiet option

pkg -q update -f yields an error:

# pkg -q update -f
pkg: illegal option -- q

The following fixes it:

diff --git a/modules/pkgng/manifests/init.pp b/modules/pkgng/manifests/init.pp
index 277afb3..23d3b1b 100644
--- a/modules/pkgng/manifests/init.pp
+++ b/modules/pkgng/manifests/init.pp
@@ -70,7 +70,7 @@ class pkgng (
   exec { 'pkg update':
     path        => '/usr/local/sbin',
     refreshonly => true,
-    command     => 'pkg -q update -f',
+    command     => 'pkg update -q -f',
   }

   # This exec should really on ever be run once, and only upon converting to

pkgng_version fact breaks under facter 2.1.0

I've just done an upgrade of my puppet clients to 3.6.2 which pulls in facter 2.1.0. After the upgrade the pkgng_version fact is broken:

% sudo facter -p pkgng_version
Could not retrieve fact='pkgng_version', resolution='<anonymous>': undefined method `pkgng_enabled' for Facter:Module

This results in the following errors on a puppet run:

Could not retrieve fact='pkgng_version', resolution='<anonymous>': undefined method `pkgng_enabled' for Facter:Module
Could not retrieve fact='pkgng_version', resolution='<anonymous>': undefined method `pkgng_enabled' for Facter:Module
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: PKGng is either not supported on your system or it is too old at /etc/puppetlabs/puppet/modules/pkgng/manifests/init.pp:18 on node testbox.conundrum.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

According to the facter 2.1 docs it looks like this line:

    if Facter.pkgng_enabled

should be:

    if Facter.value(:pkgng_enabled)

See: http://docs.puppetlabs.com/facter/2.1/custom_facts.html#using-other-facts

$pkgng_enabled fact not available to pkgng.rb

FreeBSD 10 with pkgng here. I can see that

facter --puppet 

yields:

pkgng_enabled => true

I can also see in pkgng.rb:9

defaultfor :operatingsystem => :freebsd if $pkgng_enabled

However, $pkgng_enabled is not available when the code in invoked. Doing something like Puppet.info(global_variables.to_yaml) in that point in the code also shows that no other facts are available to the module for that matter.

That the pkgng module does not get to be default is highly problematic, because lacking a default, puppet tries to pick the first available from all the candidates and warns with the message:

Warning: Found multiple default providers for package: pkgng, pip, gem; using pkgng

Of course, one can select the provider by explicitly doing Provider { package => 'pkgng' }, but the presence of the warning means that the agent return code will not be 0, which leads to all sorts of other problems, which I'm sure you are aware of.

I don't know whether this is a problem intrinsic with puppet-pkgng, but nonetheless I would like to inform you of it, in case you have any idea on how to approach this.

Not overriding default provider w/ PE 3.3.0

It looks like the default provider isn't being overridden when pkgng is used on PE 3.3.0 (puppet 3.6.2, Ubuntu 12.04 LTS) with an OSS puppet 3.4.2 client (FreeBSD). The pkgng provider is being executed, but so is the default provider, and that's causing errors to be thrown. For example, using the pkgng provider to make sure that 'pkg' is at the latest version throws this error:

root@testbox:~ # puppet agent -t
Info: Retrieving plugin
Info: Loading facts in /var/puppet/lib/facter/concat_basedir.rb
Info: Loading facts in /var/puppet/lib/facter/staging_http_get.rb
Info: Loading facts in /var/puppet/lib/facter/root_home.rb
Info: Loading facts in /var/puppet/lib/facter/pe_postgres_default_version.rb
Info: Loading facts in /var/puppet/lib/facter/pkgng.rb
Info: Loading facts in /var/puppet/lib/facter/facter_dot_d.rb
Info: Loading facts in /var/puppet/lib/facter/puppet_vardir.rb
Info: Loading facts in /var/puppet/lib/facter/iptables_version.rb
Info: Loading facts in /var/puppet/lib/facter/iptables_persistent_version.rb
Info: Loading facts in /var/puppet/lib/facter/ip6tables_version.rb
Info: Loading facts in /var/puppet/lib/facter/pe_version.rb
Info: Loading facts in /var/puppet/lib/facter/postgres_default_version.rb
Info: Loading facts in /var/puppet/lib/facter/windows.rb
Info: Loading facts in /var/puppet/lib/facter/pe_build.rb
Info: Loading facts in /var/puppet/lib/facter/pe_puppetdb_server_status.rb
Info: Loading facts in /var/puppet/lib/facter/custom_auth_conf.rb
Info: Loading facts in /var/puppet/lib/facter/platform_tag.rb
/usr/local/lib/ruby/site_ruby/1.9/puppet/provider/package/freebsd.rb:18: warning: class variable access from toplevel
/usr/local/lib/ruby/site_ruby/1.9/puppet/provider/package/freebsd.rb:19: warning: class variable access from toplevel
Info: Caching catalog for testbox.conundrum.com
Error: Failed to apply catalog: Parameter ensure failed on Package[pkg]: Provider must have features 'upgradeable' to set 'ensure' to 'latest' at /etc/puppetlabs/puppet/environment/production/modules/packaging/manifests/freebsd/package.pp:10
Wrapped exception:
Provider must have features 'upgradeable' to set 'ensure' to 'latest'

If I instead try to set it to simply 'installed' the old provider throws this error instead:

/usr/local/lib/ruby/site_ruby/1.9/puppet/provider/package/freebsd.rb:18: warning: class variable access from toplevel
/usr/local/lib/ruby/site_ruby/1.9/puppet/provider/package/freebsd.rb:19: warning: class variable access from toplevel
Info: Caching catalog for testbox.conundrum.com
Info: Applying configuration version '1406498853'
Error: pkg: not in required origin format: .*/<port_category>/<port_name>
Error: /Stage[main]/Packaging::Freebsd::Package/Package[pkg]/ensure: change from absent to present failed: pkg: not in required origin format: .*/<port_category>/<port_name>

The pkgng provider module is in the basemodulepath ahead of the stock PE modules.

freebsd version detection

This code: if kernel.to_i =~ /^(9|10)/ doesn't seems to be correct, since it doesn't matches against freebsd 9.1

README fix

Instead of

puppet module install xaque208/pkgng

it should be

puppet module install zleslie/pkgng

Dependency cycles when using with theforeman/puppet-dhcp

Hi,

I get the following dependency cycles when using this in conjunction with theforeman/puppet-dhcp:

Error: Found 1 dependency cycle:
(Exec[pkg update] => Package[isc-dhcp44-server] => File[/usr/local/etc] => File[/usr/local/etc/pkg.conf] => Exec[pkg update])

output

The only thing I've noticed is that theforeman/puppet-dhcp manages the /usr/local/etc directory and has a package referenced:

  file { $dhcp_dir:
    mode    => '0755',
    require => Package[$packagename],
  }

(https://github.com/theforeman/puppet-dhcp/blob/53e8e4abe0f8da9d85aec883098f2e43e09ca859/manifests/init.pp#L68-L71)

I've read the relevant parts in theforeman/puppet-dhcp and it looks good to me, not an uncommon pattern.

It looks like it's an unfortunate choice of resource relationships causes this issue. Do you see any chance to adjust the related resource relationships in the pkng module to avoid this kind of dependency cycle?

package not found in INDEX

Hi,

When I'm on the command line I can simply do 'pkg install puppet' and it will install my puppet package. The same goes for 'pkg install any/puppet'.

However, when trying to install the puppet package via this puppet module, I'm told that: "package not found in INDEX".

Prefixing the package name with 'any/' results in the same error.

I must admit I'm a total pkgng/bsd noob, but maybe you could help me out here? From a user perspective I'd say the thing I'm trying to do is expected (user) behavior. Either that, or I'm just that wrong ;)

Regards,

Dolf
-- Freeaqingme

Doesn't work if pkgng version isn't latest

If pkgng isn't the latest version, it forces you to install prior to allowing you to do package installations, so invoking this on a fresh system will repeatedly fail.

Allow modifying / disabling repos in /etc

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 6.19.1
  • Ruby: 2.6
  • Distribution: FreeBSD 12.2-RELEASE
  • Module version: 2.4.0

How to reproduce (e.g Puppet code you use)

according to the README,

Disabling the FreeBSD default repository is done with:

pkgng::repo { 'FreeBSD':
 enabled => false,
}

What are you seeing

This, however, just adds a file in /usr/local/etc/pkg/repos, but that does not seem to actually disable the repo

What behaviour did you expect instead

I would expect to disable the FreeBSD repo, by modifying /etc/pkg/FreeBSD.conf

Any additional information you'd like to impart

I don't know if this is a bug in pkg.

possibility of regulation (and turnoff) for pkg_has_updates / monopolization of pkg by pkgng via pkg-version

For system with lot of packages execution of:

https://github.com/xaque208/puppet-pkgng/blob/2.1.1/lib/facter/pkg_updates.rb#L8:

50338  1  S      0:00.01 /usr/sbin/pkg version -ql<
50339  1  D      0:00.12 /usr/sbin/pkg version -ql<

for pkg_has_updates facts always lock pkg for a long time and user can do anything with pkg. The problem is the slow 'pkg version' execution when ports not installed (and fetchindex not performed).
For example, on a PC with desktop role (KDE5) and 1746 packages this operation may take ~ 20 minutes (no ssd, one hdd).

More details: freebsd/pkg#1739

it would be nice to regulate this behavior and be able to turn off. Or try to find another solution, for example pkg dry-run:

pkg upgrade -Unq

or

pkg version -RU

Order of operations problem with Puppet 4

In Puppet 4.x after the pkgng provider was incorporated into the core there is an order of operations problem that causes failed, or very long puppet runs. This is tested with puppet 4.5.1 and zleslie/pkgng 1.1.1.

In my setup the pkgng class is included in site.pp like this:

class { 'pkgng':
  purge_repos_d => true,
}

I then include a pkgng::repo resource on FreeBSD hosts to define a local repository.

In this case, the order of operations appears to be:

  1. purge repositories (purge_repos_d true)
  2. update/install packages
  3. process pkgng::repo objects

There are two very painful failure modes with this.

First, on a system where the existing repository is being completely replaced with a local repository (possibly a new system with the default FreeBSD repository), the old repository is deleted, then packages are updated, then the new repository is installed. The core pkgng provider fails badly if no repository is present (see https://groups.google.com/d/topic/puppet-users/ZtfxbkCEyWc/discussion). There's no easy way to recover from this within puppet. Since the agent run fails at the point that the pkgng provider errors out, the repo resource never gets created. The only fix is to use some other process to create the proper repository config files on all the affected systems.

In the second failure mode, if a repository host or path is being updated, the agent run takes a very long time while all of the package version checks individually time out, before the repository is updated at the end of the agent run.

I'm not sure what the fix is for this. There at least needs to be a way to swap the order of pkgng::repo handling and package updates. Preferably the purge of unmanaged repo resources would happen at the same time as the update of managed repo resources.

Logo proposal

Hey, I am graphic designer and my aim is make my portfolio better with supporting open source project in field of graphic. I can contribute on your project with making a logo design. I would be very pleased if you interested. I am waiting your feedback, have a nice day! :)

Best Regards,
Baran Pirincal
Visual Communication Designer

module registers as puppet-pkgng instead of zleslie-pkgng

Not sure if this is actually an issue or not, maybe I'm doing something wrong. When installing the module by running 'puppet module install zleslie/pkgng', the module registers itself as 'puppet-pkgng'. Running 'puppet module upgrade puppet-pkgng' returns an error saying the module doesn't exist on forge. Running 'puppet module upgrade zleslie-pkgng' returns an errors saying the module is not installed. So the only way to upgrade/downgrade is to delete the module and install it again.

latest not working

Hi
Is it possible to work install the latest version of repos?
If I use the example.

package {'shells / bash':
The ensure => Präsente,
provider => pkgng,
}
It does not have any effect (after the restart puppet agent version is changed), after that, how to initialize the pkg update?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.