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

@@ -10,7 +10,7 @@ class swift::auth_file (
owner => 'root', owner => 'root',
group => 'root', group => 'root',
mode => '0600', mode => '0600',
content => content =>
" "
export ST_USER=${admin_tenant}:${admin_user} export ST_USER=${admin_tenant}:${admin_user}
export ST_KEY=${admin_password} export ST_KEY=${admin_password}

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,19 +45,19 @@ 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,
} }
file { '/var/lib/swift': file { '/var/lib/swift':
ensure => directory, ensure => directory,
owner => 'swift' owner => 'swift'
} }
file { '/var/run/swift': file { '/var/run/swift':
ensure => directory, ensure => directory,
@@ -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,12 +29,12 @@ 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,
read_only => true, read_only => true,
} }
} }

View File

@@ -6,7 +6,7 @@ class swift::storage::account(
} }
service { 'swift-account-reaper': service { 'swift-account-reaper':
name => $::swift::params::account_reaper_service_name, name => $::swift::params::account_reaper_service_name,
ensure => running, ensure => running,
enable => true, enable => true,
provider => $::swift::params::service_provider, provider => $::swift::params::service_provider,
@@ -14,7 +14,7 @@ class swift::storage::account(
} }
service { 'swift-account-auditor': service { 'swift-account-auditor':
name => $::swift::params::account_auditor_service_name, name => $::swift::params::account_auditor_service_name,
ensure => running, ensure => running,
enable => true, enable => true,
provider => $::swift::params::service_provider, provider => $::swift::params::service_provider,

View File

@@ -1,7 +1,7 @@
# #
# === Parameters # === Parameters
# #
# [*allowed_sync_hosts*] A list of hosts allowed in the X-Container-Sync-To # [*allowed_sync_hosts*] A list of hosts allowed in the X-Container-Sync-To
# field for containers. Defaults to one entry list '127.0.0.1'. # field for containers. Defaults to one entry list '127.0.0.1'.
# #
class swift::storage::container( class swift::storage::container(
@@ -13,21 +13,21 @@ class swift::storage::container(
} }
service { 'swift-container-updater': service { 'swift-container-updater':
name => $::swift::params::container_updater_service_name, name => $::swift::params::container_updater_service_name,
ensure => running, ensure => running,
enable => true, enable => true,
provider => $::swift::params::service_provider, provider => $::swift::params::service_provider,
require => Package['swift-container'], require => Package['swift-container'],
} }
service { 'swift-container-auditor': service { 'swift-container-auditor':
name => $::swift::params::container_auditor_service_name, name => $::swift::params::container_auditor_service_name,
ensure => running, ensure => running,
enable => true, enable => true,
provider => $::swift::params::service_provider, provider => $::swift::params::service_provider,
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

@@ -6,7 +6,7 @@
# this define needs to be sent a refresh signal to do anything # this define needs to be sent a refresh signal to do anything
# #
# #
# [*title*] # [*title*]
# #
# [*byte_size*] Byte size to use for every inode in the created filesystem. # [*byte_size*] Byte size to use for every inode in the created filesystem.
# It is recommened to use 1024 to ensure that the metadata can fit in a single inode. # It is recommened to use 1024 to ensure that the metadata can fit in a single inode.

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

@@ -17,9 +17,9 @@ define swift::storage::mount(
} }
if($fstype == 'xfs'){ if($fstype == 'xfs'){
$fsoptions = 'logbufs=8' $fsoptions = 'logbufs=8'
} else { } else {
$fsoptions = 'user_xattr' $fsoptions = 'user_xattr'
} }
# the directory that represents the mount point # the directory that represents the mount point
@@ -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

@@ -24,28 +24,28 @@ define swift::storage::node(
} }
swift::storage::server { "60${name}0": swift::storage::server { "60${name}0":
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,
} }
swift::storage::server { "60${name}1": swift::storage::server { "60${name}1":
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,
} }
swift::storage::server { "60${name}2": swift::storage::server { "60${name}2":
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

@@ -6,14 +6,14 @@ class swift::storage::object(
} }
service { 'swift-object-updater': service { 'swift-object-updater':
name => $::swift::params::object_updater_service_name, name => $::swift::params::object_updater_service_name,
ensure => running, ensure => running,
enable => true, enable => true,
provider => $::swift::params::service_provider, provider => $::swift::params::service_provider,
require => Package['swift-object'], require => Package['swift-object'],
} }
service { 'swift-object-auditor': service { 'swift-object-auditor':
name => $::swift::params::object_auditor_service_name, name => $::swift::params::object_auditor_service_name,
ensure => running, ensure => running,
enable => true, enable => true,
provider => $::swift::params::service_provider, provider => $::swift::params::service_provider,

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,13 +44,13 @@ 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,
gid => $group, gid => $group,
max_connections => $max_connections, max_connections => $max_connections,
read_only => false, read_only => false,
} }
concat { "/etc/swift/${config_file_path}": concat { "/etc/swift/${config_file_path}":

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

@@ -18,7 +18,7 @@ class { 'memcached':
class { 'swift': class { 'swift':
# not sure how I want to deal with this shared secret # not sure how I want to deal with this shared secret
swift_hash_suffix => $swift_shared_secret, swift_hash_suffix => $swift_shared_secret,
package_ensure => latest, package_ensure => latest,
} }
# === Configure Storage # === Configure Storage

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')
@@ -250,8 +250,8 @@ node /swift-proxy/ inherits swift_base {
# exports rsync gets that can be used to sync the ring files # exports rsync gets that can be used to sync the ring files
@@swift::ringsync { ['account', 'object', 'container']: @@swift::ringsync { ['account', 'object', 'container']:
ring_server => $swift_local_net_ip ring_server => $swift_local_net_ip
} }
# deploy a script that can be used for testing # deploy a script that can be used for testing
class { 'swift::test_file': class { 'swift::test_file':