aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-10-28 09:36:38 -0200
committerSilvio Rhatto <rhatto@riseup.net>2017-10-28 09:36:38 -0200
commitf9fbad5598b616c7bb89d0c36c64567d8db75531 (patch)
tree86bf1083fcd5f4d59a268a2cb613b6e012d86ad2
parent6120cc7b7646856ee6bd79a8ae7fcf067c1bc69c (diff)
downloadpuppet-php-f9fbad5598b616c7bb89d0c36c64567d8db75531.tar.gz
puppet-php-f9fbad5598b616c7bb89d0c36c64567d8db75531.tar.bz2
Up-to-date composer handling by package or upstream version
-rwxr-xr-xfiles/getcomposer16
-rw-r--r--manifests/composer.pp55
2 files changed, 60 insertions, 11 deletions
diff --git a/files/getcomposer b/files/getcomposer
new file mode 100755
index 0000000..8625042
--- /dev/null
+++ b/files/getcomposer
@@ -0,0 +1,16 @@
+#!/usr/bin/env sh
+#
+# See https://getcomposer.org/download/
+#
+
+# Download
+#php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
+wget https://getcomposer.org/installer -O composer-setup.php || exit 1
+
+php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
+
+if [ -e "composer-setup.php" ]; then
+ php composer-setup.php --install-dir=/usr/local/bin --filename=composer
+ #php -r "unlink('composer-setup.php');"
+ rm composer-setup.php
+fi
diff --git a/manifests/composer.pp b/manifests/composer.pp
index 4ab3337..b6274f6 100644
--- a/manifests/composer.pp
+++ b/manifests/composer.pp
@@ -1,16 +1,49 @@
-class php::composer {
- # TODO: future
+class php::composer(
+ $provider = 'upstream',
+) {
package { 'composer':
- ensure => absent,
+ ensure => $provider ? {
+ 'package' => present,
+ default => absent,
+ },
}
- # Composer
- 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',
- user => 'root',
- cwd => '/tmp',
- creates => '/usr/local/bin/composer',
+ 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",
+ 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'],
+ }
}
}