Defined Type: ckan::ext
- Defined in:
- manifests/ext.pp
Summary
A type which can be used to install a CKAN extension in the default location.Overview
The ext directory classes utilize the ckan modularization framework known as [extensions](extensions.ckan.org). To fully install the plugin, puppet needs to be run twice. The first time puppet runs, the extension won’t be added to ckan due to how this module manages the plugins.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'manifests/ext.pp', line 51
define ckan::ext (
Optional[String] $extname = undef,
String $provider = 'git',
Optional[String] $source = undef,
String $revision = 'master',
String $branch = 'master',
Optional[Array[String]] $plugin = undef,
Optional[Array[String]] $views = undef,
String $pip_requirements = 'pip-requirements.txt',
Optional[String] $user = undef,
Boolean $run_setup = false,
String $run_setup_param = 'develop'
) {
if ! defined(Class['ckan']) {
fail( 'You must include the ckan base class before using any ckan defined resources')
}
$pip = $ckan::pip
$python = $ckan::python
$activate = '/usr/local/bin/ckan_activate_exec.bash'
if $extname == undef {
$_extname = $title
} else {
$_extname = $extname
}
if $source == undef {
$_source = "http://github.com/ckan/ckanext-${_extname}"
} else {
$_source = $source
}
$extdir = "/usr/lib/ckan/default/src/ckanext-${_extname}"
$defaults = {
# TODO add require to
require => Class['ckan::conf::production'],
}
# check if the plugins need to be updated
if $plugin != undef {
# update plugins with ini
ensure_resource(ckan::conf::plugin_setting,$plugin,$defaults)
}
if $views != undef {
# update views with ini
ensure_resource(ckan::conf::views_setting,$views,$defaults)
}
vcsrepo { $extdir:
ensure => 'latest',
provider => $provider,
source => $_source,
revision => $revision,
branch => $branch,
user => $user,
require => File['/usr/lib/ckan/default/src'],
}
exec { "install ckanext-${_extname}":
command => "${activate} ${pip} install -e '${extdir}'",
refreshonly => true,
subscribe => Vcsrepo[$extdir],
}
exec { "install ckanext-${_extname} requirements":
command => "${activate} ${pip} install -r '${extdir}/${pip_requirements}'",
cwd => $extdir,
onlyif => "/usr/bin/test -e '${extdir}/${pip_requirements}'",
refreshonly => true,
subscribe => Exec["install ckanext-${_extname}"],
}
if $run_setup {
exec { "setup ckanext-${_extname}":
command => "${activate} ${python} setup.py ${run_setup_param}",
cwd => $extdir,
refreshonly => true,
subscribe => Exec["install ckanext-${_extname} requirements"],
}
}
}
|