Skip to content

Commit

Permalink
Merge af5c64b into fee3ac8
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidS committed Mar 27, 2016
2 parents fee3ac8 + af5c64b commit c472589
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
13 changes: 13 additions & 0 deletions README.md
Expand Up @@ -282,6 +282,19 @@ If, for whatever reason, you don't want to automatically manage a repository for
}


### Custom Dependencies

In rare cases it might be necessary to have a relationship in between the parts of a `tp::install`. To allow this, the main package and service resource are available under the name of the application:

```
tp::install { exim: }
Package[exim] -> Exec['extra setup script'] ~> Service[exim]
```

This works even if, like in this case, the package and service names vary widely across distributions.


## Usage with Hiera

You may find useful the ```create_resources``` defines that are feed, in the main ```tp``` class by special ```hiera_hash``` lookups that map all the available ```tp``` defines to hiera keys in this format ```tp::<define>_hash```.
Expand Down
32 changes: 25 additions & 7 deletions manifests/install.pp
Expand Up @@ -106,7 +106,7 @@
if $settings[package_name] == Variant[Undef,String[0]] {
$service_require = undef
} else {
$service_require = Package[$settings[package_name]]
$service_require = Package[$name]
}

$service_ensure = $ensure ? {
Expand Down Expand Up @@ -139,19 +139,37 @@
if $settings[package_name] {
$packages_array=any2array($settings[package_name])
$packages_array.each |$pkg| {
package { $pkg:
ensure => $ensure,
# Setup a stable alias to the application's name for the "main" package
if $pkg != $name and (size($packages_array) == 1 or $svc == $settings[main_package]) {
package { $name:
name => $pkg,
ensure => $ensure,
}
} else {
package { $pkg:
ensure => $ensure,
}
}
}
}

if $settings[service_name] {
$services_array=any2array($settings[service_name])
$services_array.each |$svc| {
service { $svc:
ensure => $service_ensure,
enable => $service_enable,
require => $service_require,
# Setup a stable alias to the application's name for the "main" service
if $svc != $name and (size($services_array) == 1 or $svc == $settings[main_service]) {
service { $name:
name => $svc,
ensure => $service_ensure,
enable => $service_enable,
require => $service_require,
}
} else {
service { $svc:
ensure => $service_ensure,
enable => $service_enable,
require => $service_require,
}
}
}
}
Expand Down

0 comments on commit c472589

Please sign in to comment.