Various Puppet lint fixes

* Fix following warnings:
    * double quoted string containing no variables
    * indentation of => is not properly aligned
    * mode should be represented as a 4 digit octal value or symbolic mode
    * string containing only a variable
    * top-scope variable being used without an explicit namespace
    * unquoted file mode
    * variable not enclosed in {}
* Fix following errors:
    * trailing whitespace found
    * two-space soft tabs not used
* Remove quotes around class in include/require statements

Change-Id: Ia920d848e1955612a6486ec8731309e6d3a70f63
This commit is contained in:
Mathieu Gagné
2013-07-01 18:27:13 -04:00
parent cb2e06556d
commit 178f4b18dc
25 changed files with 65 additions and 63 deletions

View File

@@ -84,7 +84,7 @@ class swift::dispersion (
timeout => 0, timeout => 0,
onlyif => "swift -A ${auth_url} -U ${auth_tenant}:${auth_user} -K ${auth_pass} -V ${auth_version} stat | grep 'Account: '", onlyif => "swift -A ${auth_url} -U ${auth_tenant}:${auth_user} -K ${auth_pass} -V ${auth_version} stat | grep 'Account: '",
unless => "swift -A ${auth_url} -U ${auth_tenant}:${auth_user} -K ${auth_pass} -V ${auth_version} list | grep dispersion_", unless => "swift -A ${auth_url} -U ${auth_tenant}:${auth_user} -K ${auth_pass} -V ${auth_version} list | grep dispersion_",
require => Package["swiftclient"], require => Package['swiftclient'],
} }
} }

View File

@@ -45,12 +45,12 @@ class swift(
file { '/home/swift': file { '/home/swift':
ensure => directory, ensure => directory,
mode => 0700, mode => '0700',
} }
file { '/etc/swift': file { '/etc/swift':
ensure => directory, ensure => directory,
mode => 2770, mode => '2770',
} }
user {'swift': user {'swift':
ensure => present, ensure => present,
@@ -65,7 +65,7 @@ class swift(
file { '/etc/swift/swift.conf': file { '/etc/swift/swift.conf':
ensure => present, ensure => present,
mode => 0660, mode => '0660',
content => template('swift/swift.conf.erb'), content => template('swift/swift.conf.erb'),
} }

View File

@@ -14,7 +14,7 @@ class swift::keystone::auth(
) { ) {
if $address != '127.0.0.1' { if $address != '127.0.0.1' {
warning("Address parameter for swift::keystone::auth has been deprecated, use public_address instead") warning('Address parameter for swift::keystone::auth has been deprecated, use public_address instead')
} }
if ! $public_port { if ! $public_port {

View File

@@ -1,5 +1,5 @@
class swift::params { class swift::params {
case $osfamily { case $::osfamily {
'Debian': { 'Debian': {
$package_name = 'swift' $package_name = 'swift'
$client_package = 'python-swiftclient' $client_package = 'python-swiftclient'
@@ -51,7 +51,7 @@ class swift::params {
$swift3 = 'openstack-swift-plugin-swift3' $swift3 = 'openstack-swift-plugin-swift3'
} }
default: { default: {
fail("Unsupported osfamily: ${osfamily} for os ${operatingsystem}") fail("Unsupported osfamily: ${::osfamily} for os ${::operatingsystem}")
} }
} }
} }

View File

@@ -55,8 +55,8 @@ class swift::proxy(
$package_ensure = 'present' $package_ensure = 'present'
) { ) {
include 'swift::params' include swift::params
include 'concat::setup' include concat::setup
validate_bool($account_autocreate) validate_bool($account_autocreate)
validate_bool($allow_account_management) validate_bool($allow_account_management)
@@ -77,7 +77,7 @@ class swift::proxy(
} }
if($auth_type == 'tempauth' and ! $account_autocreate ){ if($auth_type == 'tempauth' and ! $account_autocreate ){
fail("\$account_autocreate must be set to true when auth type is tempauth") fail('account_autocreate must be set to true when auth_type is tempauth')
} }
package { 'swift-proxy': package { 'swift-proxy':
@@ -102,7 +102,7 @@ class swift::proxy(
# you can now add your custom fragments at the user level # you can now add your custom fragments at the user level
concat::fragment { 'swift_proxy': concat::fragment { 'swift_proxy':
target => "/etc/swift/proxy-server.conf", target => '/etc/swift/proxy-server.conf',
content => template('swift/proxy-server.conf.erb'), content => template('swift/proxy-server.conf.erb'),
order => '00', order => '00',
# require classes for each of the elements of the pipeline # require classes for each of the elements of the pipeline

View File

@@ -61,7 +61,7 @@ class swift::proxy::authtoken(
validate_re($auth_admin_prefix, '^(/.+[^/])?$') validate_re($auth_admin_prefix, '^(/.+[^/])?$')
} }
concat::fragment { "swift_authtoken": concat::fragment { 'swift_authtoken':
target => '/etc/swift/proxy-server.conf', target => '/etc/swift/proxy-server.conf',
content => template('swift/proxy/authtoken.conf.erb'), content => template('swift/proxy/authtoken.conf.erb'),
order => '22', order => '22',

View File

@@ -5,7 +5,7 @@
# #
# == Examples # == Examples
# #
# include 'swift::proxy::catch_errors' # include swift::proxy::catch_errors
# #
# == Authors # == Authors
# #

View File

@@ -5,7 +5,7 @@
# #
# == Examples # == Examples
# #
# include 'swift::proxy::formpost' # include swift::proxy::formpost
# #
# == Authors # == Authors
# #

View File

@@ -27,11 +27,11 @@ class swift::proxy::s3token(
$auth_protocol = 'http' $auth_protocol = 'http'
) { ) {
include keystone::python
concat::fragment { 'swift_s3token': concat::fragment { 'swift_s3token':
target => '/etc/swift/proxy-server.conf', target => '/etc/swift/proxy-server.conf',
content => template('swift/proxy/s3token.conf.erb'), content => template('swift/proxy/s3token.conf.erb'),
order => '28', order => '28',
} }
include 'keystone::python'
} }

View File

@@ -18,7 +18,7 @@ class swift::proxy::swift3(
$ensure = 'present' $ensure = 'present'
) { ) {
include $::swift::params include swift::params
package { 'swift-plugin-s3': package { 'swift-plugin-s3':
name => $::swift::params::swift3, name => $::swift::params::swift3,

View File

@@ -5,7 +5,7 @@
# #
# == Examples # == Examples
# #
# include 'swift::proxy::tempurl' # include swift::proxy::tempurl
# #
# == Authors # == Authors
# #

View File

@@ -29,9 +29,9 @@ class swift::ringserver(
use_chroot => 'no', use_chroot => 'no',
} }
rsync::server::module { "swift_server": rsync::server::module { 'swift_server':
path => '/etc/swift', path => '/etc/swift',
lock_file => "/var/lock/swift_server.lock", lock_file => '/var/lock/swift_server.lock',
uid => 'swift', uid => 'swift',
gid => 'swift', gid => 'swift',
max_connections => $max_connections, max_connections => $max_connections,

View File

@@ -27,7 +27,7 @@ class swift::storage::container(
require => Package['swift-container'], require => Package['swift-container'],
} }
if $operatingsystem == 'Ubuntu' { if $::operatingsystem == 'Ubuntu' {
# The following service conf is missing in Ubunty 12.04 # The following service conf is missing in Ubunty 12.04
file { '/etc/init/swift-container-sync.conf': file { '/etc/init/swift-container-sync.conf':
source => 'puppet:///modules/swift/swift-container-sync.conf.upstart', source => 'puppet:///modules/swift/swift-container-sync.conf.upstart',

View File

@@ -42,6 +42,8 @@ define swift::storage::loopback(
subscribe => Exec["create_partition-${name}"], subscribe => Exec["create_partition-${name}"],
loopback => true, loopback => true,
} }
$device_config_hash = {"$name" => $storage_params,} # NOTE(mgagne) Puppet does not allow hash keys to be bare variables.
create_resources("swift::storage::$fstype", $device_config_hash) # Keep double-quotes to avoid parse errors.
$device_config_hash = { "${name}" => $storage_params }
create_resources("swift::storage::${fstype}", $device_config_hash)
} }

View File

@@ -34,7 +34,7 @@ define swift::storage::mount(
ensure => present, ensure => present,
device => $device, device => $device,
fstype => $fstype, fstype => $fstype,
options => "$options,$fsoptions", options => "${options},${fsoptions}",
require => File["${mnt_base_dir}/${name}"] require => File["${mnt_base_dir}/${name}"]
} }

View File

@@ -27,7 +27,7 @@ define swift::storage::node(
type => 'object', type => 'object',
config_file_path => 'object-server.conf', config_file_path => 'object-server.conf',
} }
ring_object_device { "${storage_local_net_ip}:60${name}0/$name": ring_object_device { "${storage_local_net_ip}:60${name}0/${name}":
zone => $zone, zone => $zone,
weight => $weight, weight => $weight,
} }
@@ -36,7 +36,7 @@ define swift::storage::node(
type => 'container', type => 'container',
config_file_path => 'container-server.conf', config_file_path => 'container-server.conf',
} }
ring_container_device { "${storage_local_net_ip}:60${name}1/$name": ring_container_device { "${storage_local_net_ip}:60${name}1/${name}":
zone => $zone, zone => $zone,
weight => $weight, weight => $weight,
} }
@@ -45,7 +45,7 @@ define swift::storage::node(
type => 'account', type => 'account',
config_file_path => 'account-server.conf', config_file_path => 'account-server.conf',
} }
ring_account_device { "${storage_local_net_ip}:60${name}2/$name": ring_account_device { "${storage_local_net_ip}:60${name}2/${name}":
zone => $zone, zone => $zone,
weight => $weight, weight => $weight,
} }

View File

@@ -28,13 +28,13 @@ define swift::storage::server(
# TODO if array does not include type-server, warn # TODO if array does not include type-server, warn
if( if(
(is_array($pipeline) and ! member($pipeline, "${type}-server")) or (is_array($pipeline) and ! member($pipeline, "${type}-server")) or
"$pipeline" != "${type}-server" $pipeline != "${type}-server"
) { ) {
warning("swift storage server ${type} must specify ${type}-server") warning("swift storage server ${type} must specify ${type}-server")
} }
include "swift::storage::$type" include "swift::storage::${type}"
include 'concat::setup' include concat::setup
validate_re($name, '^\d+$') validate_re($name, '^\d+$')
validate_re($type, '^object|container|account$') validate_re($type, '^object|container|account$')
@@ -44,7 +44,7 @@ define swift::storage::server(
$bind_port = $name $bind_port = $name
rsync::server::module { "${type}": rsync::server::module { $type:
path => $devices, path => $devices,
lock_file => "/var/lock/${type}.lock", lock_file => "/var/lock/${type}.lock",
uid => $owner, uid => $owner,

View File

@@ -37,7 +37,7 @@ class swift::test_file (
$user = 'admin' $user = 'admin'
) { ) {
file { '/tmp/swift_test_file.rb': file { '/tmp/swift_test_file.rb':
mode => '755', mode => '0755',
content => template('swift/swift_keystone_test.erb') content => template('swift/swift_keystone_test.erb')
} }
} }

View File

@@ -3,9 +3,9 @@ require 'spec_helper'
describe 'swift::proxy::swift3' do describe 'swift::proxy::swift3' do
let :facts do let :facts do
{ { :concat_basedir => '/var/lib/puppet/concat',
:concat_basedir => '/var/lib/puppet/concat' :osfamily => 'Debian',
} :operatingsystem => 'Ubuntu' }
end end
let :pre_condition do let :pre_condition do

View File

@@ -25,7 +25,7 @@
#$swift_admin_password = 'admin_password' #$swift_admin_password = 'admin_password'
$swift_admin_password = hiera('admin_password', 'admin_password') $swift_admin_password = hiera('admin_password', 'admin_password')
# swift specific configurations # swift specific configurations
#$swift_shared_secret = 'changeme' #$swift_shared_secret = 'changeme'
$swift_shared_secret = hiera('swift_shared_secret', 'changeme') $swift_shared_secret = hiera('swift_shared_secret', 'changeme')