summaryrefslogtreecommitdiff
path: root/puppet/modules/obfsproxy/manifests/init.pp
blob: 5c78560aca4b0472f2eda7d6a8264137f1db4d67 (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
78
79
80
81
82
83
84
85
class obfsproxy (
  $transport,
  $bind_address,
  $port,
  $param,
  $dest_ip,
  $dest_port,
  $log_level = 'info'
){

  $user = 'obfsproxy'
  $conf = '/etc/obfsproxy/obfsproxy.conf'

  user { $user:
    ensure => present,
    system => true,
    gid    => $user,
  }

  group { $user:
    ensure => present,
    system => true,
  }

  file { '/etc/init.d/obfsproxy':
    path      => '/etc/init.d/obfsproxy',
    ensure    => present,
    source    => 'puppet:///modules/obfsproxy/obfsproxy_init',
    owner     => 'root',
    group     => 'root',
    mode      => '0750',
    require   => File[$conf],
  }

  file { $conf :
    path    => $conf,
    ensure  => present,
    owner   => 'root',
    group   => 'root',
    mode    => '0600',
    content => template('obfsproxy/etc_conf.erb'),
  }

  file { '/etc/obfsproxy':
    ensure  => directory,
    owner   => $user,
    group   => $user,
    mode    => '0700',
    require => User[$user],
  }

  file { '/var/log/obfsproxy.log':
    ensure  => present,
    owner   => $user,
    group   => $user,
    mode    => '0640',
    require => User[$user],
  }

  file { '/etc/logrotate.d/obfsproxy':
    ensure  => present,
    source  => 'puppet:///modules/obfsproxy/obfsproxy_logrotate',
    owner   => 'root',
    group   => 'root',
    mode    => '0644',
    require => File['/var/log/obfsproxy.log'],
  }

  package { 'obfsproxy':
    ensure  => present
  }

  service { 'obfsproxy':
    ensure    => running,
    subscribe => File[$conf],
    require   => [
      Package['obfsproxy'],
      File['/etc/init.d/obfsproxy'],
      User[$user],
      Group[$user]]
  }


}