diff --git a/.bundle/config b/.bundle/config new file mode 100644 index 0000000..00ae63b --- /dev/null +++ b/.bundle/config @@ -0,0 +1,3 @@ +--- +BUNDLE_PATH: vendor/bundle +BUNDLE_DISABLE_SHARED_GEMS: true diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..a1b84fe --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,4 @@ +## 2016-10-10 Release 0.0.2 + +- First forge release + diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..4f662dc --- /dev/null +++ b/Gemfile @@ -0,0 +1,18 @@ +source ENV['GEM_SOURCE'] || 'https://rubygems.org' + +puppetversion = ENV.key?('PUPPET_VERSION') ? ENV['PUPPET_VERSION'] : ['>= 3.3'] +gem 'metadata-json-lint' +gem 'puppet', puppetversion +gem 'puppetlabs_spec_helper', '>= 1.0.0' +gem 'puppet-lint', '>= 1.0.0' +gem 'facter', '>= 1.7.0' +gem 'rspec-puppet' + +# rspec must be v2 for ruby 1.8.7 +if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9' + gem 'rspec', '~> 2.0' + gem 'rake', '~> 10.0' +else + # rubocop requires ruby >= 1.9 + gem 'rubocop' +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..717feb8 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,74 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (2.2.8) + ast (2.3.0) + diff-lcs (1.2.5) + facter (2.4.6) + CFPropertyList (~> 2.2.6) + hiera (3.2.1) + json (2.0.2) + json_pure (1.8.3) + metaclass (0.0.4) + metadata-json-lint (0.0.11) + json + spdx-licenses (~> 1.0) + mocha (1.2.0) + metaclass (~> 0.0.1) + parser (2.3.1.4) + ast (~> 2.2) + powerpack (0.1.1) + puppet (4.7.0) + CFPropertyList (~> 2.2.6) + facter (> 2.0, < 4) + hiera (>= 2.0, < 4) + json_pure (~> 1.8) + puppet-lint (2.0.2) + puppet-syntax (2.1.0) + rake + puppetlabs_spec_helper (1.2.2) + mocha (~> 1.0) + puppet-lint (~> 2.0) + puppet-syntax (~> 2.0) + rspec-puppet (~> 2.0) + rainbow (2.1.0) + rake (11.3.0) + rspec (3.5.0) + rspec-core (~> 3.5.0) + rspec-expectations (~> 3.5.0) + rspec-mocks (~> 3.5.0) + rspec-core (3.5.4) + rspec-support (~> 3.5.0) + rspec-expectations (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-mocks (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-puppet (2.4.0) + rspec + rspec-support (3.5.0) + rubocop (0.43.0) + parser (>= 2.3.1.1, < 3.0) + powerpack (~> 0.1) + rainbow (>= 1.99.1, < 3.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.0, >= 1.0.1) + ruby-progressbar (1.8.1) + spdx-licenses (1.1.0) + unicode-display_width (1.1.1) + +PLATFORMS + ruby + +DEPENDENCIES + facter (>= 1.7.0) + metadata-json-lint + puppet (>= 3.3) + puppet-lint (>= 1.0.0) + puppetlabs_spec_helper (>= 1.0.0) + rspec-puppet + rubocop + +BUNDLED WITH + 1.12.5 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c0b30d9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +Copyright (c) 2016 Ben Roberts + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a2ba97a --- /dev/null +++ b/README.md @@ -0,0 +1,187 @@ +# Sabayon + +#### Table of Contents + +1. [Description](#description) +1. [Setup - The basics of getting started with sabayon](#setup) + * [What the sabayon module affects](#what-the-sabayon-module-affects) + * [Beginning with sabayon](#beginning-with-sabayon) +1. [Usage - Configuration options and additional functionality](#usage) +1. [Reference - An under-the-hood peek at what the module is doing and how](#reference) +1. [Limitations - OS compatibility, etc.](#limitations) +1. [Development - Guide for contributing to the module](#development) + +## Description + +This module extends puppet with support for the Sabayon Linux disttribution. + +It adds support for: +* The Entropy package manager +* Managing `Sabayon Community Repository (SCR)` definitions using `enman` +* Entropy package masks and unmasks +* Using systemd as the default service provider + +## Setup + +### What the sabayon module affects + + * `operatingsystem` fact + This module overrides the operatingsystem fact to `Sabayon` on Sabayon + systems. + * `Service` provider + This module overrides the default provider for `service` resources to + force use of `systemd` + * `Package` provider + This module overrides the default provider for `package` resources to + force use of `entropy` + +### Beginning with sabayon + +The types and providers within this module can be used without any special +setup, as long as the required packages are already installed. To let this +module take care of installing the required packages, simply include the +`sabayon` class. + +``` +class { 'sabayon': } +``` + +## Usage + +### Installing packages using entropy + +This module sets the `entropy` provider to be the default for Sabayon, +so no special configuration is required. + +The provider supports package names in both the fully-qualified format, e.g. + +``` +package { 'net-misc/openssh': + ensure => installed, +} +``` + +Or the more verbose format: + +``` +package { 'ssh-server': + ensure => installed, + category => 'net-misc', + name => 'openssh', +} +``` + +The category specification is optional as long as the package name is unique. +For example you could install `pip` as that's (currently) unique, but you could +not install 'mysql' since there's no way to disambiguate between +`virtual/mysql` and `dev-db/mysql`. + +### Managing enman repositories + +``` +enman_repo { 'community': + ensure => present, +} +``` + +### Masking packages + +Entropy is very flexible in how to specify which packages can be masked, +and supports some or all of the following in the atom specification. + +All of these parameters are optional, but at least one must be specified + * `package` (either fully qualified or unqualified package name) + * `operator` (`<`, `<=`, `=`, `>=`, `>`. applied to version) + * `version` + * `slot` + * `use` + * `tag` + * `repo` + +The `entropy_mask` type also takes the following optional parameters: + * `target` (The path to the mask file, defaults to + `/etc/entropy/packages/package.mask`) + +#### Examples + +To mask all packages within the `community` repository by default +and later unmask specific packages, you could use something like: + +``` +entropy_mask { 'mask-community-by-default': + repo => 'community', +} +``` + +Alternatively, you could mask newer versions of a package + +``` +entropy_mask { 'mask-postgresql-9.5+': + package => 'app-shells/bash', + operator => '>=', + version => '9.5', +} +``` + +Or mask a package with an undesirable set of use flags, e.g. +to ensure any installed version of openssh supports ldap, mask +all versions of openssh which don't include ldap support with: + +``` +entropy_mask { 'openssh-without-ldap-support': + package => 'net-misc/openssh', + use => '-ldap', +} +``` + +The `entropy_mask` type directly writes to the mask file, rather than using the +`equo mask` command line. This is so that entries can be removed again when +using `ensure => absent`, something which `equo` doesn't yet provide support +for. All entries managed by puppet include the ` # Puppet Name: namevar` +trailing comment. Puppet will completely ignore the existence of other entries +in this file, which means you could manually manage other entries in the file +if you wished, although this is not recommended since puppet would not be able +to remove unmanaged entries if you later decide you want them to be managed. + +### Unmasking packages + +Unmasking packages works identically to masking packages, except using the +`entropy_unmask` resource. All the same parameters are supported. + +Unmasks take precedence over masks, so assuming +in the example above you have masked everything in the `community` repository +you could enable installing a particular package from that repository again +using: + +``` +entropy_unmask { 'sublime': + package => 'app-editors/sublime-text', +} +``` + +The same caveats about managing the unmask file apply as with `entropy_mask` +above. + +## Reference + +### Classes + + * `::sabayon` class to install required packages to support included types + +### Types + + * `enman_repo` Manages SCR repositories using enman + * `entropy_mask` Manages entropy package masks + * `entropy_unmask` Manages entropy package unmasks + +## Limitations + +This module is actively used by the developer against current Sabayon versions. +Due to the rolling release nature of Sabayon, the module is provided as-is and +cannot be guaranteed to always be in a working state. Updates are provided on a +best-efforts basis. + +## Development + +Pull requests welcome! + diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..eab1662 --- /dev/null +++ b/Rakefile @@ -0,0 +1,32 @@ +require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' +require 'metadata-json-lint/rake_task' + +if RUBY_VERSION >= '1.9' + require 'rubocop/rake_task' + RuboCop::RakeTask.new +end + +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.relative = true +PuppetLint.configuration.ignore_paths = ['spec/**/*.pp', 'pkg/**/*.pp', 'vendor/**/*.pp'] + +desc 'Validate manifests, templates, and ruby files' +task :validate do + Dir['manifests/**/*.pp'].each do |manifest| + sh "puppet parser validate --noop #{manifest}" + end + Dir['spec/**/*.rb', 'lib/**/*.rb'].each do |ruby_file| + sh "ruby -c #{ruby_file}" unless ruby_file =~ %r{spec/fixtures} + end + Dir['templates/**/*.erb'].each do |template| + sh "erb -P -x -T '-' #{template} | ruby -c" + end +end + +desc 'Run metadata_lint, lint, validate, and spec tests.' +task :test do + [:metadata_lint, :lint, :validate, :spec].each do |test| + Rake::Task[test].invoke + end +end diff --git a/examples/init.pp b/examples/init.pp new file mode 100644 index 0000000..90916f6 --- /dev/null +++ b/examples/init.pp @@ -0,0 +1,30 @@ +# The baseline for module testing used by Puppet Labs is that each manifest +# should have a corresponding test manifest that declares that class or defined +# type. +# +# Tests are then run by using puppet apply --noop (to check for compilation +# errors and view a log of events) or by fully applying the test in a virtual +# environment (to compare the resulting system state to the desired state). +# +# Learn more about module testing here: +# https://docs.puppet.com/guides/tests_smoke.html +# + +class { + 'sabayon': +} + +enman_repo { 'community': + ensure => present, +} + +entropy_mask { 'mask-community-by-default': + repo => 'community', +} + +entropy_unmask { 'unmask-sublime': + package => 'app-text/sublime-text', + repo => 'community', +} + +# vim: set ts=2 sw=2 expandtab: diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..4b05ac3 --- /dev/null +++ b/metadata.json @@ -0,0 +1,20 @@ +{ + "name": "optiz0r-sabayon", + "version": "0.0.2", + "author": "Ben Roberts", + "license": "MIT", + "summary": "Extends Puppet with support for the Sabayon Linux distribution", + "source": "https://github.com/optiz0r/puppet-sabayon.git", + "project_page": "https://github.com/optiz0r/puppet-sabayon", + "issues_url": "https://github.com/optiz0r/puppet-sabayon/issues", + "tags": ["sabayon", "entropy"], + "operatingsystem_support": [ + { + "operatingsystem":"Sabayon", + "operatingsystemrelease":[ "16.07", "16.11" ] + } + ], + "dependencies": [ + ], + "data_provider": "hiera" +} diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb new file mode 100644 index 0000000..66ab330 --- /dev/null +++ b/spec/classes/init_spec.rb @@ -0,0 +1,7 @@ +require 'spec_helper' +describe 'sabayon' do + context 'with default values for all parameters' do + it { should contain_class('sabayon') } + it { should contain_package('app-admin/enman') } + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..2c6f566 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1 @@ +require 'puppetlabs_spec_helper/module_spec_helper' diff --git a/vendor/.gitignore b/vendor/.gitignore new file mode 100644 index 0000000..757b422 --- /dev/null +++ b/vendor/.gitignore @@ -0,0 +1 @@ +bundle