aboutsummaryrefslogtreecommitdiff
path: root/manifests/daemon/base.pp
blob: 63d7bc4dcee50a33567aa728b304420a16e7d225 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# extend basic tor things with a snippet based daemon configuration
class tor::daemon::base inherits tor::base {
  # packages, user, group
  Service['tor'] {
    subscribe => File[$tor::daemon::config_file],
  }

  Package[ 'tor' ] {
    require => File[$tor::daemon::data_dir],
  }

  group { 'debian-tor':
    ensure    => present,
    allowdupe => false,
  }

  user { 'debian-tor':
    ensure    => present,
    allowdupe => false,
    comment   => 'tor user,,,',
    home      => $tor::daemon::data_dir,
    shell     => '/bin/false',
    gid       => 'debian-tor',
    require   => Group['debian-tor'],
  }

  # directories
  file { $tor::daemon::data_dir:
    ensure  => directory,
    mode    => '0700',
    owner   => 'debian-tor',
    group   => 'debian-tor',
    require => User['debian-tor'],
  }

  file { '/etc/tor':
    ensure  => directory,
    mode    => '0755',
    owner   => 'debian-tor',
    group   => 'debian-tor',
    require => User['debian-tor'],
  }

  file { '/var/lib/puppet/modules/tor':
    ensure  => absent,
    recurse => true,
    force   => true,
  }

  # tor configuration file
  concat { $tor::daemon::config_file:
    mode   => '0600',
    owner  => 'debian-tor',
    group  => 'debian-tor',
  }

  # config file headers
  concat::fragment { '00.header':
    ensure  => present,
    content => template('tor/torrc.header.erb'),
    owner   => 'debian-tor',
    group   => 'debian-tor',
    mode    => '0644',
    order   => 00,
    target  => $tor::daemon::config_file,
  }

  # global configurations
  concat::fragment { '01.global':
    content => template('tor/torrc.global.erb'),
    owner   => 'debian-tor',
    group   => 'debian-tor',
    mode    => '0644',
    order   => 01,
    target  => $tor::daemon::config_file,
  }
}