comparison modules/python/manifests/requirements.pp @ 387:66c075c5f54a

Update to newer Python module
author IBBoard <dev@ibboard.co.uk>
date Mon, 03 Jan 2022 17:13:06 +0000
parents c42fb28cff86
children adf6fe9bbc17
comparison
equal deleted inserted replaced
386:3fce34f642f1 387:66c075c5f54a
8 # @param group The group relating to the virtualenv being manipulated. 8 # @param group The group relating to the virtualenv being manipulated.
9 # @param proxy Proxy server to use for outbound connections. 9 # @param proxy Proxy server to use for outbound connections.
10 # @param src Pip --src parameter to; if the requirements file contains --editable resources, this parameter specifies where they will be installed. See the pip documentation for more. 10 # @param src Pip --src parameter to; if the requirements file contains --editable resources, this parameter specifies where they will be installed. See the pip documentation for more.
11 # @param environment Additional environment variables required to install the packages. 11 # @param environment Additional environment variables required to install the packages.
12 # @param forceupdate Run a pip install requirements even if we don't receive an event from the requirements file - Useful for when the requirements file is written as part of a resource other than file (E.g vcsrepo) 12 # @param forceupdate Run a pip install requirements even if we don't receive an event from the requirements file - Useful for when the requirements file is written as part of a resource other than file (E.g vcsrepo)
13 # @param cwd The directory from which to run the "pip install" command. 13 # @param cwd The directory from which to run the "pip install" command.
14 # @param extra_pip_args Extra arguments to pass to pip after the requirements file 14 # @param extra_pip_args Extra arguments to pass to pip after the requirements file
15 # @param manage_requirements Create the requirements file if it doesn't exist. 15 # @param manage_requirements Create the requirements file if it doesn't exist.
16 # @param fix_requirements_owner Change owner and group of requirements file. 16 # @param fix_requirements_owner Change owner and group of requirements file.
17 # @param log_dir Log directory. 17 # @param log_dir Log directory.
18 # @param timeout The maximum time in seconds the "pip install" command should take. 18 # @param timeout The maximum time in seconds the "pip install" command should take.
24 # owner => 'appuser', 24 # owner => 'appuser',
25 # group => 'apps', 25 # group => 'apps',
26 # } 26 # }
27 # 27 #
28 define python::requirements ( 28 define python::requirements (
29 $requirements = $name, 29 Stdlib::Absolutepath $requirements = $name,
30 $virtualenv = 'system', 30 Variant[Enum['system'],Stdlib::Absolutepath] $virtualenv = 'system',
31 Enum['pip', 'pip3'] $pip_provider = 'pip', 31 Enum['pip', 'pip3'] $pip_provider = 'pip',
32 $owner = 'root', 32 String[1] $owner = 'root',
33 $group = 'root', 33 String[1] $group = 'root',
34 Optional[Stdlib::HTTPUrl] $proxy = undef, 34 Optional[Stdlib::HTTPUrl] $proxy = undef,
35 $src = false, 35 Any $src = false,
36 $environment = [], 36 Array $environment = [],
37 $forceupdate = false, 37 Boolean $forceupdate = false,
38 $cwd = undef, 38 Optional[Stdlib::Absolutepath] $cwd = undef,
39 $extra_pip_args = '', 39 Optional[String[1]] $extra_pip_args = undef,
40 $manage_requirements = true, 40 Boolean $manage_requirements = true,
41 $fix_requirements_owner = true, 41 Boolean $fix_requirements_owner = true,
42 $log_dir = '/tmp', 42 Stdlib::Absolutepath $log_dir = '/tmp',
43 $timeout = 1800, 43 Integer $timeout = 1800,
44 ) { 44 ) {
45
46 include python 45 include python
47 46
48 if $virtualenv == 'system' and ($owner != 'root' or $group != 'root') { 47 if $virtualenv == 'system' and ($owner != 'root' or $group != 'root') {
49 fail('python::pip: root user must be used when virtualenv is system') 48 fail('python::pip: root user must be used when virtualenv is system')
50 } 49 }
79 78
80 # This will ensure multiple python::virtualenv definitions can share the 79 # This will ensure multiple python::virtualenv definitions can share the
81 # the same requirements file. 80 # the same requirements file.
82 if !defined(File[$requirements]) and $manage_requirements == true { 81 if !defined(File[$requirements]) and $manage_requirements == true {
83 file { $requirements: 82 file { $requirements:
84 ensure => present, 83 ensure => file,
85 mode => '0644', 84 mode => '0644',
86 owner => $owner_real, 85 owner => $owner_real,
87 group => $group_real, 86 group => $group_real,
88 audit => content, 87 audit => content,
89 replace => false, 88 replace => false,
90 content => '# Puppet will install and/or update pip packages listed here', 89 content => '# Puppet will install and/or update pip packages listed here',
91 } 90 }
91
92 $local_subscribe = File[$requirements] 92 $local_subscribe = File[$requirements]
93 } else { 93 } else {
94 $local_subscribe = undef 94 $local_subscribe = undef
95 } 95 }
96 96