mirror of
https://gh.wpcy.net/https://github.com/Chassis/puppet-wp.git
synced 2026-05-05 17:30:44 +08:00
62 lines
1.3 KiB
Puppet
Executable file
62 lines
1.3 KiB
Puppet
Executable file
# A class to install WP-CLI.
|
|
class wp::cli (
|
|
$ensure = 'installed',
|
|
$install_path = '/usr/local/src/wp-cli',
|
|
$version = 'dev-master'
|
|
) {
|
|
include wp
|
|
|
|
if 'installed' == $ensure or 'present' == $ensure {
|
|
# Create the install path
|
|
file { [ $install_path, "${install_path}/bin" ]:
|
|
ensure => directory,
|
|
}
|
|
|
|
# Clone the Git repo
|
|
exec { 'wp-cli download':
|
|
command => "/usr/bin/curl -o $install_path/bin/wp -L https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar",
|
|
require => [ Package[ 'curl' ], File[ $install_path ] ],
|
|
creates => "${install_path}/bin/wp"
|
|
}
|
|
|
|
# Ensure we can run wp-cli
|
|
file { "${install_path}/bin/wp":
|
|
ensure => 'present',
|
|
mode => 'a+x',
|
|
require => Exec[ 'wp-cli download' ]
|
|
}
|
|
|
|
# Symlink it across
|
|
file { '/usr/bin/wp':
|
|
ensure => link,
|
|
target => "${install_path}/bin/wp",
|
|
require => File[ "${install_path}/bin/wp" ],
|
|
}
|
|
}
|
|
elsif 'absent' == $ensure {
|
|
file { '/usr/bin/wp':
|
|
ensure => absent,
|
|
}
|
|
file { '/usr/local/src/wp-cli':
|
|
ensure => absent,
|
|
}
|
|
}
|
|
|
|
if ! defined( Package[ $::wp::php_package ] ) {
|
|
package { $::wp::php_package:
|
|
ensure => installed,
|
|
}
|
|
}
|
|
|
|
if ! defined(Package['curl']) {
|
|
package { 'curl':
|
|
ensure => installed,
|
|
}
|
|
}
|
|
|
|
if ! defined(Package['git']) {
|
|
package { 'git':
|
|
ensure => installed,
|
|
}
|
|
}
|
|
}
|