dev/provisioning/modules/drush/manifests/install.pp
changeset 353 bf1bc6b08c46
equal deleted inserted replaced
352:d8a8c57f36c4 353:bf1bc6b08c46
       
     1 # == Defined type: drush::install
       
     2 #
       
     3 # Installs a Drush version with the given method.
       
     4 #
       
     5 # === Parameters
       
     6 #
       
     7 # [*version*]
       
     8 #   Drush release to install. Example: 7, 6.6, master.
       
     9 #
       
    10 # [*install_type*]
       
    11 #   Install distribution package or source code.
       
    12 #   Valid values: 'dist', 'source'. Defaults to 'dist'.
       
    13 #
       
    14 # [*autoupdate*]
       
    15 #   Try and install new versions automatically. Defaults to false.
       
    16 #
       
    17 # [*method*]
       
    18 #   Installation method. It only accepts composer at present.
       
    19 #
       
    20 define drush::install(
       
    21   $version,
       
    22   $install_type = 'dist',
       
    23   $autoupdate   = false,
       
    24   $method       = 'composer',
       
    25 ) {
       
    26 
       
    27   $install_types = [ 'dist', 'source' ]
       
    28   if ! ($install_type in $install_types) {
       
    29     fail("'${install_type}' is not a valid value for creation_mode. Valid values: ${install_types}.")
       
    30   }
       
    31 
       
    32 
       
    33   # Pick major version.
       
    34   $parts = split($version, '[.]')
       
    35   $version_major = $parts[0]
       
    36 
       
    37   $drush        = "drush${version_major}"
       
    38   $drush_exe    = "/usr/local/bin/${drush}"
       
    39   $install_path = "${drush::install_base_path}/${version_major}"
       
    40 
       
    41   case $method {
       
    42     'composer': {
       
    43       drush::install::composer { $drush:
       
    44         autoupdate   => $autoupdate,
       
    45         version      => $version,
       
    46         install_path => $install_path,
       
    47         install_type => $install_type,
       
    48         notify       => Exec["${drush}-first-run"],
       
    49       }
       
    50       file { $drush_exe:
       
    51         ensure  => link,
       
    52         target  => "${install_path}/vendor/bin/drush",
       
    53         require => Drush::Install::Composer[$drush],
       
    54       }
       
    55     }
       
    56     default: {
       
    57       fail("Unknown install method: '${method}'.")
       
    58     }
       
    59   }
       
    60 
       
    61   exec { "${drush}-first-run":
       
    62     command     => "/usr/bin/su - -c '${drush_exe} status'",
       
    63     require     => File[$drush_exe],
       
    64     refreshonly => true,
       
    65   }
       
    66 
       
    67 }
       
    68