summaryrefslogtreecommitdiff
path: root/manifests/lens.pp
blob: 109dd3833eb3d4229e54b49a3f8e9dabde3478e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
define augeas::lens (
  $ensure=present,
  $lens_source,
  $test_source=false
) {

  include augeas::base

  $lens_dest = "${augeas::base::lens_dir}/${name}.aug"
  $test_dest = "${augeas::base::lens_dir}/tests/test_${name}.aug"
 
  file { "${lens_dest}":
    ensure => $ensure,
    source => $lens_source,
# We should actually run the test when the lens is changed
# but we need to know if the test exists...
#    notify => Exec["Typecheck lens ${name}", "Test lens ${name}"]
    notify => Exec["Typecheck lens ${name}"]
  }

  exec { "Typecheck lens ${name}":
    command => "augparse -I ${augeas::base::lens_dir} ${lens_dest} || (rm -f ${lens_dest} && exit 1)",
    require => File["${lens_dest}"],
    refreshonly => true,
  }

  if $test_source {
    file { "${test_dest}":
      ensure => $ensure,
      source => $test_source,
      notify => Exec["Test lens ${name}"]
    }
  
    exec { "Test lens ${name}":
      command => "augparse -I ${augeas::base::lens_dir} ${test_dest} || (rm -f ${lens_dest} && rm -f ${test_dest} && exit 1)",
      require => File["${lens_dest}", "${test_dest}"],
      refreshonly => true,
    }
  }
}