aboutsummaryrefslogtreecommitdiff
path: root/manifests/init.pp
blob: 11a58f0d5d9d8da5b929b52e0bde1685a098e366 (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
class drupal(
  $folder       = hiera('drupal::folder',       '/var/www/data/drupal'),
  $sites_folder = hiera('drupal::sites_folder', '/var/sites'),
  $www_folder   = hiera('drupal::www_folder',   '/var/www/data')
) {
  # We use drupal source from upstream 
  package { [ "drupal6", "drush" ]:
    ensure => absent,
  }

  # Needed packages
  package { [ "php5-gd", "php5-imagick" ]:
    ensure => installed,
  }

  # Drush config folder
  file { '/etc/drush':
    ensure => directory,
    owner  => root,
    group  => root,
    mode   => 0644,
  }

  # Drush default configuration
  file { '/etc/drush/drushrc.php':
    ensure  => present,
    owner   => root,
    group   => root,
    mode    => 0644,
    source  => 'puppet:///modules/drupal/drushrc.php',
    require => File['/etc/drush'],
  }

  # Drupal management script
  file { "/usr/local/sbin/drupal":
    ensure  => present,
    content => template('drupal/drupal.sh.erb'),
    owner   => root,
    group   => root,
    mode    => 755,
  }

  # Run drupal cron
  cron { "drupal-cron":
    command  => "/usr/local/sbin/drupal cron &> /dev/null",
    user     => root,
    hour     => "*/1",
    minute   => "15",
    ensure   => present,
    require  => File['/usr/local/sbin/drupal'],
  }

  # Keep themes and modules up-to-date
  cron { "drupal-update":
    command  => "/usr/local/sbin/drupal cron-update",
    user     => root,
    # Run once a week after security releases (usually on Wednesdays)
    weekday  => 5,
    hour     => "02",
    minute   => "30",
    ensure   => present,
  }

  cron { "drupal-make-6":
    command  => "/usr/local/sbin/drupal make 6",
    user     => root,
    # Run once a week to ensure the server has all dependencies
    weekday  => 4,
    hour     => "02",
    minute   => "30",
    ensure   => present,
    require  => File['/usr/local/sbin/drupal',
                     '/usr/local/share/drupal/drupal6.make',
                     '/usr/local/share/drupal/themes6.make'],
  }

  cron { "drupal-make-7":
    command  => "/usr/local/sbin/drupal make 7",
    user     => root,
    # Run once a week to ensure the server has all dependencies
    weekday  => 4,
    hour     => "02",
    minute   => "30",
    ensure   => present,
    require  => File['/usr/local/sbin/drupal',
                     '/usr/local/share/drupal/drupal7.make',
                     '/usr/local/share/drupal/themes7.make'],
  }

  # Drupal shared folder
  file { "/usr/local/share/drupal":
    ensure  => directory,
    owner   => root,
    group   => root,
    mode    => 755,
  }

  # Drupal 6 makefile
  file { "/usr/local/share/drupal/drupal6.make":
    ensure  => present,
    owner   => root,
    group   => root,
    mode    => 644,
    source  => "puppet:///modules/drupal/drupal6.make",
    require => File['/usr/local/share/drupal'],
  }

  # Drupal 7 makefile
  file { "/usr/local/share/drupal/drupal7.make":
    ensure  => present,
    owner   => root,
    group   => root,
    mode    => 644,
    source  => "puppet:///modules/drupal/drupal7.make",
    require => File['/usr/local/share/drupal'],
  }

  # Drupal 6 theme makefile
  file { "/usr/local/share/drupal/themes6.make":
    ensure  => present,
    owner   => root,
    group   => root,
    mode    => 644,
    source  => "puppet:///modules/drupal/themes6.make",
    require => File['/usr/local/share/drupal'],
  }

  # Drupal 7 theme makefile
  file { "/usr/local/share/drupal/themes7.make":
    ensure  => present,
    owner   => root,
    group   => root,
    mode    => 644,
    source  => "puppet:///modules/drupal/themes7.make",
    require => File['/usr/local/share/drupal'],
  }

  # See https://drupal.org/SA-CORE-2013-003
  file { "/tmp/.htaccess":
    ensure  => present,
    owner   => root,
    group   => root,
    mode    => 644,
    source  => "puppet:///modules/drupal/htaccess",
  }

  file { [ '/var/www/data/drupal-6/backup', '/var/www/data/drupal-7/backup' ]:
    ensure  => absent,
    recurse => true,
    force   => true,
    backup  => false,
  }

  # Composer
  exec { 'getcomposer':
    command => '/usr/bin/curl -sS https://getcomposer.org/installer | /usr/bin/php && /bin/mv composer.phar /usr/local/bin/composer',
    user    => 'root',
    cwd     => '/tmp',
    creates => '/usr/local/bin/composer',
  }

  #vcsrepo { "/usr/local/share/drush":
  #  ensure   => present,
  #  provider => git,
  #  source   => 'https://github.com/drush-ops/drush',
  #  revision => '401f034c59b031221d900bec7c2ba81d1331c284',
  #  owner    => 'root',
  #  group    => 'root',
  #}

  #file { "/usr/local/bin/drush":
  #  ensure  => '/usr/local/share/drush/drush',
  #  owner   => root,
  #  group   => root,
  #  require => [ Vcsrepo['/usr/local/share/drush'], Exec['getcomposer'] ],
  #}

  #exec { 'composer-drush':
  #  command     => '/usr/local/bin/composer global require drush/drush:dev-master',
  #  user        => 'vagrant',
  #  creates     => '/home/vagrant/composer/vendor/bin/drush',
  #  environment => [ 'COMPOSER_HOME="/vagrant"' ],
  #  require     => Exec['getcomposer'],
  #}

  exec { 'getdrush':
    command => '/usr/bin/wget https://github.com/drush-ops/drush/releases/download/8.0.0/drush.phar -O /usr/local/bin/drush && chmod +x /usr/local/bin/drush',
    user    => 'root',
    cwd     => '/tmp',
    creates => '/usr/local/bin/drush',
  }
}