Skip to content

Commit 81e3715

Browse files
authored
Merge pull request voxpupuli#440 from paychex/dev
Update modules with defined types for variables as described in docs/Add reference.md
2 parents eac8ea6 + a990c0b commit 81e3715

13 files changed

+1359
-790
lines changed

.DS_Store

6 KB
Binary file not shown.

README.md

+5-296
Original file line numberDiff line numberDiff line change
@@ -34,288 +34,13 @@ git submodule add https://github.com/stankevich/puppet-python.git /path/to/pytho
3434
OR
3535

3636
``` shell
37-
puppet module install stankevich-python
37+
puppet module install puppet-python
3838
```
3939

4040
## Usage
41-
42-
### python
43-
44-
Installs and manages python, python-pip, python-dev, python-virtualenv and Gunicorn.
45-
46-
**ensure** - Desired installation state for the Python package. Options are absent, present and latest. Default: present
47-
48-
**version** - Python version to install. Default: system
49-
50-
**pip** - Desired installation state for the python-pip package. Options are absent, present and latest. Default: present
51-
52-
**dev** - Desired installation state for the python-dev package. Options are absent, present and latest. Default: absent
53-
54-
**virtualenv** - Desired installation state for the virtualenv package. Options are absent, present and latest. Default: absent
55-
56-
**gunicorn** - Desired installation state for Gunicorn. Options are absent, present and latest. Default: absent
57-
58-
**manage_gunicorn** - Allow Installation / Removal of Gunicorn. Default: true
59-
60-
**use_epel** - Boolean to determine if the epel class is used. Default: true on RHEL like systems, false otherwise
61-
62-
*Install Python from system python*
63-
```puppet
64-
class { 'python' :
65-
version => 'system',
66-
pip => 'present',
67-
dev => 'absent',
68-
virtualenv => 'absent',
69-
gunicorn => 'absent',
70-
}
71-
```
72-
*Install Python 3 from the scl repo*
73-
```puppet
74-
class { 'python' :
75-
ensure => 'present',
76-
version => 'rh-python36-python',
77-
dev => 'present',
78-
virtualenv => 'present',
79-
}
80-
```
81-
82-
### python::pip
83-
84-
Installs and manages packages from pip.
85-
86-
**pkgname** - the name of the package to install. Required.
87-
88-
**ensure** - present/latest/absent. You can also specify the version. Default: present
89-
90-
**virtualenv** - virtualenv to run pip in. Default: system (no virtualenv)
91-
92-
**pip_provider** - pip provider to execute pip with. Default: pip.
93-
94-
**url** - URL to install from. Default: none
95-
96-
**owner** - The owner of the virtualenv to ensure that packages are installed with the correct permissions (must be specified). Default: root
97-
98-
**proxy** - Proxy server to use for outbound connections. Default: none
99-
100-
**environment** - Additional environment variables required to install the packages. Default: none
101-
102-
**extras** - Extra features provided by the package which should be installed. Default: none
103-
104-
**egg** - The egg name to use. Default: `$name` of the class, e.g. cx_Oracle
105-
106-
**install_args** - String of additional flags to pass to pip during installaton. Default: none
107-
108-
**uninstall_args** - String of additional flags to pass to pip during uninstall. Default: none
109-
110-
**timeout** - Timeout for the pip install command. Defaults to 1800.
111-
112-
*Install cx_Oracle with pip*
113-
```puppet
114-
python::pip { 'cx_Oracle' :
115-
pkgname => 'cx_Oracle',
116-
ensure => '5.1.2',
117-
virtualenv => '/var/www/project1',
118-
owner => 'appuser',
119-
proxy => 'http://proxy.domain.com:3128',
120-
environment => 'ORACLE_HOME=/usr/lib/oracle/11.2/client64',
121-
install_args => '-e',
122-
timeout => 1800,
123-
}
124-
```
125-
*Install Requests with pip3*
126-
```puppet
127-
python::pip { 'requests' :
128-
ensure => 'present',
129-
pkgname => 'requests',
130-
pip_provider => 'pip3',
131-
virtualenv => '/var/www/project1',
132-
owner => 'root',
133-
timeout => 1800
134-
}
135-
```
136-
137-
### python::requirements
138-
139-
Installs and manages Python packages from requirements file.
140-
141-
**virtualenv** - virtualenv to run pip in. Default: system-wide
142-
143-
**proxy** - Proxy server to use for outbound connections. Default: none
144-
145-
**owner** - The owner of the virtualenv to ensure that packages are installed with the correct permissions (must be specified). Default: root
146-
147-
**src** - The `--src` parameter to `pip`, used to specify where to install `--editable` resources; by default no `--src` parameter is passed to `pip`.
148-
149-
**group** - The group that was used to create the virtualenv. This is used to create the requirements file with correct permissions if it's not present already.
150-
151-
**manage_requirements** - Create the requirements file if it doesn't exist. Default: true
152-
153-
```puppet
154-
python::requirements { '/var/www/project1/requirements.txt' :
155-
virtualenv => '/var/www/project1',
156-
proxy => 'http://proxy.domain.com:3128',
157-
owner => 'appuser',
158-
group => 'apps',
159-
}
160-
```
161-
162-
### python::virtualenv
163-
164-
Creates Python virtualenv.
165-
166-
**ensure** - present/absent. Default: present
167-
168-
**version** - Python version to use. Default: system default
169-
170-
**requirements** - Path to pip requirements.txt file. Default: none
171-
172-
**systempkgs** - Copy system site-packages into virtualenv. Default: don't
173-
174-
**venv_dir** - The location of the virtualenv if resource path not specified. Must be absolute path. Default: resource name
175-
176-
**ensure_venv_dir** - Create virtualenv directory. Default: true
177-
178-
**distribute** - Include distribute in the virtualenv. Default: true
179-
180-
**index** - Base URL of Python package index. Default: none
181-
182-
**owner** - Specify the owner of this virtualenv
183-
184-
**group** - Specify the group for this virtualenv
185-
186-
**mode** - Specify the directory mode. Default: 0755
187-
188-
**proxy** - Proxy server to use for outbound connections. Default: none
189-
190-
**environment** - Additional environment variables required to install the packages. Default: none
191-
192-
**path** - Set the $PATH environment variable. Default: [ '/bin', '/usr/bin', '/usr/sbin' ]
193-
194-
**cwd** - The directory from which to run the "pip install" command. Default: undef
195-
196-
**timeout** - The maximum time in seconds the "pip install" command should take. Default: 1800
197-
198-
**pip_args** - Arguments to pass to pip during installation. Default: blank
199-
200-
**extra_pip_args** - Arguments to pass to pip for package install. These are included in the pip command *after* the requirements file. Default: blank
201-
202-
```puppet
203-
python::virtualenv { '/var/www/project1' :
204-
ensure => present,
205-
version => 'system',
206-
requirements => '/var/www/project1/requirements.txt',
207-
systempkgs => true,
208-
venv_dir => '/home/appuser/virtualenvs',
209-
ensure_venv_dir => false,
210-
distribute => false,
211-
index => 'appuser',
212-
owner => 'appuser',
213-
group => 'apps',
214-
proxy => 'http://proxy.domain.com:3128',
215-
cwd => '/var/www/project1',
216-
timeout => 0,
217-
extra_pip_args => '--no-binary :none:',
218-
}
219-
```
220-
221-
### python::pyvenv
222-
223-
Creates Python3 virtualenv.
224-
225-
**ensure** - present/absent. Default: present
226-
227-
**version** - Python version to use. Default: system default
228-
229-
**systempkgs** - Copy system site-packages into virtualenv. Default: don't
230-
231-
**venv_dir** - The location of the virtualenv if resource path not specified. Must be absolute path. Default: resource name
232-
233-
**owner** - Specify the owner of this virtualenv
234-
235-
**group** - Specify the group for this virtualenv
236-
237-
**path** - Specifies the PATH variable that contains `pyvenv` executable. Default: [ '/bin', '/usr/bin', '/usr/sbin' ]
238-
239-
**environment** - Specify any environment variables to use when creating pyvenv
240-
241-
```puppet
242-
python::pyvenv { '/var/www/project1' :
243-
ensure => present,
244-
version => 'system',
245-
systempkgs => true,
246-
venv_dir => '/home/appuser/virtualenvs',
247-
owner => 'appuser',
248-
group => 'apps',
249-
}
250-
```
251-
252-
### python::gunicorn
253-
254-
Manages Gunicorn virtual hosts.
255-
256-
**ensure** - present/absent. Default: present
257-
258-
**virtualenv** - Run in virtualenv, specify directory. Default: disabled
259-
260-
**mode** - Gunicorn mode. wsgi/django. Default: wsgi
261-
262-
**dir** - Application directory.
263-
264-
**bind** - Bind on: 'HOST', 'HOST:PORT', 'unix:PATH'. Default: `unix:/tmp/gunicorn-$name.socket` or `unix:${virtualenv}/${name}.socket`
265-
266-
**environment** - Set ENVIRONMENT variable. Default: none
267-
268-
**appmodule** - Set the application module name for gunicorn to load when not using Django. Default: `app:app`
269-
270-
**osenv** - Allows setting environment variables for the gunicorn service. Accepts a hash of 'key': 'value' pairs. Default: false
271-
272-
**timeout** - Allows setting the gunicorn idle worker process time before being killed. The unit of time is seconds. Default: 30
273-
274-
**template** - Which ERB template to use. Default: python/gunicorn.erb
275-
276-
```puppet
277-
python::gunicorn { 'vhost' :
278-
ensure => present,
279-
virtualenv => '/var/www/project1',
280-
mode => 'wsgi',
281-
dir => '/var/www/project1/current',
282-
bind => 'unix:/tmp/gunicorn.socket',
283-
environment => 'prod',
284-
appmodule => 'app:app',
285-
osenv => { 'DBHOST' => 'dbserver.example.com' },
286-
timeout => 30,
287-
template => 'python/gunicorn.erb',
288-
}
289-
```
290-
291-
### python::dotfile
292-
293-
Manages arbitrary python dotiles with a simple config hash.
294-
295-
**ensure** - present/absent. Default: present
296-
297-
**filename** - Default: $title
298-
299-
**mode** - Default: 0644
300-
301-
**owner** - Default: root
302-
303-
**group** - Default: root
304-
305-
**config** Config hash. This will be expanded to an ini-file. Default: {}
306-
307-
```puppet
308-
python::dotfile { '/var/lib/jenkins/.pip/pip.conf':
309-
ensure => present,
310-
owner => 'jenkins',
311-
group => 'jenkins',
312-
config => {
313-
'global' => {
314-
'index-url => 'https://mypypi.acme.com/simple/'
315-
'extra-index-url => https://pypi.risedev.at/simple/
316-
}
317-
}
318-
}
41+
For class usage refer to the [Reference]("https://github.com/voxpupuli/puppet-python/blob/master/REFERENCE.md). If contributing, this is updated with
42+
```shell
43+
bundle exec rake strings:generate\[',,,,false,true']
31944
```
32045

32146
### hiera configuration
@@ -351,23 +76,7 @@ of the collection you want to use (e.g., 'python27', 'python33', or 'rh-python34
35176
35277
## Release Notes
35378
354-
**Version 1.9.8 Notes**
355-
The `pip`, `virtualenv` and `gunicorn` parameters of `Class['python']` have changed. These parameters now accept `absent`, `present` and `latest` rather than `true` and `false`. The boolean values are still supported and are equivalent to `present` and `absent` respectively. Support for these boolean parameters is deprecated and will be removed in a later release.
356-
357-
**Version 1.7.10 Notes**
358-
359-
Installation of python-pip previously defaulted to `false` and was not installed. This default is now `true` and python-pip is installed. To prevent the installation of python-pip specify `pip => false` as a parameter when instantiating the `python` puppet class.
360-
361-
**Version 1.1.x Notes**
362-
363-
Version `1.1.x` makes several fundamental changes to the core of this module, adding some additional features, improving performance and making operations more robust in general.
364-
365-
Please note that several changes have been made in `v1.1.x` which make manifests incompatible with the previous version. However, modifying your manifests to suit is trivial. Please see the notes below.
366-
367-
Currently, the changes you need to make are as follows:
368-
369-
* All pip definitions MUST include the owner field which specifies which user owns the virtualenv that packages will be installed in. Adding this greatly improves performance and efficiency of this module.
370-
* You must explicitly specify pip => true in the python class if you want pip installed. As such, the pip package is now independent of the dev package and so one can exist without the other.
79+
See [Changelog](https://github.com/voxpupuli/puppet-python/blob/master/CHANGELOG.md)
37180
37281
## Contributors
37382

0 commit comments

Comments
 (0)