puppet support via puppet-lint
This commit is contained in:
parent
554ba8db83
commit
ae226e24fb
|
@ -0,0 +1,95 @@
|
|||
# Define quantum::generic_service
|
||||
#
|
||||
# This class implements basic ceilomer services.
|
||||
# It is derived from https://github.com/stackforge/puppet-quantum/blob/master/manifests/generic_service.pp
|
||||
#
|
||||
define quantum::generic_service (
|
||||
|
||||
$package_name = '',
|
||||
$package_ensure = 'present',
|
||||
|
||||
$service_name = '',
|
||||
$service_ensure = 'running',
|
||||
$service_enable = true,
|
||||
|
||||
$config_file_path = undef,
|
||||
$config_file_notify = 'default',
|
||||
$config_file_require = 'default',
|
||||
$config_file_replace = undef,
|
||||
$config_file_source = undef,
|
||||
$config_file_template = undef,
|
||||
$config_file_content = undef,
|
||||
$config_file_options_hash = { },
|
||||
|
||||
$config_dir_path = '/etc/quantum',
|
||||
) {
|
||||
|
||||
$distro_prefix = $::osfamily ? {
|
||||
RedHat => 'openstack-',
|
||||
Debian => '',
|
||||
}
|
||||
|
||||
$manage_package_name = pickx($package_name, "${distro_prefix}${name}")
|
||||
$manage_service_name = pickx($service_name, "${distro_prefix}${name}")
|
||||
$manage_config_file_path = pickx($config_file_path, "${config_dir_path}/${name}.conf")
|
||||
$manage_config_file_content = default_content($config_file_content, $config_file_template)
|
||||
$manage_config_file_notify = $config_file_notify ? {
|
||||
'default' => "Service[${name}]",
|
||||
'' => undef,
|
||||
default => $config_file_notify,
|
||||
}
|
||||
$manage_config_file_require = $config_file_require ? {
|
||||
'default' => "Package[${name}]",
|
||||
default => $config_file_require,
|
||||
}
|
||||
|
||||
if $package_ensure == 'absent' {
|
||||
$manage_service_enable = undef
|
||||
$manage_service_ensure = stopped
|
||||
$config_file_ensure = absent
|
||||
} else {
|
||||
$manage_service_enable = $service_enable ? {
|
||||
'' => undef,
|
||||
'undef' => undef,
|
||||
default => $service_enable,
|
||||
}
|
||||
$manage_service_ensure = $service_ensure ? {
|
||||
'' => undef,
|
||||
'undef' => undef,
|
||||
default => $service_ensure,
|
||||
}
|
||||
$config_file_ensure = present
|
||||
}
|
||||
|
||||
if ($manage_package_name) {
|
||||
package { $name:
|
||||
ensure => $package_ensure,
|
||||
name => $manage_package_name,
|
||||
}
|
||||
}
|
||||
|
||||
if ($manage_service_name) {
|
||||
service { $name:
|
||||
ensure => $manage_service_ensure,
|
||||
name => $manage_service_name,
|
||||
enable => $manage_service_enable,
|
||||
require => Package[$manage_package_name],
|
||||
}
|
||||
}
|
||||
|
||||
if $config_file_source
|
||||
or $manage_config_file_content {
|
||||
file { "${name}.conf":
|
||||
ensure => $config_file_ensure,
|
||||
path => $manage_config_file_path,
|
||||
mode => $config_file_mode,
|
||||
owner => $config_file_owner,
|
||||
group => $config_file_group,
|
||||
source => $config_file_source,
|
||||
content => $manage_config_file_content,
|
||||
notify => $manage_config_file_notify,
|
||||
require => $manage_config_file_require,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
# Define quantum::generic_service
|
||||
#
|
||||
# This class implements basic ceilomer services.
|
||||
# It is derived from https://github.com/stackforge/puppet-quantum/blob/master/manifests/generic_service.pp
|
||||
#
|
||||
define quantum::generic_service (
|
||||
|
||||
$package_name = '',
|
||||
$package_ensure = 'present',
|
||||
|
||||
$service_name = '',
|
||||
$service_ensure = 'running',
|
||||
$service_enable = true,
|
||||
|
||||
$config_file_path = undef,
|
||||
$config_file_notify = 'default',
|
||||
$config_file_require = 'default',
|
||||
$config_file_replace = undef,
|
||||
$config_file_source = undef,
|
||||
$config_file_template = undef,
|
||||
$config_file_content = undef,
|
||||
$config_file_options_hash = { },
|
||||
|
||||
$config_dir_path = '/etc/quantum',
|
||||
) {
|
||||
|
||||
$distro_prefix = $::osfamily ? {
|
||||
RedHat => 'openstack-',
|
||||
Debian => '',
|
||||
}
|
||||
|
||||
$manage_package_name = pickx($package_name, "${distro_prefix}${name}")
|
||||
$manage_service_name = pickx($service_name, "${distro_prefix}${name}")
|
||||
$manage_config_file_path = pickx($config_file_path, "${config_dir_path}/${name}.conf")
|
||||
$manage_config_file_content = default_content($config_file_content, $config_file_template)
|
||||
$manage_config_file_notify = $config_file_notify ? {
|
||||
'default' => "Service[${name}]",
|
||||
'' => undef,
|
||||
default => $config_file_notify,
|
||||
}
|
||||
$manage_config_file_require = $config_file_require ? {
|
||||
'default' => "Package[${name}]",
|
||||
default => $config_file_require,
|
||||
}
|
||||
|
||||
if $package_ensure == 'absent' {
|
||||
$manage_service_enable = undef
|
||||
$manage_service_ensure = stopped
|
||||
$config_file_ensure = absent
|
||||
} else {
|
||||
$manage_service_enable = $service_enable ? {
|
||||
'' => undef,
|
||||
'undef' => undef,
|
||||
default => $service_enable,
|
||||
}
|
||||
$manage_service_ensure = $service_ensure ? {
|
||||
'' => undef,
|
||||
'undef' => undef,
|
||||
default => $service_ensure,
|
||||
}
|
||||
$config_file_ensure = present
|
||||
}
|
||||
|
||||
if ($manage_package_name) {
|
||||
package { $name:
|
||||
ensure => $package_ensure,
|
||||
name => $manage_package_name,
|
||||
}
|
||||
}
|
||||
|
||||
if ($manage_service_name) {
|
||||
service { $name:
|
||||
ensure => $manage_service_ensure,
|
||||
name => $manage_service_name,
|
||||
enable => $manage_service_enable,
|
||||
require => Package[$manage_package_name],
|
||||
}
|
||||
}
|
||||
|
||||
if $config_file_source
|
||||
or $manage_config_file_content {
|
||||
file { "${name}.conf":
|
||||
ensure => $config_file_ensure,
|
||||
path => $manage_config_file_path,
|
||||
mode => $config_file_mode,
|
||||
owner => $config_file_owner,
|
||||
group => $config_file_group,
|
||||
source => $config_file_source,
|
||||
content => $manage_config_file_content,
|
||||
notify => $manage_config_file_notify,
|
||||
require => $manage_config_file_require,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -46,6 +46,7 @@ module.exports = class Beautifiers extends EventEmitter
|
|||
'perltidy'
|
||||
'php-cs-fixer'
|
||||
'prettydiff'
|
||||
'puppet-fix'
|
||||
'rubocop'
|
||||
'ruby-beautify'
|
||||
'rustfmt'
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
###
|
||||
Requires [puppet-link](http://puppet-lint.com/)
|
||||
###
|
||||
"use strict"
|
||||
Beautifier = require('./beautifier')
|
||||
|
||||
module.exports = class PuppetFix extends Beautifier
|
||||
# this is what displays as your Default Beautifier in Language Config
|
||||
name: "puppet-lint"
|
||||
|
||||
options: {
|
||||
Puppet: true
|
||||
}
|
||||
|
||||
cli: (options) ->
|
||||
if not options.puppet_path?
|
||||
return new Error("'puppet-lint' path is not set!" +
|
||||
" Please set this in the Atom Beautify package settings.")
|
||||
else
|
||||
return options.puppet_path
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
@run("puppet-lint", [
|
||||
'--fix'
|
||||
tempFile = @tempFile("input", text)
|
||||
], {
|
||||
ignoreReturnCode: true
|
||||
help: {
|
||||
link: "http://puppet-lint.com/"
|
||||
}
|
||||
})
|
||||
.then(=>
|
||||
console.log(@readFile(tempFile))
|
||||
@readFile(tempFile)
|
||||
)
|
|
@ -38,6 +38,7 @@ module.exports = class Languages
|
|||
"pawn"
|
||||
"perl"
|
||||
"php"
|
||||
"puppet"
|
||||
"python"
|
||||
"ruby"
|
||||
"rust"
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
module.exports = {
|
||||
|
||||
name: "Puppet"
|
||||
namespace: "puppet"
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"Puppet"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"pp"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue