Skip to content

Commit 5ccfca4

Browse files
committed
Prefer Hiera data to params.pp
This limit the quantity of spaghetti code we add when adding support for another platform. No functional change.
1 parent 448fcab commit 5ccfca4

File tree

17 files changed

+75
-85
lines changed

17 files changed

+75
-85
lines changed

REFERENCE.md

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
* `python::config`: Optionally installs the gunicorn service
1717
* `python::install`: Installs core python packages
18-
* `python::params`: The python Module default configuration settings.
1918

2019
### Defined types
2120

@@ -81,8 +80,8 @@ The following parameters are available in the `python` class:
8180
* [`manage_python_package`](#-python--manage_python_package)
8281
* [`manage_venv_package`](#-python--manage_venv_package)
8382
* [`manage_pip_package`](#-python--manage_pip_package)
84-
* [`venv`](#-python--venv)
8583
* [`gunicorn_package_name`](#-python--gunicorn_package_name)
84+
* [`venv`](#-python--venv)
8685
* [`python_pips`](#-python--python_pips)
8786
* [`python_pyvenvs`](#-python--python_pyvenvs)
8887
* [`python_requirements`](#-python--python_requirements)
@@ -112,8 +111,6 @@ Allowed values:
112111
- 3/3.3/... means you are going to install the python3/python3.3/...
113112
package, if available on your osfamily.
114113

115-
Default value: `$facts['os']['family'] ? { 'Archlinux' => 'system', default => '3'`
116-
117114
##### <a name="-python--pip"></a>`pip`
118115

119116
Data type: `Python::Package::Ensure`
@@ -160,8 +157,6 @@ Data type: `Boolean`
160157

161158
to determine if the epel class is used.
162159

163-
Default value: `$python::params::use_epel`
164-
165160
##### <a name="-python--manage_scl"></a>`manage_scl`
166161

167162
Data type: `Boolean`
@@ -198,31 +193,25 @@ Data type: `Boolean`
198193

199194
manage the state for package venv
200195

201-
Default value: `$python::params::manage_venv_package`
202-
203196
##### <a name="-python--manage_pip_package"></a>`manage_pip_package`
204197

205198
Data type: `Boolean`
206199

207200
manage the state for package pip
208201

209-
Default value: `$python::params::manage_pip_package`
210-
211-
##### <a name="-python--venv"></a>`venv`
212-
213-
Data type: `Python::Package::Ensure`
202+
##### <a name="-python--gunicorn_package_name"></a>`gunicorn_package_name`
214203

204+
Data type: `String[1]`
215205

216206

217-
Default value: `'absent'`
218207

219-
##### <a name="-python--gunicorn_package_name"></a>`gunicorn_package_name`
208+
##### <a name="-python--venv"></a>`venv`
220209

221-
Data type: `String[1]`
210+
Data type: `Python::Package::Ensure`
222211

223212

224213

225-
Default value: `$python::params::gunicorn_package_name`
214+
Default value: `'absent'`
226215

227216
##### <a name="-python--python_pips"></a>`python_pips`
228217

@@ -301,6 +290,7 @@ The following parameters are available in the `python::pip::bootstrap` class:
301290
* [`version`](#-python--pip--bootstrap--version)
302291
* [`manage_python`](#-python--pip--bootstrap--manage_python)
303292
* [`http_proxy`](#-python--pip--bootstrap--http_proxy)
293+
* [`pip_lookup_path`](#-python--pip--bootstrap--pip_lookup_path)
304294
* [`exec_provider`](#-python--pip--bootstrap--exec_provider)
305295

306296
##### <a name="-python--pip--bootstrap--version"></a>`version`
@@ -327,6 +317,12 @@ Proxy server to use for outbound connections.
327317

328318
Default value: `undef`
329319

320+
##### <a name="-python--pip--bootstrap--pip_lookup_path"></a>`pip_lookup_path`
321+
322+
Data type: `Array[String[1]]`
323+
324+
325+
330326
##### <a name="-python--pip--bootstrap--exec_provider"></a>`exec_provider`
331327

332328
Data type: `String[1]`
@@ -753,12 +749,10 @@ Default value: `'root'`
753749

754750
##### <a name="-python--pip--group"></a>`group`
755751

756-
Data type: `Optional[String[1]]`
752+
Data type: `String[1]`
757753

758754
The group of the virtualenv being manipulated.
759755

760-
Default value: `getvar('python::params::group')`
761-
762756
##### <a name="-python--pip--index"></a>`index`
763757

764758
Data type: `Variant[Boolean,String[1]]`

data/common.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
python::version: '3'
3+
python::use_epel: true
4+
python::gunicorn_package_name: 'gunicorn'
5+
python::manage_pip_package: true
6+
python::manage_venv_package: true
7+
python::pip::group: 'root'
8+
python::pip::bootstrap::pip_lookup_path:
9+
- /bin
10+
- /usr/bin
11+
- /usr/local/bin

data/os/AIX.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
python::pip::group: 'system'
3+
python::pip::bootstrap::pip_lookup_path:
4+
- /bin
5+
- /usr/bin
6+
- /usr/local/bin
7+
- /opt/freeware/bin/

data/os/Archlinux.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
python::version: 'system'
3+
python::manage_pip_package: false
4+
python::manage_venv_package: false

data/os/RedHat.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
python::use_epel: true
3+
python::gunicorn_package_name: 'python-gunicorn'

data/os/RedHat/CentOS/8.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
python::gunicorn_package_name: 'python3-gunicorn'

data/os/RedHat/Fedora.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
python::use_epel: false

data/os/RedHat/RedHat/8.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
python::gunicorn_package_name: 'python3-gunicorn'

hiera.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
version: 5
3+
4+
defaults:
5+
datadir: 'data'
6+
data_hash: 'yaml_data'
7+
8+
hierarchy:
9+
- name: 'family/name/major'
10+
path: 'os/%{facts.os.family}/%{facts.os.name}/%{facts.os.release.major}.yaml'
11+
12+
- name: 'family/name'
13+
path: 'os/%{facts.os.family}/%{facts.os.name}.yaml'
14+
15+
- name: 'family'
16+
path: 'os/%{facts.os.family}.yaml'
17+
18+
- name: 'common'
19+
path: 'common.yaml'

manifests/init.pp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,29 @@
3737
# }
3838
#
3939
class python (
40+
Python::Version $version,
41+
Boolean $manage_venv_package,
42+
Boolean $manage_pip_package,
43+
String[1] $gunicorn_package_name,
44+
Boolean $use_epel,
4045
Python::Package::Ensure $ensure = 'present',
41-
Python::Version $version = $facts['os']['family'] ? { 'Archlinux' => 'system', default => '3' },
4246
Python::Package::Ensure $pip = 'present',
4347
Python::Package::Ensure $dev = 'absent',
4448
Python::Package::Ensure $venv = 'absent',
4549
Python::Package::Ensure $gunicorn = 'absent',
4650
Boolean $manage_gunicorn = true,
4751
Boolean $manage_python_package = true,
48-
Boolean $manage_venv_package = $python::params::manage_venv_package,
49-
Boolean $manage_pip_package = $python::params::manage_pip_package,
50-
String[1] $gunicorn_package_name = $python::params::gunicorn_package_name,
5152
Optional[Python::Provider] $provider = undef,
5253
Hash $python_pips = {},
5354
Hash $python_pyvenvs = {},
5455
Hash $python_requirements = {},
5556
Hash $python_dotfiles = {},
56-
Boolean $use_epel = $python::params::use_epel,
5757
Boolean $rhscl_use_public_repository = true,
5858
Stdlib::Httpurl $anaconda_installer_url = 'https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh',
5959
Stdlib::Absolutepath $anaconda_install_path = '/opt/python',
6060
Boolean $manage_scl = true,
6161
Optional[Python::Umask] $umask = undef,
62-
) inherits python::params {
62+
) {
6363
$exec_prefix = $provider ? {
6464
'scl' => "/usr/bin/scl enable ${version} -- ",
6565
'rhscl' => "/usr/bin/scl enable ${version} -- ",

0 commit comments

Comments
 (0)