28
|
1 |
# = Define: puppi::install_packages |
|
2 |
# |
|
3 |
# This define installs a list of packages without manging them as Puppet |
|
4 |
# resources. It's useful when you need a set of packages installed, |
|
5 |
# for example as prerequisites to build code from source, but you don't want |
|
6 |
# to create Puppet package resources for them (since they may conflict with |
|
7 |
# existing classes that provide the same packages. |
|
8 |
# |
|
9 |
# == Parameters: |
|
10 |
# |
|
11 |
# [*packages*] |
|
12 |
# String. Required. |
|
13 |
# A space separated list of of the packages to install |
|
14 |
# |
|
15 |
# [*template*] |
|
16 |
# String. Optional. Default: 'puppi/install_packages.erb' |
|
17 |
# The template to use to generate the script that installs the packages |
|
18 |
# |
|
19 |
# [*scrips_dir*] |
|
20 |
# String. Optional. Default: '/root/puppi_install_packages' |
|
21 |
# The directory where you place the scripts created by the define. |
|
22 |
# |
|
23 |
# [*autorun*] |
|
24 |
# Boolean. Default: true. |
|
25 |
# Define if to automatically execute the script when Puppet runs. |
|
26 |
# |
|
27 |
# [*refreshonly*] |
|
28 |
# Boolean. Optional. Default: true |
|
29 |
# Defines the logic of execution of the script when Puppet runs. |
|
30 |
# Maps to the omonymous Exec type argument. |
|
31 |
# |
|
32 |
# [*timeout*] |
|
33 |
# String. Optional. Default: '600' |
|
34 |
# Exec timeout in seconds. |
|
35 |
# |
|
36 |
# [*ensure*] |
|
37 |
# Define if the runscript script and eventual cron job |
|
38 |
# must be present or absent. Default: present. |
|
39 |
# |
|
40 |
# == Examples |
|
41 |
# |
|
42 |
# - Minimal setup |
|
43 |
# puppi::install_packages { 'build_tools': |
|
44 |
# source => 'build-essential vim git-core curl bison', |
|
45 |
# } |
|
46 |
# |
|
47 |
define puppi::install_packages ( |
|
48 |
$packages, |
|
49 |
$template = 'puppi/install_packages.erb', |
|
50 |
$scripts_dir = '/root/puppi_install_packages', |
|
51 |
$autorun = true, |
|
52 |
$refreshonly = true, |
|
53 |
$timeout = '600', |
|
54 |
$ensure = 'present' ) { |
|
55 |
|
|
56 |
if ! defined(File[$scripts_dir]) { |
|
57 |
file { $scripts_dir: |
|
58 |
ensure => directory, |
|
59 |
mode => '0755', |
|
60 |
owner => 'root', |
|
61 |
group => 'root', |
|
62 |
} |
|
63 |
} |
|
64 |
|
|
65 |
file { "install_packages_${name}": |
|
66 |
ensure => $ensure, |
|
67 |
path => "${scripts_dir}/${name}", |
|
68 |
mode => '0755', |
|
69 |
owner => 'root', |
|
70 |
group => 'root', |
|
71 |
content => template($template), |
|
72 |
} |
|
73 |
|
|
74 |
if $autorun == true { |
|
75 |
exec { "install_packages_${name}": |
|
76 |
command => "${scripts_dir}/${name}", |
|
77 |
refreshonly => $refreshonly, |
|
78 |
subscribe => File["install_packages_${name}"], |
|
79 |
timeout => $timeout, |
|
80 |
} |
|
81 |
} |
|
82 |
|
|
83 |
} |