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
|
# === Parameters
|
||||||
#
|
#
|
||||||
# $name:
|
# $name:
|
||||||
# Service name
|
# Service type. e.g. "_http._tcp".
|
||||||
# $description:
|
# $description:
|
||||||
# Description of service. Defaults to local hostname.
|
# Description of service. Defaults to local hostname.
|
||||||
# $port:
|
# $port:
|
||||||
# Port which service listens on.
|
# Port which service listens on. Defaults to port found from
|
||||||
# $type:
|
# /etc/services.
|
||||||
# Service type for this service. e.g. "_http._tcp".
|
|
||||||
# $txt:
|
# $txt:
|
||||||
# Array containing TXT record data.
|
# Array containing TXT record data.
|
||||||
# $ensure:
|
# $ensure:
|
||||||
|
@ -41,22 +40,21 @@ class avahi::daemon {
|
||||||
#
|
#
|
||||||
# === Sample usage
|
# === Sample usage
|
||||||
#
|
#
|
||||||
# avahi::service { "ssh":
|
# avahi::service { "_ssh._tcp":
|
||||||
# ensure => present,
|
# 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 = []) {
|
||||||
|
|
||||||
$srvtype = $type
|
$filename = regsubst($name, '^_([^.]+)\._.*', '\1.service')
|
||||||
|
|
||||||
if $port == "AUTO" {
|
if $port == "AUTO" {
|
||||||
$realport = avahi_service_port($srvtype)
|
$realport = avahi_service_port($name)
|
||||||
} else {
|
} else {
|
||||||
$realport = $port
|
$realport = $port
|
||||||
}
|
}
|
||||||
|
|
||||||
file { "/etc/avahi/services/${name}.service":
|
file { "/etc/avahi/services/${filename}":
|
||||||
ensure => $ensure,
|
ensure => $ensure,
|
||||||
content => template("avahi/service.erb"),
|
content => template("avahi/service.erb"),
|
||||||
mode => 0644,
|
mode => 0644,
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<name replace-wildcards="yes"><%= description %></name>
|
<name replace-wildcards="yes"><%= description %></name>
|
||||||
|
|
||||||
<service>
|
<service>
|
||||||
<type><%= srvtype %></type>
|
<type><%= name %></type>
|
||||||
<port><%= port %></port>
|
<port><%= realport %></port>
|
||||||
<% txt.each do |val| -%>
|
<% txt.each do |val| -%>
|
||||||
<txt-record><%= val %></txt-record>
|
<txt-record><%= val %></txt-record>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
Loading…
Add table
Reference in a new issue