Page MenuHomePhabricator
Paste P17066

In which I break puppet-lint
ActivePublic

Authored by MatthewVernon on Aug 24 2021, 10:48 AM.
Tags
None
Referenced Files
F34618708: In which I break puppet-lint
Aug 24 2021, 10:50 AM
F34618707: In which I break puppet-lint
Aug 24 2021, 10:49 AM
F34618706: In which I break puppet-lint
Aug 24 2021, 10:48 AM
Subscribers
None
matthew@tsk:~/puppet$ puppet-lint modules/prometheus/manifests/mysqld_exporter.pp
Whoops! It looks like puppet-lint has encountered an error that it doesn't
know how to handle. Please open an issue at https://github.com/rodjek/puppet-lint
and paste the following output into the issue description.
---
puppet-lint version: 2.4.2
ruby version: 2.7.4-p191
platform: x86_64-linux-gnu
file path: modules/prometheus/manifests/mysqld_exporter.pp
file contents:
```
# == Define: prometheus::mysqld_exporter
#
# Prometheus exporter for MySQL server metrics. The exporter is most effective
# when ran alongside the MySQL server to be monitored, connecting via a local
# UNIX socket is supported.
#
# = Parameters
#
# [*client_socket*]
# The socket to connect to.
#
# [*client_user*]
# MySQL user
#
# [*client_password*]
# MySQL password
#
# [*arguments*]
# Additional command line arguments for prometheus-mysqld-exporter.
define prometheus::mysqld_exporter (
$client_socket = '/tmp/mysql.sock',
$client_user = 'prometheus',
$client_password = '',
$arguments = '',
) {
#We only want to restart if the service is running
#(which it won't be if mariadb isn't)
exec { 'systemctl try-restart prometheus-mysqld-exporter':
refreshonly => true,
path => '/usr/bin',
}
ensure_packages('prometheus-mysqld-exporter', {'notify' => Exec['systemctl try-restart prometheus-mysqld-exporter']})
file { '/var/lib/prometheus':
ensure => directory,
mode => '0550',
owner => 'prometheus',
group => 'prometheus',
}
# default .my.cnf location (i.e. $HOME/.my.cnf)
file { '/var/lib/prometheus/.my.cnf':
ensure => present,
mode => '0400',
owner => 'prometheus',
group => 'prometheus',
content => template('prometheus/mysqld_exporter.cnf.erb'),
require => [
Package['prometheus-mysqld-exporter'],
File['/var/lib/prometheus'],
],
notify => Exec['systemctl try-restart prometheus-mysqld-exporter'],
}
# Set default arguments
if $arguments == '' {
if debian::codename::ge('buster') {
$options = "--collect.global_status \
--collect.global_variables \
--collect.info_schema.processlist \
--collect.slave_status \
--no-collect.info_schema.tables"
} else {
$options = "-collect.global_status \
-collect.global_variables \
-collect.info_schema.processlist \
-collect.info_schema.processlist.min_time 0 \
-collect.slave_status \
-collect.info_schema.tables false"
}
} else {
$options = $arguments
}
file { '/etc/default/prometheus-mysqld-exporter':
ensure => present,
mode => '0444',
owner => 'root',
group => 'root',
content => "ARGS=\"${options}\"",
notify => Exec['systemctl try-restart prometheus-mysqld-exporter'],
}
systemd::unit { 'prometheus-mysqld-exporter':
ensure => present,
override => true,
restart => false,
content => (@EOT)
#Ensure the prometheus exporter is (re-)started and stopped
#with the mariadb service
[Unit]
After=mariadb.service
Requisite=mariadb.service
| EOT
,
}
systemd::unit { 'mariadb':
ensure => present,
override => true,
restart => false,
content => (@ZOT)
#Cause prometheus-mysqld-exporter to be started when mariadb is
[Unit]
Before=prometheus-mysqld-exporter.service
Wants=prometheus-mysqld-exporter.service
| ZOT
,
}
base::service_auto_restart { 'prometheus-mysqld-exporter': }
}
```
error:
```
NoMethodError: undefined method `line' for nil:NilClass
/usr/share/rubygems-integration/all/gems/puppet-lint-2.4.2/lib/puppet-lint/plugins/check_classes/variable_scope.rb:112:in `block (2 levels) in check'
/usr/share/rubygems-integration/all/gems/puppet-lint-2.4.2/lib/puppet-lint/plugins/check_classes/variable_scope.rb:57:in `each'
/usr/share/rubygems-integration/all/gems/puppet-lint-2.4.2/lib/puppet-lint/plugins/check_classes/variable_scope.rb:57:in `block in check'
/usr/share/rubygems-integration/all/gems/puppet-lint-2.4.2/lib/puppet-lint/plugins/check_classes/variable_scope.rb:40:in `each'
/usr/share/rubygems-integration/all/gems/puppet-lint-2.4.2/lib/puppet-lint/plugins/check_classes/variable_scope.rb:40:in `check'
/usr/share/rubygems-integration/all/gems/puppet-lint-2.4.2/lib/puppet-lint/checkplugin.rb:21:in `run'
/usr/share/rubygems-integration/all/gems/puppet-lint-2.4.2/lib/puppet-lint/checks.rb:61:in `block in run'
/usr/share/rubygems-integration/all/gems/puppet-lint-2.4.2/lib/puppet-lint/checks.rb:58:in `each'
/usr/share/rubygems-integration/all/gems/puppet-lint-2.4.2/lib/puppet-lint/checks.rb:58:in `run'
/usr/share/rubygems-integration/all/gems/puppet-lint-2.4.2/lib/puppet-lint.rb:205:in `run'
/usr/share/rubygems-integration/all/gems/puppet-lint-2.4.2/lib/puppet-lint/bin.rb:66:in `block in run'
/usr/share/rubygems-integration/all/gems/puppet-lint-2.4.2/lib/puppet-lint/bin.rb:62:in `each'
/usr/share/rubygems-integration/all/gems/puppet-lint-2.4.2/lib/puppet-lint/bin.rb:62:in `run'
/usr/share/rubygems-integration/all/gems/puppet-lint-2.4.2/bin/puppet-lint:7:in `<top (required)>'
/usr/bin/puppet-lint:23:in `load'
/usr/bin/puppet-lint:23:in `<main>'
```
If I remove the second heredoc, i.e. leave that stanza as
```
systemd::unit { 'mariadb':
ensure => present,
override => true,
restart => false,
}
```
Then puppet-lint is happy...