Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dc3a3a9337 | |||
| e4df1583df | |||
|
|
0bc87f0cbf | ||
| c87ceb824b | |||
|
|
55da9601b0 | ||
|
|
c46c360eb0 | ||
| 9d89654211 | |||
| d8b9a1b4a5 | |||
| 9f8cc61cf1 | |||
| e962f31411 | |||
| 97c1cc97e6 | |||
| bd1fd54bbb | |||
| 3a4c1c85ad | |||
| 0c3db36c4d |
@@ -1,3 +1,3 @@
|
|||||||
---
|
---
|
||||||
BUNDLE_PATH: vendor/bundle
|
BUNDLE_PATH: "vendor/bundle"
|
||||||
BUNDLE_DISABLE_SHARED_GEMS: true
|
BUNDLE_DISABLE_SHARED_GEMS: "true"
|
||||||
|
|||||||
10
CHANGELOG.md
10
CHANGELOG.md
@@ -1,3 +1,13 @@
|
|||||||
|
## 2017-03-13 Release 0.4.0
|
||||||
|
|
||||||
|
- Replace operatingsystem.rb native fact with executable fact to workaround
|
||||||
|
[https://tickets.puppetlabs.com/browse/FACT-1528](FACT-1528) (ace13)
|
||||||
|
|
||||||
|
## 2016-10-16 Release 0.3.0
|
||||||
|
|
||||||
|
- Add `entropy_repo` type to enable/disable repositories
|
||||||
|
- Add `entropy_repos` fact
|
||||||
|
|
||||||
## 2016-10-13 Release 0.2.0
|
## 2016-10-13 Release 0.2.0
|
||||||
|
|
||||||
- Add `locale` fact
|
- Add `locale` fact
|
||||||
|
|||||||
62
README.md
62
README.md
@@ -1,5 +1,7 @@
|
|||||||
# Sabayon
|
# Sabayon
|
||||||
|
|
||||||
|
[](https://circleci.com/gh/Sabayon/puppet-sabayon)
|
||||||
|
|
||||||
#### Table of Contents
|
#### Table of Contents
|
||||||
|
|
||||||
1. [Description](#description)
|
1. [Description](#description)
|
||||||
@@ -18,7 +20,9 @@ This module extends puppet with support for the Sabayon Linux distribution.
|
|||||||
It adds support for:
|
It adds support for:
|
||||||
* The Entropy package manager
|
* The Entropy package manager
|
||||||
* Managing `Sabayon Community Repository (SCR)` definitions using `enman`
|
* Managing `Sabayon Community Repository (SCR)` definitions using `enman`
|
||||||
|
* Enabling and disabling entropy repositories
|
||||||
* Entropy package masks and unmasks
|
* Entropy package masks and unmasks
|
||||||
|
* Splitdebug installs for packages
|
||||||
* Using systemd as the default service provider
|
* Using systemd as the default service provider
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
@@ -35,6 +39,10 @@ It adds support for:
|
|||||||
This module overrides the default provider for `package` resources to
|
This module overrides the default provider for `package` resources to
|
||||||
force use of `entropy`
|
force use of `entropy`
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
* `sys-apps/lsb-release` is required for the operatingsystem fact to work
|
||||||
|
|
||||||
### Beginning with sabayon
|
### Beginning with sabayon
|
||||||
|
|
||||||
The types and providers within this module can be used without any special
|
The types and providers within this module can be used without any special
|
||||||
@@ -78,12 +86,41 @@ not install 'mysql' since there's no way to disambiguate between
|
|||||||
|
|
||||||
### Managing enman repositories
|
### Managing enman repositories
|
||||||
|
|
||||||
|
Install an available SCR repository using enman. The title is taken to be the
|
||||||
|
repository name by default, and must be available via enman. Use an `ensure`
|
||||||
|
value of `present` to install the repo, and `absent` to remove it.
|
||||||
|
|
||||||
```puppet
|
```puppet
|
||||||
enman_repo { 'community':
|
enman_repo { 'community':
|
||||||
ensure => present,
|
ensure => present,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Enabling and disabling entropy repositories
|
||||||
|
|
||||||
|
Installed repositories (whether system or SCR repositories) can be enabled and
|
||||||
|
disabled using the `entropy_repo` type.
|
||||||
|
|
||||||
|
To enable a repository, use:
|
||||||
|
```puppet
|
||||||
|
entropy_repo { 'sabayon-limbo':
|
||||||
|
enabled => 'true',
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
To disable a repository (only if present), use:
|
||||||
|
```puppet
|
||||||
|
if 'sabayon-limbo' in $facts['entropy_repos'] {
|
||||||
|
entropy_repo { 'sabayon-limbo':
|
||||||
|
enabled => 'false',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This type cannot currently install or remove repositories, only control the
|
||||||
|
enabled state of existing repositories. The repository being managed must
|
||||||
|
already exist on the system.
|
||||||
|
|
||||||
### Masking packages
|
### Masking packages
|
||||||
|
|
||||||
Entropy is very flexible in how to specify which packages can be masked,
|
Entropy is very flexible in how to specify which packages can be masked,
|
||||||
@@ -238,6 +275,7 @@ For more info on package keywords, see https://wiki.gentoo.org/wiki/KEYWORDS
|
|||||||
### Types
|
### Types
|
||||||
|
|
||||||
* `enman_repo`: Manages SCR repositories using enman
|
* `enman_repo`: Manages SCR repositories using enman
|
||||||
|
* `entropy_repo`: Enables/Disables repositories
|
||||||
* `entropy_mask`: Manages entropy package masks
|
* `entropy_mask`: Manages entropy package masks
|
||||||
* `entropy_unmask`: Manages entropy package unmasks
|
* `entropy_unmask`: Manages entropy package unmasks
|
||||||
* `entropy_splitdebug` Manages entropy package debug information
|
* `entropy_splitdebug` Manages entropy package debug information
|
||||||
@@ -245,6 +283,26 @@ For more info on package keywords, see https://wiki.gentoo.org/wiki/KEYWORDS
|
|||||||
|
|
||||||
### Facts
|
### Facts
|
||||||
|
|
||||||
|
#### `entropy_repos`
|
||||||
|
|
||||||
|
Provides a structured fact identifying the entropy repos present on the system
|
||||||
|
including their enabled/disabled state, and whether they are enman or entropy
|
||||||
|
repositories.
|
||||||
|
|
||||||
|
Example (in yaml format for readability):
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
sabayonlinux.org:
|
||||||
|
repo_type: "entropy"
|
||||||
|
enabled: "true"
|
||||||
|
sabayon-limbo:
|
||||||
|
repo_type: "entropy"
|
||||||
|
enabled: "false"
|
||||||
|
community:
|
||||||
|
repo_type: "enman"
|
||||||
|
enabled: "true"
|
||||||
|
```
|
||||||
|
|
||||||
#### `locale`
|
#### `locale`
|
||||||
|
|
||||||
Identifies the system-wide default locale, as set by `eselect`.
|
Identifies the system-wide default locale, as set by `eselect`.
|
||||||
@@ -267,3 +325,7 @@ best-efforts basis.
|
|||||||
|
|
||||||
Pull requests welcome!
|
Pull requests welcome!
|
||||||
|
|
||||||
|
## Contributors
|
||||||
|
|
||||||
|
* [https://github.com/ace13](ace13)
|
||||||
|
|
||||||
|
|||||||
3
circle.yml
Normal file
3
circle.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
test:
|
||||||
|
override:
|
||||||
|
- bundle exec rake test
|
||||||
5
facts.d/sabayon.sh
Executable file
5
facts.d/sabayon.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ -f /etc/sabayon-release ]; then
|
||||||
|
echo "operatingsystem=Sabayon"
|
||||||
|
fi
|
||||||
22
lib/facter/entropy_repos.rb
Normal file
22
lib/facter/entropy_repos.rb
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
Facter.add('entropy_repos') do
|
||||||
|
|
||||||
|
confine :operatingsystem => :Sabayon
|
||||||
|
|
||||||
|
setcode do
|
||||||
|
# Use the types/providers to do the heavy lifting here
|
||||||
|
repos = {}
|
||||||
|
|
||||||
|
Puppet::Type.type(:entropy_repo).provider(:file).instances().each do |repo|
|
||||||
|
Facter.debug(repo.enabled)
|
||||||
|
r = {
|
||||||
|
:repo_type => repo.repo_type,
|
||||||
|
:enabled => repo.enabled,
|
||||||
|
}
|
||||||
|
|
||||||
|
repos[repo.name] = r
|
||||||
|
end
|
||||||
|
|
||||||
|
repos
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
Facter.add(:operatingsystem) do
|
|
||||||
# Sabayon Linux is a variant of Gentoo so this resolution needs to come
|
|
||||||
# before the Gentoo resolution.
|
|
||||||
has_weight(100)
|
|
||||||
confine :kernel => :linux
|
|
||||||
|
|
||||||
setcode do
|
|
||||||
distid = Facter.value(:lsbdistid)
|
|
||||||
if distid == "Sabayon"
|
|
||||||
'Sabayon'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
74
lib/puppet/provider/entropy_repo/file.rb
Normal file
74
lib/puppet/provider/entropy_repo/file.rb
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
Puppet::Type.type(:entropy_repo).provide(:file) do
|
||||||
|
desc "File provider for Entropy Repositories"
|
||||||
|
|
||||||
|
defaultfor :operatingsystem => :sabayon
|
||||||
|
|
||||||
|
mk_resource_methods
|
||||||
|
|
||||||
|
def type_prefix
|
||||||
|
if @property_hash[:repo_type] == 'enman'
|
||||||
|
'enman_'
|
||||||
|
else
|
||||||
|
''
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def enabled=(value)
|
||||||
|
enabled_filename = "/etc/entropy/repositories.conf.d/entropy_#{type_prefix}#{@property_hash[:name]}"
|
||||||
|
disabled_filename = "/etc/entropy/repositories.conf.d/_entropy_#{type_prefix}#{@property_hash[:name]}"
|
||||||
|
|
||||||
|
if value == 'true' || value == :true
|
||||||
|
if File.exists?(disabled_filename)
|
||||||
|
File.rename(disabled_filename, enabled_filename)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if File.exists?(enabled_filename)
|
||||||
|
File.rename(enabled_filename, disabled_filename)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@property_hash[:enabled] = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.instances
|
||||||
|
repos = Dir.entries('/etc/entropy/repositories.conf.d/')
|
||||||
|
|
||||||
|
repos.collect do |r|
|
||||||
|
if r == '.' || r == '..'
|
||||||
|
nil
|
||||||
|
elsif r =~ /\.example$/
|
||||||
|
nil
|
||||||
|
elsif r !~ /^_?entropy_/
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
matches = /^(_)?entropy_(enman_)?(.*)$/.match(r)
|
||||||
|
enabled = matches[1].nil? ? 'true' : 'false'
|
||||||
|
type = matches[2] == 'enman_' ? 'enman' : 'entropy'
|
||||||
|
name = matches[3]
|
||||||
|
|
||||||
|
repo = {
|
||||||
|
:name => name,
|
||||||
|
:repo_type => type,
|
||||||
|
:enabled => enabled,
|
||||||
|
:provider => :entropy_repo,
|
||||||
|
}
|
||||||
|
|
||||||
|
new(repo)
|
||||||
|
end
|
||||||
|
end.compact
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.prefetch(resources)
|
||||||
|
repos = self.instances()
|
||||||
|
|
||||||
|
resources.each do |name, resource|
|
||||||
|
if provider = repos.find { |r| r.name == name }
|
||||||
|
resources[name].provider = provider
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# vim: set ts=2 shiftwidth=2 expandtab :
|
||||||
|
|
||||||
22
lib/puppet/type/entropy_repo.rb
Normal file
22
lib/puppet/type/entropy_repo.rb
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
require 'puppet/property/boolean'
|
||||||
|
|
||||||
|
Puppet::Type.newtype(:entropy_repo) do
|
||||||
|
@desc = "Manages Entropy Repositories"
|
||||||
|
|
||||||
|
newparam(:name) do
|
||||||
|
desc "Name of the Entropy Repository"
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:repo_type, :readonly => true) do
|
||||||
|
desc "What type of repository this is (enman or entropy)"
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:enabled) do
|
||||||
|
desc "Whether the repository is enabled or not"
|
||||||
|
newvalues('true', 'false')
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# vim: set ts=2 shiftwidth=2 expandtab :
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "optiz0r-sabayon",
|
"name": "optiz0r-sabayon",
|
||||||
"version": "0.2.0",
|
"version": "0.4.0",
|
||||||
"author": "Ben Roberts",
|
"author": "Ben Roberts",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"summary": "Extends Puppet with support for the Sabayon Linux distribution",
|
"summary": "Extends Puppet with support for the Sabayon Linux distribution",
|
||||||
|
|||||||
61
spec/unit/provider/entropy_repo/file_spec.rb
Normal file
61
spec/unit/provider/entropy_repo/file_spec.rb
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Puppet::Type.type(:entropy_repo).provider(:file) do
|
||||||
|
describe 'when fetching existing resources' do
|
||||||
|
let(:instances) do
|
||||||
|
described_class.instances
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:repos) do
|
||||||
|
[
|
||||||
|
{:name => 'sabayonlinux.org', :type => 'entropy', :enabled => 'true'},
|
||||||
|
{:name => 'sabayon-limbo', :type => 'entropy', :enabled => 'false'},
|
||||||
|
{:name => 'community', :type => 'enman', :enabled => 'true'},
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
Dir.stubs(:entries).with('/etc/entropy/repositories.conf.d/').returns([
|
||||||
|
'.', '..', 'README',
|
||||||
|
'entropy_sabayonlinux.org',
|
||||||
|
'_entropy_sabayon-limbo',
|
||||||
|
'entropy_enman_community',
|
||||||
|
'entropy_foobar.example',
|
||||||
|
])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should identify the correct number of repos' do
|
||||||
|
expect(instances.size).to eq(repos.size)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should identify the correct repo name' do
|
||||||
|
repos.each_with_index do |repo, index|
|
||||||
|
expect(instances[index].name).to eq(repo[:name])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should identify the correct enabled state' do
|
||||||
|
repos.each_with_index do |repo, index|
|
||||||
|
expect(instances[index].enabled).to eq(repo[:enabled])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'when enabling a repository' do
|
||||||
|
it 'should enable a disabled repository' do
|
||||||
|
File.stubs(:exists?).with('/etc/entropy/repositories.conf.d/entropy_sabayonlinux.org').returns(true).once
|
||||||
|
File.stubs(:rename).with('/etc/entropy/repositories.conf.d/entropy_sabayonlinux.org', '/etc/entropy/repositories.conf.d/_entropy_sabayonlinux.org').once
|
||||||
|
instance = described_class.new(:name => 'sabayonlinux.org', :enabled => 'true', :type => 'entropy')
|
||||||
|
instance.enabled = 'false'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'when disabling a repository' do
|
||||||
|
it 'should disable an enabled repository' do
|
||||||
|
File.stubs(:exists?).with('/etc/entropy/repositories.conf.d/_entropy_sabayon-limbo').returns(true).once
|
||||||
|
File.stubs(:rename).with('/etc/entropy/repositories.conf.d/_entropy_sabayon-limbo', '/etc/entropy/repositories.conf.d/entropy_sabayon-limbo').once
|
||||||
|
instance = described_class.new(:name => 'sabayon-limbo', :enabled => 'false', :type => 'entropy')
|
||||||
|
instance.enabled = 'true'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
32
spec/unit/type/entropy_repo_spec.rb
Normal file
32
spec/unit/type/entropy_repo_spec.rb
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
describe Puppet::Type.type(:entropy_repo) do
|
||||||
|
before do
|
||||||
|
@provider = stub 'provider'
|
||||||
|
@provider.stubs(:name).returns(:file)
|
||||||
|
described_class.stubs(:defaultprovider).returns(@provider)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should be an instance of Puppet::Type::Entropy_repo" do
|
||||||
|
expect(described_class.new(:name => "test")).to be_an_instance_of Puppet::Type::Entropy_repo
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when validating attributes" do
|
||||||
|
params = [:name]
|
||||||
|
properties = [:repo_type, :enabled]
|
||||||
|
|
||||||
|
params.each do |param|
|
||||||
|
it "should have the #{param} param" do
|
||||||
|
expect(described_class.attrtype(param)).to eq :param
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
properties.each do |property|
|
||||||
|
it "should have the #{property} property" do
|
||||||
|
expect(described_class.attrtype(property)).to eq :property
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should have name as the namevar" do
|
||||||
|
expect(described_class.key_attributes).to eq [:name]
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user