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.

Parameters:

  • extname (Optional[String]) (defaults to: undef)

    The name of the extension. Defaults to $title.

  • provider (String) (defaults to: 'git')

    The name of the VCS repository provider where the extension is hosted. Can be any provider supported by puppetlabs/vcsrepo. Defaults to ‘git’.

  • source (Optional[String]) (defaults to: undef)

    The URL of the remote VCS repository. Defaults to “github.com/ckan/ckanext-$extname”.

  • revision (String) (defaults to: 'master')

    The revision of the VCS repository to check out and install.

  • branch (String) (defaults to: 'master')

    The branch of the VCS repository to check out and install.

  • plugin (Optional[Array[String]]) (defaults to: undef)

    An array of strings that are plugins to add to the plugin configuration in the production.ini.

  • views (Optional[Array[String]]) (defaults to: undef)

    An array of string that are views to add to the view configuration in the production.ini.

  • pip_requirements (String) (defaults to: 'pip-requirements.txt')

    The name of the requirements pip file to be installed. Only the name of the file which is found in the root directory of ext.

  • user (Optional[String]) (defaults to: undef)

    Uses the user’s $HOME/.ssh setup

  • run_setup (Boolean) (defaults to: false)

    Many extensions require the python setup.py develop command to be issued. For convience, this has been added as a default feature which has been disabled. Simply set this to true to run the setup.py command.

  • run_setup_param (String) (defaults to: 'develop')

    The paramter for the setup.py command.



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"],
    }
  }
}