fa756d692abdd30d677e50b6bfbdd5f346b258b3
[mirror/dsa-puppet.git] / modules / roles / manifests / static_base.pp
1 class roles::static_base {
2         if ! $::staticsync_key {
3                 exec { 'create-staticsync-key':
4                         command => '/bin/su - staticsync -c \'mkdir -p -m 02700 .ssh && ssh-keygen -C "`whoami`@`hostname` (`date +%Y-%m-%d`)" -P "" -f .ssh/id_rsa -q\'',
5                         onlyif  => '/usr/bin/getent passwd staticsync > /dev/null && ! [ -e /home/staticsync/.ssh/id_rsa ]'
6                 }
7         }
8
9         file { '/etc/static-components.conf':
10                 content => template('roles/static-mirroring/static-components.conf.erb'),
11         }
12
13         file { '/etc/ssh/userkeys/staticsync':
14                 content => template('roles/static-mirroring/staticsync-authorized_keys.erb'),
15         }
16
17         file { '/usr/local/bin/staticsync-ssh-wrap':
18                 source => 'puppet:///modules/roles/static-mirroring/staticsync-ssh-wrap',
19                 mode   => '0555',
20         }
21
22         file { '/usr/local/bin/static-update-component':
23                 source => 'puppet:///modules/roles/static-mirroring/static-update-component',
24                 mode    => '0555',
25         }
26
27         file { '/usr/local/bin/static-mirror-ssh-wrap': ensure => absent; }
28         file { '/usr/local/bin/static-master-ssh-wrap': ensure => absent; }
29
30         @ferm::rule { 'dsa-static-bt-v4':
31                 description => 'Allow bt between static hosts',
32                 rule        => 'proto tcp mod state state (NEW) mod multiport destination-ports (6881:6999) @subchain \'static-bt\' { saddr ($HOST_STATIC_V4) ACCEPT; }',
33                 notarule    => true,
34         }
35         @ferm::rule { 'dsa-static-bt-v6':
36                 description => 'Allow bt between static hosts',
37                 domain      => 'ip6',
38                 rule        => 'proto tcp mod state state (NEW) mod multiport destination-ports (6881:6999) @subchain \'static-bt\' { saddr ($HOST_STATIC_V6) ACCEPT; }',
39                 notarule    => true,
40         }
41
42         file { "/etc/staticsync.conf":
43                 content  => @("EOF"),
44                                 # This file is sourced by bash
45                                 # and parsed by python
46                                 #  - empty lines and lines starting with a # are ignored.
47                                 #  - other lines are key=value.  No extra spaces anywhere.  No quoting.
48                                 base=/srv/static.debian.org
49                                 masterbase=/home/staticsync/static-master/master
50                                 staticuser=staticsync
51                                 | EOF
52         }
53 }