Defined Type: poudriere::env

Defined in:
manifests/env.pp

Overview

This resource creates a build environment for a given release and architecture of FreeBSD. Passing in custom options gives you the ability to turn on and off certain features of your ports. Specific make options you would put in make.conf, you can pass here as well. Automatic periodic building of packages is managed with the cron_enable parameter

Parameters:

  • version (String[1])

    Version of the jail

  • ensure (Enum['present', 'absent']) (defaults to: 'present')

    The desired state of this environment

  • makeopts (Array[String[1]]) (defaults to: [])

    Build options

  • makefile (Optional[String[1]]) (defaults to: undef)

    Path to a Makefile

  • arch (Optional[Poudriere::Architecture]) (defaults to: undef)

    Architecture of the jail

  • jail (String[1]) (defaults to: $name)

    Name of the jail

  • paralleljobs (Integer[1]) (defaults to: $facts['processors']['count'])

    Override the number of builders

  • pkgs (Array[String[1]]) (defaults to: [])

    List of packages to build

  • pkg_file (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Puppet path to a list of packages to build

  • pkg_makeopts (Hash) (defaults to: {})

    Per package build options

  • pkg_optsdir (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Path to a directory of build options

  • portstree (String[1]) (defaults to: 'default')

    The port tree to use

  • cron_enable (Boolean) (defaults to: false)

    Enable automatic updates

  • cron_always_mail (Boolean) (defaults to: false)

    Always send an e-mail on update

  • cron_interval (Poudriere::Cron_interval) (defaults to: { minute => 0, hour => 0, monthday => '*', month => '*', weekday => '*' })

    Scheduling of automatic updates



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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'manifests/env.pp', line 23

define poudriere::env (
  String[1]                      $version,
  Enum['present', 'absent']      $ensure           = 'present',
  Array[String[1]]               $makeopts         = [],
  Optional[String[1]]            $makefile         = undef,
  Optional[Poudriere::Architecture] $arch          = undef,
  String[1]                      $jail             = $name,
  Integer[1]                     $paralleljobs     = $facts['processors']['count'],
  Array[String[1]]               $pkgs             = [],
  Optional[Stdlib::Absolutepath] $pkg_file         = undef,
  Hash                           $pkg_makeopts     = {},
  Optional[Stdlib::Absolutepath] $pkg_optsdir      = undef,
  String[1]                      $portstree        = 'default',
  Boolean                        $cron_enable      = false,
  Boolean                        $cron_always_mail = false,
  Poudriere::Cron_interval       $cron_interval    = { minute => 0, hour => 0, monthday => '*', month => '*', weekday => '*' },
) {
  # Make sure we are prepared to run
  include poudriere

  if $makefile and ($makeopts.length() > 0 or $pkg_makeopts.length() > 0) {
    fail("\$makefile cannot be combined with \$makeopts and \$pkg_makeopts")
  }

  if $facts['os']['architecture'] == 'amd64' and $arch and $arch !~ 'amd64' and $arch !~ 'i386' {
    include poudriere::xbuild
  }

  if ! defined(Poudriere::Portstree[$portstree]) {
    if $portstree == 'defaut' {
      warning('The default portstree is no longer created automatically.  Please consult the Readme file for instructions on how to create this yourself')
    } else {
      warning("portstree['${portstree}'] is not defined please consult the Readme for instructions on how to create this.")
    }
  }

  $manage_file_ensure = $ensure ? {
    'absent' => 'absent',
    default  => 'file',
  }

  $manage_directory_ensure = $ensure ? {
    'absent' => 'absent',
    default  => 'directory',
  }

  # NOTE: directory cannot be defined absent
  # with recurse => true at the sime time:
  # https://tickets.puppetlabs.com/browse/PUP-2903
  $manage_directory_recurse = $ensure ? {
    'absent' => false,
    default  => true,
  }

  $manage_cron_ensure = $ensure ? {
    'absent' => 'absent',
    default => $cron_enable ? {
      true => 'present',
      default => 'absent',
    },
  }

  # Manage jail
  if $ensure != 'absent' {
    $arch_arg = $arch ? {
      Undef   => '',
      default => "-a ${arch}",
    }
    exec { "poudriere-jail-${jail}":
      command => "/usr/local/bin/poudriere jail -c -j ${jail} -v ${version} ${arch_arg} -p ${portstree}",
      require => Poudriere::Portstree[$portstree],
      creates => regsubst("${poudriere::poudriere_base}/jails/${jail}/", ':', '_', 'G'),
      timeout => 3600,
    }
  } else {
    exec { "poudriere-jail-${jail}":
      command => "/usr/local/bin/poudriere jail -d -j ${jail}",
      onlyif  => "/usr/local/bin/poudriere jail -l | /usr/bin/grep -w '^${jail}'",
    }
  }

  # Lay down the configuration
  file { "/usr/local/etc/poudriere.d/${jail}-make.conf":
    ensure  => $manage_file_ensure,
    source  => $makefile,
    content => if $makefile { undef } else { epp('poudriere/make.conf', { makeopts => $makeopts, pkg_makeopts => $pkg_makeopts }) },
    require => Exec["poudriere-jail-${jail}"],
  }

  # Define list of packages to build
  file { "/usr/local/etc/poudriere.d/${jail}.list":
    ensure  => $manage_file_ensure,
    source  => $pkg_file,
    content => inline_template("<%= (@pkgs.join('\n'))+\"\n\" %>"),
    require => Exec["poudriere-jail-${jail}"],
  }

  # Define optional port building options
  if $pkg_optsdir {
    file { "/usr/local/etc/poudriere.d/${jail}-options/":
      ensure  => $manage_directory_ensure,
      recurse => $manage_directory_recurse,
      force   => true,
      source  => $pkg_optsdir,
      require => Exec["poudriere-jail-${jail}"],
    }
  }

  if $cron_always_mail {
    $cron_command = "poudriere bulk -f /usr/local/etc/poudriere.d/${jail}.list -j ${jail} -J ${paralleljobs} -p ${portstree}"
  } else {
    $cron_command = "OUTPUT=\$(poudriere bulk -f /usr/local/etc/poudriere.d/${jail}.list -j ${jail} -J ${paralleljobs} -p ${portstree}) || echo \${OUTPUT}"
  }
  # Build new ports periodically
  cron { "poudriere-bulk-${jail}":
    ensure   => $manage_cron_ensure,
    command  => $cron_command,
    user     => 'root',
    minute   => $cron_interval['minute'],
    hour     => $cron_interval['hour'],
    monthday => $cron_interval['monthday'],
    month    => $cron_interval['month'],
    weekday  => $cron_interval['weekday'],
    require  => Exec["poudriere-jail-${jail}"],
  }
}