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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/onceover/codequality/syntax.rb', line 6
def self.puppet
status = true
logger.info("Checking syntax using puppet-syntax rake task...")
inline_ruby = <<-RUBY_CODE
require 'puppet-syntax/tasks/puppet-syntax'
PuppetSyntax.exclude_paths = ['vendor/**/*','spec/templates/*.erb']
Rake::Task['syntax'].invoke
RUBY_CODE
output, s = Open3.capture2e("ruby", "-e", inline_ruby)
ok = s.exitstatus.zero?
status &= ok
if ok
logger.info("...ok")
else
logger.error("puppet-syntax validation failed: #{output}")
end
if system("python --version && python -c 'import yaml'", :err => File::NULL)
logger.info("Running additional python YAML validation")
script = File.join(File.dirname(File.expand_path(__FILE__)), "../../../res/validate_yaml.py")
output, s = Open3.capture2e("python #{script}")
ok = s.exitstatus.zero?
status &= ok
if ok
logger.info("...ok")
else
logger.error("Puppetfile validation failed: #{output}")
end
else
logger.warn("Please install python and pyyaml for enhanced YAML validation (pip install pyyaml)")
end
status
end
|