Integrated type parameter into name for avahi::service definition.
This commit is contained in:
parent
78d29ea44f
commit
079b9c6210
2 changed files with 11 additions and 13 deletions
|
@ -26,13 +26,12 @@ class avahi::daemon {
|
|||
# === Parameters
|
||||
#
|
||||
# $name:
|
||||
# Service name
|
||||
# Service type. e.g. "_http._tcp".
|
||||
# $description:
|
||||
# Description of service. Defaults to local hostname.
|
||||
# $port:
|
||||
# Port which service listens on.
|
||||
# $type:
|
||||
# Service type for this service. e.g. "_http._tcp".
|
||||
# Port which service listens on. Defaults to port found from
|
||||
# /etc/services.
|
||||
# $txt:
|
||||
# Array containing TXT record data.
|
||||
# $ensure:
|
||||
|
@ -41,22 +40,21 @@ class avahi::daemon {
|
|||
#
|
||||
# === Sample usage
|
||||
#
|
||||
# avahi::service { "ssh":
|
||||
# avahi::service { "_ssh._tcp":
|
||||
# ensure => present,
|
||||
# port => 22,
|
||||
# type => "_ssh._tcp",
|
||||
# }
|
||||
#
|
||||
define avahi::service($type, $port = "AUTO", $description = "%h", $ensure = "present", $txt = []) {
|
||||
define avahi::service($port = "AUTO", $description = "%h", $ensure = "present", $txt = []) {
|
||||
|
||||
$filename = regsubst($name, '^_([^.]+)\._.*', '\1.service')
|
||||
|
||||
$srvtype = $type
|
||||
if $port == "AUTO" {
|
||||
$realport = avahi_service_port($srvtype)
|
||||
$realport = avahi_service_port($name)
|
||||
} else {
|
||||
$realport = $port
|
||||
}
|
||||
|
||||
file { "/etc/avahi/services/${name}.service":
|
||||
file { "/etc/avahi/services/${filename}":
|
||||
ensure => $ensure,
|
||||
content => template("avahi/service.erb"),
|
||||
mode => 0644,
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<name replace-wildcards="yes"><%= description %></name>
|
||||
|
||||
<service>
|
||||
<type><%= srvtype %></type>
|
||||
<port><%= port %></port>
|
||||
<type><%= name %></type>
|
||||
<port><%= realport %></port>
|
||||
<% txt.each do |val| -%>
|
||||
<txt-record><%= val %></txt-record>
|
||||
<% end -%>
|
||||
|
|
Loading…
Add table
Reference in a new issue