diff --git a/REFERENCE.md b/REFERENCE.md index cb89ef55..dbc3463e 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -15,7 +15,6 @@ * `python::config`: Optionally installs the gunicorn service * `python::install`: Installs core python packages -* `python::params`: The python Module default configuration settings. ### Defined types @@ -83,6 +82,8 @@ The following parameters are available in the `python` class: * [`manage_dev_package`](#-python--manage_dev_package) * [`manage_venv_package`](#-python--manage_venv_package) * [`manage_pip_package`](#-python--manage_pip_package) +* [`group`](#-python--group) +* [`pip_lookup_path`](#-python--pip_lookup_path) * [`venv`](#-python--venv) * [`gunicorn_package_name`](#-python--gunicorn_package_name) * [`python_pips`](#-python--python_pips) @@ -170,7 +171,7 @@ Data type: `Boolean` to determine if the epel class is used. -Default value: `$python::params::use_epel` +Default value: `false` ##### `manage_scl` @@ -212,7 +213,7 @@ Data type: `Boolean` manage the state for package venv -Default value: `$python::params::manage_venv_package` +Default value: `true` ##### `manage_pip_package` @@ -220,7 +221,23 @@ Data type: `Boolean` manage the state for package pip -Default value: `$python::params::manage_pip_package` +Default value: `true` + +##### `group` + +Data type: `String[1]` + +The group owner of the virtulenv and dotfile + +Default value: `'root'` + +##### `pip_lookup_path` + +Data type: `Array` + +The paths used when bootstrapping pip + +Default value: `['/bin', '/usr/bin', '/usr/local/bin']` ##### `venv` @@ -236,7 +253,7 @@ Data type: `String[1]` -Default value: `$python::params::gunicorn_package_name` +Default value: `'gunicorn'` ##### `python_pips` @@ -422,7 +439,7 @@ Data type: `String[1]` group owner of dotfile -Default value: `getvar('python::params::group')` +Default value: `$python::group` ##### `config` @@ -771,7 +788,7 @@ Data type: `Optional[String[1]]` The group of the virtualenv being manipulated. -Default value: `getvar('python::params::group')` +Default value: `$python::group` ##### `index` diff --git a/data/os/AIX.yaml b/data/os/AIX.yaml new file mode 100644 index 00000000..55fceb36 --- /dev/null +++ b/data/os/AIX.yaml @@ -0,0 +1,6 @@ +python::group: system +python::pip_lookup_path: + - /bin + - /usr/bin + - /usr/local/bin + - /opt/freeware/bin/ diff --git a/data/os/Archlinux.yaml b/data/os/Archlinux.yaml index 3bd58ed5..c778b5b4 100644 --- a/data/os/Archlinux.yaml +++ b/data/os/Archlinux.yaml @@ -1 +1,3 @@ python::default_system_version: "3.13" +python::manage_pip_package: false +python::manage_venv_package: false diff --git a/data/os/Fedora.yaml b/data/os/Fedora.yaml new file mode 100644 index 00000000..2f257a8f --- /dev/null +++ b/data/os/Fedora.yaml @@ -0,0 +1 @@ +python::use_epel: false diff --git a/data/os/FreeBSD.yaml b/data/os/FreeBSD.yaml index 8d945465..0dc4a33e 100644 --- a/data/os/FreeBSD.yaml +++ b/data/os/FreeBSD.yaml @@ -1 +1,2 @@ +python::group: wheel python::default_system_version: "3.11" diff --git a/data/os/RedHat.yaml b/data/os/RedHat.yaml new file mode 100644 index 00000000..33ea3e52 --- /dev/null +++ b/data/os/RedHat.yaml @@ -0,0 +1,2 @@ +python::gunicorn_package_name: python3-gunicorn +python::use_epel: true diff --git a/manifests/dotfile.pp b/manifests/dotfile.pp index 06cd2d3a..1f487b60 100644 --- a/manifests/dotfile.pp +++ b/manifests/dotfile.pp @@ -26,7 +26,7 @@ Enum['absent', 'present'] $ensure = 'present', Stdlib::Absolutepath $filename = $title, String[1] $owner = 'root', - String[1] $group = getvar('python::params::group'), + String[1] $group = $python::group, Stdlib::Filemode $mode = '0644', Hash $config = {}, ) { diff --git a/manifests/init.pp b/manifests/init.pp index 31061daf..b2ead4fc 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -23,6 +23,8 @@ # @param manage_dev_package manage the state of the python development package # @param manage_venv_package manage the state for package venv # @param manage_pip_package manage the state for package pip +# @param group The group owner of the virtulenv and dotfile +# @param pip_lookup_path The paths used when bootstrapping pip # # @example install python from system python # class { 'python': @@ -49,20 +51,22 @@ Boolean $manage_gunicorn = true, Boolean $manage_python_package = true, Boolean $manage_dev_package = true, - Boolean $manage_venv_package = $python::params::manage_venv_package, - Boolean $manage_pip_package = $python::params::manage_pip_package, - String[1] $gunicorn_package_name = $python::params::gunicorn_package_name, + Boolean $manage_venv_package = true, + Boolean $manage_pip_package = true, + String[1] $gunicorn_package_name = 'gunicorn', Optional[Python::Provider] $provider = undef, Hash $python_pips = {}, Hash $python_pyvenvs = {}, Hash $python_requirements = {}, Hash $python_dotfiles = {}, - Boolean $use_epel = $python::params::use_epel, + Boolean $use_epel = false, Boolean $rhscl_use_public_repository = true, Stdlib::Httpurl $anaconda_installer_url = 'https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh', Stdlib::Absolutepath $anaconda_install_path = '/opt/python', Boolean $manage_scl = true, -) inherits python::params { + String[1] $group = 'root', + Array $pip_lookup_path = ['/bin', '/usr/bin', '/usr/local/bin'], +) { $exec_prefix = $provider ? { 'scl' => "/usr/bin/scl enable ${version} -- ", 'rhscl' => "/usr/bin/scl enable ${version} -- ", diff --git a/manifests/params.pp b/manifests/params.pp deleted file mode 100644 index 49bfdeac..00000000 --- a/manifests/params.pp +++ /dev/null @@ -1,45 +0,0 @@ -# @api private -# @summary The python Module default configuration settings. -# -# The python Module default configuration settings. -# -class python::params { - # Module compatibility check - unless $facts['os']['family'] in ['AIX', 'Debian', 'FreeBSD', 'Gentoo', 'RedHat', 'Suse', 'Archlinux'] { - fail("Module is not compatible with ${facts['os']['name']}") - } - - if $facts['os']['family'] == 'RedHat' and $facts['os']['name'] != 'Fedora' { - $use_epel = true - } else { - $use_epel = false - } - - $group = $facts['os']['family'] ? { - 'AIX' => 'system', - 'FreeBSD' => 'wheel', - default => 'root' - } - - $pip_lookup_path = $facts['os']['family'] ? { - 'AIX' => ['/bin', '/usr/bin', '/usr/local/bin', '/opt/freeware/bin/',], - default => ['/bin', '/usr/bin', '/usr/local/bin',] - } - - $gunicorn_package_name = $facts['os']['family'] ? { - 'RedHat' => $facts['os']['release']['major'] ? { - '7' => 'python-gunicorn', - default => 'python3-gunicorn', - }, - default => 'gunicorn', - } - - $manage_pip_package = $facts['os']['family'] ? { - 'Archlinux' => false, - default => true, - } - $manage_venv_package = $facts['os']['family'] ? { - 'Archlinux' => false, - default => true, - } -} diff --git a/manifests/pip.pp b/manifests/pip.pp index 99b05ad7..6a30c614 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -55,7 +55,7 @@ String[1] $pip_provider = 'pip', Variant[Boolean, String] $url = false, String[1] $owner = 'root', - Optional[String[1]] $group = getvar('python::params::group'), + Optional[String[1]] $group = $python::group, Optional[Python::Umask] $umask = undef, Variant[Boolean,String[1]] $index = false, Variant[Boolean,String[1]] $extra_index = false, diff --git a/manifests/pip/bootstrap.pp b/manifests/pip/bootstrap.pp index b060a6d0..e3f3187f 100644 --- a/manifests/pip/bootstrap.pp +++ b/manifests/pip/bootstrap.pp @@ -14,7 +14,7 @@ Variant[Boolean, String] $manage_python = false, Optional[Stdlib::HTTPUrl] $http_proxy = undef, String[1] $exec_provider = 'shell', -) inherits python::params { +) { if $manage_python { include python } else { @@ -36,7 +36,7 @@ command => '/usr/bin/curl https://bootstrap.pypa.io/get-pip.py | python3', environment => $environ, unless => 'which pip3', - path => $python::params::pip_lookup_path, + path => $python::pip_lookup_path, require => Package['python3'], provider => $exec_provider, } @@ -53,7 +53,7 @@ command => '/usr/bin/curl https://bootstrap.pypa.io/get-pip.py | python', environment => $environ, unless => 'which pip', - path => $python::params::pip_lookup_path, + path => $python::pip_lookup_path, require => Package['python'], provider => $exec_provider, } diff --git a/spec/classes/python_spec.rb b/spec/classes/python_spec.rb index fb68c521..5c6e7faf 100644 --- a/spec/classes/python_spec.rb +++ b/spec/classes/python_spec.rb @@ -13,7 +13,6 @@ context 'with defaults' do it { is_expected.to compile.with_all_deps } it { is_expected.to contain_class('python::install') } - it { is_expected.to contain_class('python::params') } it { is_expected.to contain_class('python::config') } it { is_expected.to contain_package('python') } diff --git a/spec/defines/pip_spec.rb b/spec/defines/pip_spec.rb index a00a7792..26f5fe78 100644 --- a/spec/defines/pip_spec.rb +++ b/spec/defines/pip_spec.rb @@ -5,6 +5,7 @@ # rubocop:disable RSpec/RepeatedExampleGroupDescription describe 'python::pip', type: :define do let(:title) { 'rpyc' } + let(:pre_condition) { 'include python' } context 'on Debian OS' do let :facts do @@ -213,6 +214,7 @@ describe 'python::pip', type: :define do # rubocop:enable RSpec/RepeatedExampleGroupDescription let(:title) { 'requests' } + let(:pre_condition) { 'include python' } context 'on Debian OS' do let :facts do diff --git a/spec/defines/requirements_spec.rb b/spec/defines/requirements_spec.rb index 82dc0b37..ff8ed7fe 100644 --- a/spec/defines/requirements_spec.rb +++ b/spec/defines/requirements_spec.rb @@ -47,7 +47,6 @@ it { is_expected.to compile.with_all_deps } it { is_expected.to contain_class('python::config') } it { is_expected.to contain_class('python::install') } - it { is_expected.to contain_class('python::params') } it { is_expected.to contain_class('python') } it { is_expected.to contain_exec('python_requirements/requirements.txt') }