add pip support and some docs
This commit is contained in:
parent
50614b4407
commit
3574eac7f6
5 changed files with 63 additions and 33 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
__pycache__
|
||||
52
README.md
52
README.md
|
|
@ -1,43 +1,39 @@
|
|||
# Packages
|
||||
|
||||
## Supported
|
||||
Handels package management using system and language specific package tools
|
||||
|
||||
Only Apt and Debian Stretch.
|
||||
## Defaults
|
||||
|
||||
Other versions might work but are not tested.
|
||||
```
|
||||
# sets the default for packages.pkg , see *pkg*
|
||||
default_packages_pkg:
|
||||
provider: system
|
||||
```
|
||||
|
||||
## Parameters and defaults
|
||||
|
||||
packages:
|
||||
pkg: {}
|
||||
repos: {}
|
||||
## Parameters
|
||||
|
||||
All configuration is to be placed inside the `packages` dict.
|
||||
|
||||
```
|
||||
# dictionary of package names to install. The key is the name of the packages, value musst be != none as none is used as knock out.
|
||||
pkg: {}
|
||||
# name: *pkg*, see below for definition
|
||||
pkg:
|
||||
|
||||
# dictionary of repositories to setup, the key is used as name for the repository. See **repo** for definition for the content
|
||||
repos: {}
|
||||
# name: *repo*, see below for definition
|
||||
repos:
|
||||
|
||||
```
|
||||
|
||||
**pkg**:
|
||||
```
|
||||
# can be "system" or "pip-system"
|
||||
provider: system
|
||||
```
|
||||
|
||||
**repo**:
|
||||
```
|
||||
# url to repo, example: "http://www.deb-multimedia.org stretch main non-free"
|
||||
url: ''
|
||||
|
||||
# only set either key, keyurl or keyid + keyserver
|
||||
|
||||
# gpg key to add for this repo
|
||||
key: ''
|
||||
|
||||
# url to download a gpg key for this repo from
|
||||
keyurl: ''
|
||||
|
||||
# key id of the key to add, for example "36A1D7869245C8950F966E92D8576A8BA88D21E9"
|
||||
keyid: ''
|
||||
|
||||
# key server to get the key from, for example "keyserver.ubuntu.com"
|
||||
keyserver:
|
||||
key:
|
||||
keyid:
|
||||
keyurl:
|
||||
keyurl:
|
||||
url:
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
packages:
|
||||
pkg: {}
|
||||
repos: {}
|
||||
|
||||
default_packages_pkg:
|
||||
provider: system
|
||||
|
|
|
|||
20
filter_plugins/packages_filters.py
Executable file
20
filter_plugins/packages_filters.py
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env python3
|
||||
class FilterModule(object):
|
||||
def filters(self):
|
||||
return {
|
||||
'packages_by_provider': self.packages_by_provider
|
||||
}
|
||||
|
||||
def packages_by_provider(self, packages, provider, defaults=False):
|
||||
filtered_packages = []
|
||||
for key, value in packages.items():
|
||||
if value == None:
|
||||
continue
|
||||
if defaults:
|
||||
package = dict(defaults)
|
||||
package.update(dict(value))
|
||||
else:
|
||||
package = dict(value)
|
||||
if package['provider'] == provider:
|
||||
filtered_packages.append(key)
|
||||
return filtered_packages
|
||||
|
|
@ -1,14 +1,19 @@
|
|||
- name: filter package list
|
||||
set_fact:
|
||||
pkgs: "{{ packages.pkg | dict2items | rejectattr('value', 'none') | map(attribute='key') | list }}"
|
||||
pkgs_system: "{{ packages.pkg | packages_by_provider(provider='system', defaults=default_packages_pkg) }}"
|
||||
pkgs_pip_system: "{{ packages.pkg | packages_by_provider(provider='pip-system', defaults=default_packages_pkg) }}"
|
||||
|
||||
- name: list repositories to setup
|
||||
debug:
|
||||
var: packages.repos
|
||||
verbosity: 1
|
||||
- name: list packages to install
|
||||
- name: list system packages to install
|
||||
debug:
|
||||
var: pkgs
|
||||
var: pkgs_system
|
||||
verbosity: 1
|
||||
- name: list pip packages to install
|
||||
debug:
|
||||
var: pkgs_pip_system
|
||||
verbosity: 1
|
||||
|
||||
- name: install helper tools
|
||||
|
|
@ -33,6 +38,11 @@
|
|||
- name: ensure handlers are flushed
|
||||
meta: flush_handlers
|
||||
|
||||
- name: install packages
|
||||
- name: install packages (system)
|
||||
apt:
|
||||
pkg: "{{ pkgs }}"
|
||||
pkg: "{{ pkgs_system }}"
|
||||
|
||||
- name: install packages (pip-system)
|
||||
pip:
|
||||
name: "{{ pkgs_pip_system }}"
|
||||
extra_args: "--break-system-packages"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue