Puppet Class: wp::cli

Inherits:
wp
Defined in:
manifests/cli.pp

Overview

A class to install WP-CLI.

Parameters:

  • ensure (Any) (defaults to: 'installed')
  • install_path (Any) (defaults to: '/usr/local/src/wp-cli')
  • version (Any) (defaults to: 'dev-master')


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
# File 'manifests/cli.pp', line 2

class wp::cli (
	$ensure       = 'installed',
	$install_path = '/usr/local/src/wp-cli',
	$version      = 'dev-master',

) inherits wp {
	if $::osfamily == 'Windows' {
		Package { provider => 'chocolatey' }
	}

	if 'installed' == $ensure or 'present' == $ensure {
		# Create the install path
		file { [ $install_path, "${install_path}/bin" ]:
			ensure => directory,
		}

		archive { 'wp-cli download':
			ensure => present,
			source => 'https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar',
			path   => "${install_path}/bin/wp-cli.phar",
		}

		if $::kernel == 'Linux' {
			file { "${install_path}/bin/${wp::executable_filename}":
				ensure  => 'present',
				content => template('wp/wp.sh.erb'),
				mode    => 'a+x',
				require => Archive[ 'wp-cli download' ]
			}

			# Symlink it across
			file { "${wp::bin_path}/${wp::executable_filename}":
				ensure  => link,
				target  => "${install_path}/bin/${wp::executable_filename}",
				require => File[ "${install_path}/bin/wp" ],
			}
		} else {

			file { "${install_path}/bin/${wp::executable_filename}":
				ensure  => 'present',
				content => template('wp/wp.bat.erb'),
				require => Archive[ 'wp-cli download' ]
			}
		}
	}
	elsif 'absent' == $ensure {
		file { "${wp::bin_path}/${wp::executable_filename}":
			ensure => absent,
		}
		file { '/usr/local/src/wp-cli':
			ensure => absent,
		}
	}

	if $::wp::manage_php_package and ! defined( Package[ $::wp::php_package ] ) {
		package { $::wp::php_package:
			ensure => installed,
		}
	}

	if $::wp::manage_curl_package and ! defined(Package['curl']) {
		package { 'curl':
			ensure => installed,
		}
	}

	if $::wp::manage_git_package and ! defined(Package['git']) {
		package { 'git':
			ensure => installed,
		}
	}
}