dev/provisioning/modules/datacat/manifests/init.pp
author ymh <ymh.work@gmail.com>
Fri, 15 Jan 2016 15:35:00 +0100
changeset 28 b0b56e0f8c7f
permissions -rw-r--r--
Add contributor edition - added viaf resolver - improve contributors list display - add update of document objects - propagate update to back office - update back office - add bo-client to back office - setup language initializer - add options mechanism - add language information in language list - add lexvo resolver service + api - add language and lexvo resolver to js app - correct env template - refresh bootstrap - download google font - add version information - update dev virtual machine to centos7 - add a readme + clean folders - add local .env file to start commands
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
# Definition: datacat
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
#
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
# This definition allows you to declare datacat managed files.
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
#
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
# Parameters:
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
# All parameters are as for the file type, with the addition of a $template
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
# parameter which is a path to a template to be used as the content of the
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
# file.
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
#
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
# Sample Usage:
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
#  datacat { '/etc/motd':
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
#    owner => 'root',
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
#    group => 'root,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
#    template => 'motd/motd.erb',
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
#  }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
#
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
define datacat(
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
  $ensure                  = 'file',
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
  $template                = undef,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
  $template_body           = undef,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
  $collects                = [],
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
  $backup                  = undef,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
  $checksum                = undef,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
  $force                   = undef,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
  $group                   = undef,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
  $owner                   = undef,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
  $mode                    = undef,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
  $path                    = $title,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
  $replace                 = undef,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
  $selinux_ignore_defaults = undef,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
  $selrange                = undef,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
  $selrole                 = undef,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
  $seltype                 = undef,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
  $seluser                 = undef,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
  $show_diff               = 'UNSET'
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
) {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
  if $show_diff != 'UNSET' {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
    if versioncmp($settings::puppetversion, '3.2.0') >= 0 {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
      File { show_diff => $show_diff }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
    } else {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
      warning('show_diff not supported in puppet prior to 3.2, ignoring')
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
    }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
  }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
  # we could validate ensure by simply passing it to file, but unfortunately
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
  # someone could try to be smart and pass 'directory', so we only allow a limited range
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
  if $ensure != 'absent' and $ensure != 'present' and $ensure != 'file' {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
    fail("Datacat[${title}] invalid value for ensure")
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
  }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
  if $ensure == 'absent' {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
    file { $title:
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
      ensure                  => $ensure,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
      path                    => $path,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
      backup                  => $backup,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
      force                   => $force,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
    }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
  } else {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
    file { $title:
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
      path                    => $path,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
      backup                  => $backup,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
      checksum                => $checksum,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
      content                 => "To be replaced by datacat_collector[${title}]\n",
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
      force                   => $force,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
      group                   => $group,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
      mode                    => $mode,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
      owner                   => $owner,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
      replace                 => $replace,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
      selinux_ignore_defaults => $selinux_ignore_defaults,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
      selrange                => $selrange,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
      selrole                 => $selrole,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
      seltype                 => $seltype,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
      seluser                 => $seluser,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
    }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
    $template_real = $template ? {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
      undef   => 'inline',
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
      default => $template,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
    }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
    $template_body_real = $template_body ? {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
      undef   => template_body($template_real),
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
      default => $template_body,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
    }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
    datacat_collector { $title:
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
      template        => $template_real,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
      template_body   => $template_body_real,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
      target_resource => File[$title], # when we evaluate we modify the private data of this resource
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
      target_field    => 'content',
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
      collects        => $collects,
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
      before          => File[$title], # we want to evaluate before that resource so it can do the work
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
    }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
  }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
}