]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/portforwarder/templates/xinetd.erb
Update comment
[dsa-puppet.git] / modules / portforwarder / templates / xinetd.erb
1 <%=
2 lines = []
3
4 template = 'service @@TARGET_HOST@@@@TARGET_PORT@@
5 {
6         protocol        = tcp
7         port            = @@LOCAL_BIND@@
8         type            = UNLISTED
9
10         bind            = 127.0.0.1
11         socket_type     = stream
12         wait            = no
13         user            = portforwarder
14         group           = portforwarder
15         instances       = 10
16         server          = /usr/bin/ssh
17         server_args     = -o PreferredAuthentications=publickey -o EscapeChar=none -C @@TARGET_HOST@@ : nothing
18         cps             = 0 0
19 }
20 '
21
22 config = YAML.load(File.open('/etc/puppet/modules/portforwarder/misc/config.yaml').read)
23 if config[fqdn]
24         config[fqdn].each do |service|
25                 target_port = service['target_port']
26                 target_host = service['target_host']
27                 local_bind = service['source_bind_port']
28
29                 lines << "# to #{target_port}:target_host from local port #{local_bind}"
30                 if target_port.nil? or target_host.nil? or local_bind.nil?
31                         lines << "# insufficient config values"
32                 else
33                         p = template.clone
34                         p.gsub!('@@TARGET_HOST@@', target_host)
35                         p.gsub!('@@TARGET_PORT@@', target_port)
36                         p.gsub!('@@LOCLA_BIND@@', local_bind)
37                         lines << p
38                 end
39         end
40 end
41 lines.join("\n")
42 %>