Added support for enabling/removing avahi services.
This commit is contained in:
parent
5cb6ed6ce6
commit
9edbc6ae12
2 changed files with 61 additions and 0 deletions
|
@ -19,3 +19,48 @@ class avahi::daemon {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Modify avahi service.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# $name:
|
||||
# Service name
|
||||
# $description:
|
||||
# Description of service. Defaults to local hostname.
|
||||
# $port:
|
||||
# Port which service listens on.
|
||||
# $type:
|
||||
# Service type for this service. e.g. "_http._tcp".
|
||||
# $txt:
|
||||
# Array containing TXT record data.
|
||||
# $ensure:
|
||||
# If set to present service will be created and if set to absent
|
||||
# service will be removed.
|
||||
#
|
||||
# === Sample usage
|
||||
#
|
||||
# avahi::service { "ssh":
|
||||
# ensure => present,
|
||||
# port => 22,
|
||||
# type => "_ssh._tcp",
|
||||
# }
|
||||
#
|
||||
define avahi::service($type, $port, $description = "%h", $ensure = "present", $txt = []) {
|
||||
|
||||
$srvtype = $type
|
||||
|
||||
file { "/etc/avahi/services/${name}.service":
|
||||
ensure => $ensure,
|
||||
content => template("avahi/service.erb"),
|
||||
mode => 0644,
|
||||
owner => root,
|
||||
group => $operatingsystem ? {
|
||||
openbsd => wheel,
|
||||
default => root,
|
||||
},
|
||||
notify => Service["avahi-daemon"],
|
||||
}
|
||||
|
||||
}
|
||||
|
|
16
avahi/templates/service.erb
Normal file
16
avahi/templates/service.erb
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" standalone="no" ?>
|
||||
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
|
||||
|
||||
<service-group>
|
||||
|
||||
<name replace-wildcards="yes"><%= description %></name>
|
||||
|
||||
<service>
|
||||
<type><%= srvtype %></type>
|
||||
<port><%= port %></port>
|
||||
<% txt.each do |val| -%>
|
||||
<txt-record><%= val %></txt-record>
|
||||
<% end -%>
|
||||
</service>
|
||||
|
||||
</service-group>
|
Loading…
Add table
Reference in a new issue