Add entropy_repos fact

This commit is contained in:
2016-10-16 13:42:47 +01:00
parent bd1fd54bbb
commit 97c1cc97e6
3 changed files with 48 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
## UNRELEASED
- Add `entropy_repo` type to enable/disable repositories
- Add `entropy_repos` fact
## 2016-10-13 Release 0.2.0

View File

@@ -102,10 +102,12 @@ entropy_repo { 'sabayon-limbo':
}
```
To disable a repository, use:
To disable a repository (only if present), use:
```puppet
entropy_repo { 'sabayon-limbo':
enabled => 'false',
if 'sabayon-limbo' in $facts['entropy_repos'] {
entropy_repo { 'sabayon-limbo':
enabled => 'false',
}
}
```
@@ -275,6 +277,26 @@ For more info on package keywords, see https://wiki.gentoo.org/wiki/KEYWORDS
### 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`
Identifies the system-wide default locale, as set by `eselect`.

View 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