Skip to content

Commit

Permalink
fix puppet code style/lint/indent
Browse files Browse the repository at this point in the history
  • Loading branch information
crazymind1337 committed Nov 17, 2020
1 parent 2590a43 commit 784386d
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 121 deletions.
2 changes: 1 addition & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Python::Virtualenv <| |> -> Python::Pip <| |>

if $python::manage_gunicorn {
if $python::gunicorn != 'absent' {
unless $python::gunicorn == 'absent' {
Class['python::install'] -> Python::Gunicorn <| |>

Python::Gunicorn <| |> ~> Service['gunicorn']
Expand Down
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: 1 addition & 0 deletions manifests/gunicorn.pp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
owner => 'root',
group => 'root',
}

file { "${config_dir}/${name}":
ensure => $ensure,
mode => '0644',
Expand Down
10 changes: 2 additions & 8 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,18 @@
default => '',
}

# Module compatibility check
$compatible = ['Debian', 'RedHat', 'Suse', 'Gentoo', 'AIX']
if ! ($facts['os']['family'] in $compatible) {
fail("Module is not compatible with ${facts['os']['name']}")
}

contain python::install
contain python::config

Class['python::install']
-> Class['python::config']

# Set default umask.
## Set default umask.
if $umask != undef {
Exec { umask => $umask }
}

# Allow hiera configuration of python resources
## Allow hiera configuration of python resources
create_resources('python::pip', $python_pips)
create_resources('python::pyvenv', $python_pyvenvs)
create_resources('python::virtualenv', $python_virtualenvs)
Expand Down
57 changes: 33 additions & 24 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@

if $venv_ensure == 'present' {
$dev_ensure = 'present'

unless $python::dev {
# Error: python2-devel is needed by (installed) python-virtualenv-15.1.0-2.el7.noarch
# Python dev is required for virtual environment, but python environment is not required for python dev.
## Error: python2-devel is needed by (installed) python-virtualenv-15.1.0-2.el7.noarch
## Python dev is required for virtual environment, but python environment is not required for python dev.
notify { 'Python virtual environment is dependent on python dev': }
}
} else {
Expand Down Expand Up @@ -80,17 +81,18 @@
}
}

# Respect the $pip_ensure setting
## Respect the $pip_ensure setting
unless $pip_ensure == 'absent' {
# Install pip without pip, see https://pip.pypa.io/en/stable/installing/.
include 'python::pip::bootstrap'
## Install pip without pip, see https://pip.pypa.io/en/stable/installing/.
include python::pip::bootstrap

Exec['bootstrap pip'] -> File['pip-python'] -> Package <| provider == pip |>

Package <| title == 'pip' |> {
name => 'pip',
provider => 'pip',
}

if $pythondev {
Package <| title == 'virtualenv' |> {
name => 'virtualenv',
Expand All @@ -106,9 +108,9 @@
}
}
'scl': {
# SCL is only valid in the RedHat family. If RHEL, package must be
# enabled using the subscription manager outside of puppet. If CentOS,
# the centos-release-SCL will install the repository.
## SCL is only valid in the RedHat family. If RHEL, package must be
## enabled using the subscription manager outside of puppet. If CentOS,
## the centos-release-SCL will install the repository.
if $python::manage_scl {
$install_scl_repo_package = $facts['os']['name'] ? {
'CentOS' => 'present',
Expand All @@ -119,6 +121,7 @@
ensure => $install_scl_repo_package,
before => Package['scl-utils'],
}

package { 'scl-utils':
ensure => 'present',
before => Package['python'],
Expand All @@ -131,14 +134,10 @@
}
}

# This gets installed as a dependency anyway
# package { "${python::version}-python-virtualenv":
# ensure => $venv_ensure,
# require => Package['scl-utils'],
# }
package { "${python}-scldevel":
ensure => $dev_ensure,
}

if $pip_ensure != 'absent' {
exec { 'python-scl-pip-install':
command => "${python::exec_prefix}easy_install pip",
Expand All @@ -148,9 +147,10 @@
}
}
'rhscl': {
# rhscl is RedHat SCLs from softwarecollections.org
## rhscl is RedHat SCLs from softwarecollections.org
if $python::rhscl_use_public_repository {
$scl_package = "rhscl-${python::version}-epel-${facts['os']['release']['major']}-${facts['os']['architecture']}"

package { $scl_package:
source => "https://www.softwarecollections.org/en/scls/rhscl/${python::version}/epel-${facts['os']['release']['major']}-${facts['os']['architecture']}/download/${scl_package}.noarch.rpm",
provider => 'rpm',
Expand Down Expand Up @@ -181,8 +181,7 @@
-> Package <| tag == 'python-scl-package' |>
}

Package <| tag == 'python-scl-package' |>
-> Package <| tag == 'python-pip-package' |>
Package <| tag == 'python-scl-package' |> -> Package <| tag == 'python-pip-package' |>
}
'anaconda': {
$installer_path = '/var/tmp/anaconda_installer.sh'
Expand Down Expand Up @@ -217,6 +216,7 @@
}
}
}

if $pythondev {
package { 'python-dev':
ensure => $dev_ensure,
Expand All @@ -233,6 +233,7 @@
require => Package['python'],
}
}

if $pythondev {
package { 'python-dev':
ensure => $dev_ensure,
Expand All @@ -247,14 +248,22 @@
'RedHat': {
if $pip_ensure != 'absent' {
if $python::use_epel == true {
include 'epel'
if $python::manage_pip_package { Class['epel'] -> Package['pip'] }
if $python::manage_python_package { Class['epel'] -> Package['python'] }
include epel

if $python::manage_pip_package {
Class['epel'] -> Package['pip']
}

if $python::manage_python_package {
Class['epel'] -> Package['python']
}
}
}

if ($venv_ensure != 'absent') and ($facts['os']['release']['full'] =~ /^6/) {
if $python::use_epel == true {
include 'epel'
include epel

Class['epel'] -> Package['virtualenv']
}
}
Expand All @@ -278,19 +287,19 @@

if String($python::version) =~ /^python3/ {
$pip_category = undef
$pip_package = "${python}-pip"
$pip_package = "${python}-pip"
$pip_provider = $python.regsubst(/^.*python3\.?/,'pip3.').regsubst(/\.$/,'')
} elsif ($facts['os']['family'] == 'RedHat') and (versioncmp($facts['os']['release']['major'], '7') >= 0) {
$pip_category = undef
$pip_package = 'python2-pip'
$pip_package = 'python2-pip'
$pip_provider = pip2
} elsif $facts['os']['family'] == 'Gentoo' {
$pip_category = 'dev-python'
$pip_package = 'pip'
$pip_package = 'pip'
$pip_provider = 'pip'
} else {
$pip_category = undef
$pip_package = 'python-pip'
$pip_package = 'python-pip'
$pip_provider = 'pip'
}

Expand Down
53 changes: 26 additions & 27 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,32 @@
# The python Module default configuration settings.
#
class python::params {
$ensure = 'present'
$version = 'system'
$pip = 'present'
$dev = 'absent'
$virtualenv = 'absent'
$gunicorn = 'absent'
$manage_gunicorn = true
$manage_python_package = true
$manage_virtualenv_package = true
$manage_pip_package = true
$provider = undef
$valid_versions = undef
$manage_scl = true
## Module compatibility check
unless $facts['os']['family'] in [ 'Debian', 'RedHat', 'Suse', 'Gentoo', 'AIX', ] {
fail("Module is not compatible with ${facts['os']['name']}")
}

$ensure = 'present'
$version = 'system'
$pip = 'present'
$dev = 'absent'
$virtualenv = 'absent'
$gunicorn = 'absent'
$manage_gunicorn = true
$manage_python_package = true
$manage_virtualenv_package = true
$manage_pip_package = true
$provider = undef
$valid_versions = undef
$manage_scl = true
$rhscl_use_public_repository = true
$anaconda_installer_url = 'https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh'
$anaconda_install_path = '/opt/python'

if $facts['os']['family'] == 'RedHat' {
if $facts['os']['name'] != 'Fedora' {
$use_epel = true
} else {
$use_epel = false
}
if $facts['os']['family'] == 'RedHat' and $facts['os']['name'] != 'Fedora' {
$use_epel = true
} else {
$use_epel = false
$use_epel = false
}

$group = $facts['os']['family'] ? {
Expand All @@ -34,17 +38,12 @@
}

$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'] ? {
'RedHat' => 'python-gunicorn',
default => 'gunicorn',
}

$rhscl_use_public_repository = true

$anaconda_installer_url = 'https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh'
$anaconda_install_path = '/opt/python'
}
Loading

0 comments on commit 784386d

Please sign in to comment.