Skip to content

Commit

Permalink
puppet-lint: autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Jul 25, 2020
1 parent d0f6848 commit 3dd0582
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 36 deletions.
2 changes: 0 additions & 2 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# include python::config
#
class python::config {

Class['python::install'] -> Python::Pip <| |>
Class['python::install'] -> Python::Requirements <| |>
Class['python::install'] -> Python::Virtualenv <| |>
Expand All @@ -27,5 +26,4 @@
}
}
}

}
2 changes: 1 addition & 1 deletion manifests/dotfile.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

exec { "create ${title}'s parent dir":
command => "install -o ${owner} -g ${group} -d ${parent_dir}",
path => [ '/usr/bin', '/bin', '/usr/local/bin', ],
path => ['/usr/bin', '/bin', '/usr/local/bin',],
creates => $parent_dir,
}

Expand Down
1 change: 0 additions & 1 deletion manifests/gunicorn.pp
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,4 @@
content => template($template),
}
}

}
16 changes: 7 additions & 9 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,31 @@
$gunicorn_package_name = $python::params::gunicorn_package_name,
Optional[Enum['pip', 'scl', 'rhscl', 'anaconda', '']] $provider = $python::params::provider,
$valid_versions = $python::params::valid_versions,
Hash $python_pips = { },
Hash $python_virtualenvs = { },
Hash $python_pyvenvs = { },
Hash $python_requirements = { },
Hash $python_dotfiles = { },
Hash $python_pips = {},
Hash $python_virtualenvs = {},
Hash $python_pyvenvs = {},
Hash $python_requirements = {},
Hash $python_dotfiles = {},
Boolean $use_epel = $python::params::use_epel,
$rhscl_use_public_repository = $python::params::rhscl_use_public_repository,
Stdlib::Httpurl $anaconda_installer_url = $python::params::anaconda_installer_url,
Stdlib::Absolutepath $anaconda_install_path = $python::params::anaconda_install_path,
Boolean $manage_scl = $python::params::manage_scl,
Optional[Pattern[/[0-7]{1,4}/]] $umask = undef,
) inherits python::params {

$exec_prefix = $provider ? {
'scl' => "/usr/bin/scl enable ${version} -- ",
'rhscl' => "/usr/bin/scl enable ${version} -- ",
default => '',
}

unless $version =~ Pattern[/\A(python)?[0-9](\.?[0-9])*/,
/\Apypy\Z/, /\Asystem\Z/, /\Arh-python[0-9]{2}(?:-python)?\Z/] {
/\Apypy\Z/, /\Asystem\Z/, /\Arh-python[0-9]{2}(?:-python)?\Z/] {
fail("version needs to be pypy, system or a version string like '36', '3.6' or 'python3.6' )")
}

# Module compatibility check
$compatible = [ 'Debian', 'RedHat', 'Suse', 'Gentoo', 'AIX' ]
$compatible = ['Debian', 'RedHat', 'Suse', 'Gentoo', 'AIX']
if ! ($facts['os']['family'] in $compatible) {
fail("Module is not compatible with ${facts['os']['name']}")
}
Expand All @@ -96,5 +95,4 @@
create_resources('python::virtualenv', $python_virtualenvs)
create_resources('python::requirements', $python_requirements)
create_resources('python::dotfile', $python_dotfiles)

}
6 changes: 1 addition & 5 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# include python::install
#
class python::install {

$python = $python::version ? {
'system' => 'python',
'pypy' => 'pypy',
Expand Down Expand Up @@ -67,7 +66,6 @@

case $python::provider {
'pip': {

if $python::manage_pip_package {
package { 'pip':
ensure => $pip_ensure,
Expand Down Expand Up @@ -208,7 +206,7 @@
'AIX': {
if String($python::version) =~ /^python3/ {
class { 'python::pip::bootstrap':
version => 'pip3',
version => 'pip3',
}
} else {
if $python::manage_pip_package {
Expand All @@ -227,7 +225,6 @@
provider => 'yum',
}
}

}
default: {
if $python::manage_pip_package {
Expand All @@ -243,7 +240,6 @@
alias => $pythondev,
}
}

}
}

Expand Down
4 changes: 2 additions & 2 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
}

$pip_lookup_path = $facts['os']['family'] ? {
'AIX' => [ '/bin', '/usr/bin', '/usr/local/bin', '/opt/freeware/bin/' ],
default => [ '/bin', '/usr/bin', '/usr/local/bin' ]
'AIX' => ['/bin', '/usr/bin', '/usr/local/bin', '/opt/freeware/bin/'],
default => ['/bin', '/usr/bin', '/usr/local/bin']
}

$gunicorn_package_name = $facts['os']['family'] ? {
Expand Down
17 changes: 8 additions & 9 deletions manifests/pip.pp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
String[1] $log_dir = '/tmp',
Array[String] $path = ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'],
String[1] $exec_provider = 'shell',
){
) {
$python_provider = getparam(Class['python'], 'provider')
$python_version = getparam(Class['python'], 'version')

Expand Down Expand Up @@ -111,9 +111,9 @@
}

$pypi_index = $index ? {
false => '',
default => "--index-url=${index}",
}
false => '',
default => "--index-url=${index}",
}

$proxy_flag = $proxy ? {
undef => '',
Expand Down Expand Up @@ -204,15 +204,15 @@
# Note: we DO need to repeat ourselves with "from version" in both grep and sed as on some systems pip returns
# more than one line with paretheses.
$latest_version = join(["${pip_install} ${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${real_pkgname}==notreallyaversion 2>&1",
' | grep -oP "\(from versions: .*\)" | sed -E "s/\(from versions: (.*?, )*(.*)\)/\2/g"',
' | tr -d "[:space:]"'])
' | grep -oP "\(from versions: .*\)" | sed -E "s/\(from versions: (.*?, )*(.*)\)/\2/g"',
' | tr -d "[:space:]"'])

# Packages with underscores in their names are listed with dashes in their place in `pip freeze` output
$pkgname_with_dashes = regsubst($real_pkgname, '_', '-', 'G')
$grep_regex_pkgname_with_dashes = "^${pkgname_with_dashes}=="
$installed_version = join(["${pip_env} freeze --all",
" | grep -i -e ${grep_regex_pkgname_with_dashes} | cut -d= -f3",
" | tr -d '[:space:]'"])
" | grep -i -e ${grep_regex_pkgname_with_dashes} | cut -d= -f3",
" | tr -d '[:space:]'"])

$command = "${pip_install} --upgrade ${pip_common_args}"
$unless_command = "[ \$(${latest_version}) = \$(${installed_version}) ]"
Expand Down Expand Up @@ -243,5 +243,4 @@
path => $_path,
provider => $exec_provider,
}

}
4 changes: 2 additions & 2 deletions manifests/pip/bootstrap.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
$environ = $http_proxy ? {
undef => [],
default => $facts['os']['family'] ? {
'AIX' => [ "http_proxy=${http_proxy}", "https_proxy=${http_proxy}" ],
default => [ "HTTP_PROXY=${http_proxy}", "HTTPS_PROXY=${http_proxy}" ],
'AIX' => ["http_proxy=${http_proxy}", "https_proxy=${http_proxy}"],
default => ["HTTP_PROXY=${http_proxy}", "HTTPS_PROXY=${http_proxy}"],
}
}

Expand Down
4 changes: 2 additions & 2 deletions manifests/pyvenv.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
$owner = 'root',
$group = 'root',
$mode = '0755',
$path = [ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin' ],
$path = ['/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin'],
$environment = [],
) {
include python
Expand All @@ -44,7 +44,7 @@
$normalized_python_version = sprintf('%s.%s', $python_version_parts[0], $python_version_parts[1])

# Debian splits the venv module into a seperate package
if ( $facts['os']['family'] == 'Debian'){
if ( $facts['os']['family'] == 'Debian') {
$python3_venv_package="python${normalized_python_version}-venv"
case $facts['os']['distro']['codename'] {
'xenial','bionic','cosmic','disco',
Expand Down
3 changes: 1 addition & 2 deletions manifests/requirements.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
$log_dir = '/tmp',
$timeout = 1800,
) {

include python

if $virtualenv == 'system' and ($owner != 'root' or $group != 'root') {
Expand Down Expand Up @@ -81,7 +80,7 @@
# the same requirements file.
if !defined(File[$requirements]) and $manage_requirements == true {
file { $requirements:
ensure => present,
ensure => file,
mode => '0644',
owner => $owner_real,
group => $group_real,
Expand Down
2 changes: 1 addition & 1 deletion manifests/virtualenv.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
$mode = '0755',
Optional[Stdlib::HTTPUrl] $proxy = undef,
$environment = [],
$path = [ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin' ],
$path = ['/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin'],
$cwd = undef,
$timeout = 1800,
$pip_args = '',
Expand Down

0 comments on commit 3dd0582

Please sign in to comment.