fix: check for python3_version
- check for python3 version before attempting to setup node_lookup
This commit is contained in:
parent
b6c7e3fd2d
commit
f9562a9109
@ -12,45 +12,54 @@ class profiles::helpers::node_lookup (
|
|||||||
Array[String[1]] $packages = ['requests'],
|
Array[String[1]] $packages = ['requests'],
|
||||||
){
|
){
|
||||||
|
|
||||||
# ensure the base_path exists
|
if $::facts['python3_version'] {
|
||||||
file { $base_path:
|
|
||||||
ensure => directory,
|
|
||||||
mode => '0755',
|
|
||||||
owner => $owner,
|
|
||||||
group => $group,
|
|
||||||
}
|
|
||||||
# create a venv
|
|
||||||
python::pyvenv { $venv_path :
|
|
||||||
ensure => present,
|
|
||||||
version => $version,
|
|
||||||
systempkgs => $systempkgs,
|
|
||||||
venv_dir => $venv_path,
|
|
||||||
owner => $owner,
|
|
||||||
group => $group,
|
|
||||||
require => File[$base_path],
|
|
||||||
}
|
|
||||||
|
|
||||||
# install the required pip packages
|
$python_version = $version ? {
|
||||||
$packages.each |String $package| {
|
'system' => $::facts['python3_version'],
|
||||||
python::pip { "${venv_path}_${package}":
|
default => $version,
|
||||||
|
}
|
||||||
|
|
||||||
|
# ensure the base_path exists
|
||||||
|
file { $base_path:
|
||||||
|
ensure => directory,
|
||||||
|
mode => '0755',
|
||||||
|
owner => $owner,
|
||||||
|
group => $group,
|
||||||
|
}
|
||||||
|
|
||||||
|
# create a venv
|
||||||
|
python::pyvenv { $venv_path :
|
||||||
ensure => present,
|
ensure => present,
|
||||||
pkgname => $package,
|
version => $python_version,
|
||||||
virtualenv => $venv_path,
|
systempkgs => $systempkgs,
|
||||||
|
venv_dir => $venv_path,
|
||||||
|
owner => $owner,
|
||||||
|
group => $group,
|
||||||
|
require => File[$base_path],
|
||||||
|
}
|
||||||
|
|
||||||
|
# install the required pip packages
|
||||||
|
$packages.each |String $package| {
|
||||||
|
python::pip { "${venv_path}_${package}":
|
||||||
|
ensure => present,
|
||||||
|
pkgname => $package,
|
||||||
|
virtualenv => $venv_path,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# create the script from a template
|
||||||
|
file { "${base_path}/${script_name}":
|
||||||
|
ensure => file,
|
||||||
|
mode => '0755',
|
||||||
|
content => template("profiles/helpers/${script_name}.erb"),
|
||||||
|
require => Python::Pyvenv[$venv_path],
|
||||||
|
}
|
||||||
|
|
||||||
|
# create symbolic link in $PATH
|
||||||
|
file { "/usr/local/bin/${script_name}":
|
||||||
|
ensure => 'link',
|
||||||
|
target => "${base_path}/${script_name}",
|
||||||
|
require => File["${base_path}/${script_name}"],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# create the script from a template
|
|
||||||
file { "${base_path}/${script_name}":
|
|
||||||
ensure => file,
|
|
||||||
mode => '0755',
|
|
||||||
content => template("profiles/helpers/${script_name}.erb"),
|
|
||||||
require => Python::Pyvenv[$venv_path],
|
|
||||||
}
|
|
||||||
|
|
||||||
# create symbolic link in $PATH
|
|
||||||
file { "/usr/local/bin/${script_name}":
|
|
||||||
ensure => 'link',
|
|
||||||
target => "${base_path}/${script_name}",
|
|
||||||
require => File["${base_path}/${script_name}"],
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user