aboutsummaryrefslogtreecommitdiff
path: root/manifests/composer.pp
blob: 3f51ecd8ecf815f5cd314868f102491c62c170de (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
class php::composer(
  $provider = 'upstream',
) {
  package { 'composer':
    ensure => $provider ? {
      'package' => present,
      default   => absent,
    },
  }

  file { '/usr/local/bin/getcomposer':
    ensure => present,
    owner  => root,
    group  => root,
    mode   => '0755',
    source => 'puppet:///modules/php/getcomposer',
  }

  if ($provider == 'package') {
    file { '/usr/local/bin/composer':
      ensure => absent,
    }
  }

  cron { "composer-self-update":
    command  => "/usr/local/bin/composer self-update > /dev/null 2>&1",
    user     => root,
    hour     => "03",
    minute   => "30",
    ensure   => $provider ? {
      'upstream' => present,
      default    => absent,
    },
    require  => Exec['getcomposer'],
  }

  if ($provider == 'upstream') {
    exec { 'getcomposer':
      # 'The HOME or COMPOSER_HOME environment variable must be set for composer to install correctly'
      environment => [ 'HOME=/root' ],
      #command     => '/usr/bin/wget -O - https://getcomposer.org/installer | /usr/bin/php && /bin/mv composer.phar /usr/local/bin/composer',
      command     => '/usr/local/bin/getcomposer',
      user        => 'root',
      cwd         => '/tmp',
      creates     => '/usr/local/bin/composer',
      require     => File['/usr/local/bin/getcomposer'],
    }
  }
}