edd-tool 0.2.0__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {edd_tool-0.2.0/src/edd_tool.egg-info → edd_tool-0.2.2}/PKG-INFO +52 -7
- edd_tool-0.2.2/README.md +98 -0
- {edd_tool-0.2.0 → edd_tool-0.2.2}/pyproject.toml +7 -1
- {edd_tool-0.2.0 → edd_tool-0.2.2}/src/edd_tool/cli.py +175 -17
- {edd_tool-0.2.0 → edd_tool-0.2.2}/src/edd_tool/data/edd-tool.rc.template +1 -1
- {edd_tool-0.2.0 → edd_tool-0.2.2/src/edd_tool.egg-info}/PKG-INFO +52 -7
- edd_tool-0.2.0/README.md +0 -57
- {edd_tool-0.2.0 → edd_tool-0.2.2}/LICENSE +0 -0
- {edd_tool-0.2.0 → edd_tool-0.2.2}/setup.cfg +0 -0
- {edd_tool-0.2.0 → edd_tool-0.2.2}/src/edd_tool/__init__.py +0 -0
- {edd_tool-0.2.0 → edd_tool-0.2.2}/src/edd_tool/data/__init__.py +0 -0
- {edd_tool-0.2.0 → edd_tool-0.2.2}/src/edd_tool.egg-info/SOURCES.txt +0 -0
- {edd_tool-0.2.0 → edd_tool-0.2.2}/src/edd_tool.egg-info/dependency_links.txt +0 -0
- {edd_tool-0.2.0 → edd_tool-0.2.2}/src/edd_tool.egg-info/entry_points.txt +0 -0
- {edd_tool-0.2.0 → edd_tool-0.2.2}/src/edd_tool.egg-info/requires.txt +0 -0
- {edd_tool-0.2.0 → edd_tool-0.2.2}/src/edd_tool.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: edd-tool
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: EDD deployment and plugin management tool
|
|
5
5
|
Author-email: Ewan Barr <ebarr@mpifr-bonn.mpg.de>
|
|
6
6
|
License: Copyright 2025 Ewan Barr
|
|
@@ -11,6 +11,10 @@ License: Copyright 2025 Ewan Barr
|
|
|
11
11
|
|
|
12
12
|
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
13
13
|
|
|
14
|
+
Project-URL: Homepage, https://gitlab.mpcdf.mpg.de/mpifr-bdg/edd_installer
|
|
15
|
+
Project-URL: Documentation, https://gitlab.mpcdf.mpg.de/mpifr-bdg/edd_installer
|
|
16
|
+
Project-URL: Repository, https://gitlab.mpcdf.mpg.de/mpifr-bdg/edd_installer.git
|
|
17
|
+
Project-URL: Bug Tracker, https://gitlab.mpcdf.mpg.de/mpifr-bdg/edd_installer/issues
|
|
14
18
|
Requires-Python: >=3.11
|
|
15
19
|
Description-Content-Type: text/markdown
|
|
16
20
|
License-File: LICENSE
|
|
@@ -48,29 +52,70 @@ edd-tool --help
|
|
|
48
52
|
## Basic usage
|
|
49
53
|
|
|
50
54
|
```
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
[--
|
|
54
|
-
|
|
55
|
+
$ edd-tool deploy --h
|
|
56
|
+
usage: edd-tool deploy [-h] [--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [--site-repo SITE_REPO] [--version VERSION]
|
|
57
|
+
[--deploy-dir DEPLOY_DIR] [--inventory INVENTORY] [--vault-pass-file VAULT_PASS_FILE]
|
|
58
|
+
[--site-config SITE_CONFIG] [--plugin-install-method {galaxy,git-submodule}] [--no-pullremote] [--force]
|
|
59
|
+
[--dry-run] [--ansible-args ANSIBLE_ARGS]
|
|
60
|
+
[config_profile]
|
|
55
61
|
|
|
56
62
|
positional arguments:
|
|
57
|
-
|
|
63
|
+
config_profile Optional profile name from ~/.edd-tool.rc (e.g. 'production', 'devel')
|
|
58
64
|
|
|
59
65
|
options:
|
|
60
66
|
-h, --help show this help message and exit
|
|
61
67
|
--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
|
|
62
68
|
Set the logging level (default: INFO)
|
|
69
|
+
--site-repo SITE_REPO
|
|
70
|
+
Git URL of the EDD site repository
|
|
63
71
|
--version VERSION Branch or tag for the site repository
|
|
64
72
|
--deploy-dir DEPLOY_DIR
|
|
65
73
|
Deployment directory
|
|
66
74
|
--inventory INVENTORY
|
|
67
75
|
Ansible inventory path (file, dir, or script)
|
|
68
76
|
--vault-pass-file VAULT_PASS_FILE
|
|
69
|
-
Path to vault password file
|
|
77
|
+
Path to vault password file (defaults to $ANSIBLE_VAULT_PASSWORD_FILE if set)
|
|
70
78
|
--site-config SITE_CONFIG
|
|
71
79
|
Path to site configuration YAML
|
|
72
80
|
--plugin-install-method {galaxy,git-submodule}
|
|
73
81
|
--no-pullremote Skip pullremote tag
|
|
74
82
|
--force Force overwrite of deployment directory
|
|
75
83
|
--dry-run Dry run the deployment
|
|
84
|
+
--ansible-args ANSIBLE_ARGS
|
|
85
|
+
Quoted string of extra ansible-playbook args
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Deployment profiles
|
|
89
|
+
|
|
90
|
+
To simplify the deployment interface it is possible to define deployment profiles in the `~/.edd-tool.rc` configuration file.
|
|
91
|
+
This will be used to set the default values for CLI arguments. For example `~/.edd-tool.rc` might contain:
|
|
92
|
+
|
|
93
|
+
```YAML
|
|
94
|
+
## Example ~/.edd-tool.rc
|
|
95
|
+
## Define reusable deployment profiles here
|
|
96
|
+
## Uncomment and update the profiles below to get started
|
|
97
|
+
|
|
98
|
+
production:
|
|
99
|
+
site_config: production_config.yml
|
|
100
|
+
site_repo: https://gitlab.com/site-repos/my-telescope-site.git
|
|
101
|
+
inventory: production
|
|
102
|
+
vault-pass-file: ~/.edd/production.pwd
|
|
103
|
+
|
|
104
|
+
development:
|
|
105
|
+
site_config: development_config.yml
|
|
106
|
+
site_repo: https://gitlab.com/site-repos/my-telescope-site.git
|
|
107
|
+
inventory: development
|
|
108
|
+
vault-pass-file: ~/.edd/development.pwd
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The name of a profile can be passed as a positional argument to the `deploy` command of `edd-tool`:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
edd-tool deploy development --force --version 250915.0
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
or
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
edd-tool deploy production --dry-run --force --version 250915.0
|
|
76
121
|
```
|
edd_tool-0.2.2/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# EDD Tool
|
|
2
|
+
|
|
3
|
+
`edd-tool` is a command-line utility for deploying and managing EDD (Effelsberg Direct Digitisation) backend instances.
|
|
4
|
+
It automates cloning site repositories, resolving variables from Ansible inventories, installing plugins, and running playbooks.
|
|
5
|
+
|
|
6
|
+
## Purpose
|
|
7
|
+
|
|
8
|
+
The `edd-tool` simplifies the deployment of EDD site repositories managing the docker update cycle and plugin installation phases of an EDD backend deployment.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
It is strongly recommended to install and run `edd-tool` inside a Python virtual environment to avoid dependency conflicts.
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Create and activate a virtual environment
|
|
16
|
+
python3 -m venv .venv
|
|
17
|
+
source .venv/bin/activate
|
|
18
|
+
|
|
19
|
+
# Install from PyPI
|
|
20
|
+
pip install edd-tool
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
You can verify the installation with:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
edd-tool --help
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Basic usage
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
$ edd-tool deploy --h
|
|
33
|
+
usage: edd-tool deploy [-h] [--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [--site-repo SITE_REPO] [--version VERSION]
|
|
34
|
+
[--deploy-dir DEPLOY_DIR] [--inventory INVENTORY] [--vault-pass-file VAULT_PASS_FILE]
|
|
35
|
+
[--site-config SITE_CONFIG] [--plugin-install-method {galaxy,git-submodule}] [--no-pullremote] [--force]
|
|
36
|
+
[--dry-run] [--ansible-args ANSIBLE_ARGS]
|
|
37
|
+
[config_profile]
|
|
38
|
+
|
|
39
|
+
positional arguments:
|
|
40
|
+
config_profile Optional profile name from ~/.edd-tool.rc (e.g. 'production', 'devel')
|
|
41
|
+
|
|
42
|
+
options:
|
|
43
|
+
-h, --help show this help message and exit
|
|
44
|
+
--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
|
|
45
|
+
Set the logging level (default: INFO)
|
|
46
|
+
--site-repo SITE_REPO
|
|
47
|
+
Git URL of the EDD site repository
|
|
48
|
+
--version VERSION Branch or tag for the site repository
|
|
49
|
+
--deploy-dir DEPLOY_DIR
|
|
50
|
+
Deployment directory
|
|
51
|
+
--inventory INVENTORY
|
|
52
|
+
Ansible inventory path (file, dir, or script)
|
|
53
|
+
--vault-pass-file VAULT_PASS_FILE
|
|
54
|
+
Path to vault password file (defaults to $ANSIBLE_VAULT_PASSWORD_FILE if set)
|
|
55
|
+
--site-config SITE_CONFIG
|
|
56
|
+
Path to site configuration YAML
|
|
57
|
+
--plugin-install-method {galaxy,git-submodule}
|
|
58
|
+
--no-pullremote Skip pullremote tag
|
|
59
|
+
--force Force overwrite of deployment directory
|
|
60
|
+
--dry-run Dry run the deployment
|
|
61
|
+
--ansible-args ANSIBLE_ARGS
|
|
62
|
+
Quoted string of extra ansible-playbook args
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Deployment profiles
|
|
66
|
+
|
|
67
|
+
To simplify the deployment interface it is possible to define deployment profiles in the `~/.edd-tool.rc` configuration file.
|
|
68
|
+
This will be used to set the default values for CLI arguments. For example `~/.edd-tool.rc` might contain:
|
|
69
|
+
|
|
70
|
+
```YAML
|
|
71
|
+
## Example ~/.edd-tool.rc
|
|
72
|
+
## Define reusable deployment profiles here
|
|
73
|
+
## Uncomment and update the profiles below to get started
|
|
74
|
+
|
|
75
|
+
production:
|
|
76
|
+
site_config: production_config.yml
|
|
77
|
+
site_repo: https://gitlab.com/site-repos/my-telescope-site.git
|
|
78
|
+
inventory: production
|
|
79
|
+
vault-pass-file: ~/.edd/production.pwd
|
|
80
|
+
|
|
81
|
+
development:
|
|
82
|
+
site_config: development_config.yml
|
|
83
|
+
site_repo: https://gitlab.com/site-repos/my-telescope-site.git
|
|
84
|
+
inventory: development
|
|
85
|
+
vault-pass-file: ~/.edd/development.pwd
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The name of a profile can be passed as a positional argument to the `deploy` command of `edd-tool`:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
edd-tool deploy development --force --version 250915.0
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
or
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
edd-tool deploy production --dry-run --force --version 250915.0
|
|
98
|
+
```
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "edd-tool"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.2"
|
|
8
8
|
description = "EDD deployment and plugin management tool"
|
|
9
9
|
dynamic = ["readme"]
|
|
10
10
|
license = { file = "LICENSE" }
|
|
@@ -31,3 +31,9 @@ where = ["src"]
|
|
|
31
31
|
|
|
32
32
|
[tool.setuptools.package-data]
|
|
33
33
|
"edd_tool.data" = ["edd-tool.rc.template"]
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://gitlab.mpcdf.mpg.de/mpifr-bdg/edd_installer"
|
|
37
|
+
Documentation = "https://gitlab.mpcdf.mpg.de/mpifr-bdg/edd_installer"
|
|
38
|
+
Repository = "https://gitlab.mpcdf.mpg.de/mpifr-bdg/edd_installer.git"
|
|
39
|
+
"Bug Tracker" = "https://gitlab.mpcdf.mpg.de/mpifr-bdg/edd_installer/issues"
|
|
@@ -7,11 +7,18 @@ import json
|
|
|
7
7
|
import logging
|
|
8
8
|
import os
|
|
9
9
|
import pprint
|
|
10
|
-
|
|
10
|
+
import shlex
|
|
11
|
+
import warnings
|
|
12
|
+
import io
|
|
13
|
+
from contextlib import contextmanager, redirect_stdout, redirect_stderr
|
|
11
14
|
from pathlib import Path
|
|
15
|
+
from collections import defaultdict
|
|
16
|
+
from datetime import datetime, UTC
|
|
12
17
|
import importlib.resources as pkg_resources
|
|
13
18
|
|
|
14
19
|
import yaml
|
|
20
|
+
import requests
|
|
21
|
+
import urllib3
|
|
15
22
|
|
|
16
23
|
from ansible.parsing.dataloader import DataLoader
|
|
17
24
|
from ansible.inventory.manager import InventoryManager
|
|
@@ -19,9 +26,14 @@ from ansible.vars.manager import VariableManager
|
|
|
19
26
|
from ansible.template import Templar
|
|
20
27
|
from ansible.parsing.vault import VaultSecret, VaultSecretsContext
|
|
21
28
|
|
|
29
|
+
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|
30
|
+
|
|
22
31
|
logging.basicConfig(level=logging.INFO, format="[%(levelname)s] %(message)s")
|
|
23
32
|
logger = logging.getLogger("edd-installer")
|
|
24
33
|
|
|
34
|
+
SESSION = requests.Session()
|
|
35
|
+
SESSION.verify = False
|
|
36
|
+
|
|
25
37
|
def ensure_rc_file():
|
|
26
38
|
"""Ensure that ~/.edd-tool.rc exists. Create from template if missing."""
|
|
27
39
|
rc_file = Path.home() / ".edd-tool.rc"
|
|
@@ -37,6 +49,44 @@ def ensure_rc_file():
|
|
|
37
49
|
logger.warning(f"Could not create default RC file: {e}")
|
|
38
50
|
|
|
39
51
|
|
|
52
|
+
def configure_file_logging(site_repo, version, inventory):
|
|
53
|
+
"""
|
|
54
|
+
Configure logging to also write to a timestamped log file.
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
site_repo (str): Site repository URL or name
|
|
58
|
+
version (str): Version/branch/tag
|
|
59
|
+
inventory (str): Inventory name
|
|
60
|
+
Returns:
|
|
61
|
+
Path: Path to the created log file
|
|
62
|
+
"""
|
|
63
|
+
timestamp = datetime.now(UTC).replace(microsecond=0).isoformat() # e.g. 2025-09-19T14:02:00+00:00
|
|
64
|
+
safe_repo = site_repo.split("/")[-1].replace(".git", "")
|
|
65
|
+
log_dir = Path.home() / ".edd" / "deployment_logs"
|
|
66
|
+
log_dir.mkdir(parents=True, exist_ok=True)
|
|
67
|
+
log_path = log_dir / f"{timestamp}_{safe_repo}_{version}_{inventory}.log"
|
|
68
|
+
|
|
69
|
+
fh = logging.FileHandler(log_path)
|
|
70
|
+
fh.setLevel(logging.DEBUG)
|
|
71
|
+
fh.setFormatter(logging.Formatter("[%(asctime)s] [%(levelname)s] %(message)s"))
|
|
72
|
+
logging.getLogger().addHandler(fh)
|
|
73
|
+
|
|
74
|
+
logger.info(f"Logging to file: {log_path}")
|
|
75
|
+
return log_path
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@contextmanager
|
|
79
|
+
def suppress_ansible_warnings():
|
|
80
|
+
"""
|
|
81
|
+
Context manager to suppress warnings and stdout/stderr noise.
|
|
82
|
+
Useful for silencing Ansible's noisy inventory parsing.
|
|
83
|
+
"""
|
|
84
|
+
with warnings.catch_warnings():
|
|
85
|
+
warnings.simplefilter("ignore")
|
|
86
|
+
buffer = io.StringIO()
|
|
87
|
+
with redirect_stdout(buffer), redirect_stderr(buffer):
|
|
88
|
+
yield
|
|
89
|
+
|
|
40
90
|
@contextmanager
|
|
41
91
|
def working_directory(path):
|
|
42
92
|
"""Temporarily change the working directory inside the context."""
|
|
@@ -47,24 +97,104 @@ def working_directory(path):
|
|
|
47
97
|
finally:
|
|
48
98
|
os.chdir(original_dir)
|
|
49
99
|
|
|
100
|
+
def get_repositories(registry):
|
|
101
|
+
url = f"{registry}/v2/_catalog"
|
|
102
|
+
resp = SESSION.get(url)
|
|
103
|
+
resp.raise_for_status()
|
|
104
|
+
return resp.json().get("repositories", [])
|
|
105
|
+
|
|
106
|
+
def get_tags(registry, repo):
|
|
107
|
+
url = f"{registry}/v2/{repo}/tags/list"
|
|
108
|
+
resp = SESSION.get(url)
|
|
109
|
+
resp.raise_for_status()
|
|
110
|
+
return resp.json().get("tags", [])
|
|
111
|
+
|
|
112
|
+
def get_manifest_digest(registry, repo, tag):
|
|
113
|
+
url = f"{registry}/v2/{repo}/manifests/{tag}"
|
|
114
|
+
headers = {"Accept": "application/vnd.docker.distribution.manifest.v2+json"}
|
|
115
|
+
resp = SESSION.head(url, headers=headers)
|
|
116
|
+
resp.raise_for_status()
|
|
117
|
+
return resp.headers.get("Docker-Content-Digest")
|
|
118
|
+
|
|
119
|
+
def snapshot_registry(registry):
|
|
120
|
+
"""Return a dict mapping repo -> digest -> tags."""
|
|
121
|
+
snapshot = {}
|
|
122
|
+
for repo in get_repositories(registry):
|
|
123
|
+
tags = get_tags(registry, repo)
|
|
124
|
+
if not tags:
|
|
125
|
+
continue
|
|
126
|
+
digest_to_tags = defaultdict(list)
|
|
127
|
+
for tag in tags:
|
|
128
|
+
digest = get_manifest_digest(registry, repo, tag)
|
|
129
|
+
if digest:
|
|
130
|
+
digest_to_tags[digest].append(tag)
|
|
131
|
+
snapshot[repo] = {digest: sorted(tags) for digest, tags in digest_to_tags.items()}
|
|
132
|
+
return snapshot
|
|
133
|
+
|
|
134
|
+
def compare_snapshots(before, after):
|
|
135
|
+
"""Return a report of added and removed tags."""
|
|
136
|
+
report = []
|
|
137
|
+
all_repos = set(before.keys()) | set(after.keys())
|
|
138
|
+
for repo in sorted(all_repos):
|
|
139
|
+
before_d = before.get(repo, {})
|
|
140
|
+
after_d = after.get(repo, {})
|
|
141
|
+
all_digests = set(before_d.keys()) | set(after_d.keys())
|
|
142
|
+
for digest in all_digests:
|
|
143
|
+
before_tags = set(before_d.get(digest, []))
|
|
144
|
+
after_tags = set(after_d.get(digest, []))
|
|
145
|
+
added = after_tags - before_tags
|
|
146
|
+
removed = before_tags - after_tags
|
|
147
|
+
if added or removed:
|
|
148
|
+
report.append((repo, digest, sorted(added), sorted(removed)))
|
|
149
|
+
return report
|
|
150
|
+
|
|
151
|
+
def print_report(report):
|
|
152
|
+
if not report:
|
|
153
|
+
logger.info("No changes detected in the registry.")
|
|
154
|
+
return
|
|
155
|
+
for repo, digest, added, removed in report:
|
|
156
|
+
short_digest = digest[:20]
|
|
157
|
+
if added:
|
|
158
|
+
logger.info(f"[+] {repo}:{short_digest} --> added tags: {', '.join(added)}")
|
|
159
|
+
if removed:
|
|
160
|
+
logger.info(f"[-] {repo}:{short_digest} --> removed tags: {', '.join(removed)}")
|
|
50
161
|
|
|
51
162
|
def run_cmd(cmd, cwd=None, check=True, env=None):
|
|
52
163
|
"""
|
|
53
|
-
Run a subprocess command.
|
|
164
|
+
Run a subprocess command and stream its output into the logger.
|
|
54
165
|
|
|
55
166
|
Args:
|
|
56
167
|
cmd (list[str]): Command and arguments
|
|
57
168
|
cwd (str|Path, optional): Directory to run command in
|
|
58
169
|
check (bool): Exit on non-zero return code
|
|
170
|
+
env (dict, optional): Environment variables
|
|
59
171
|
|
|
60
172
|
Returns:
|
|
61
|
-
|
|
173
|
+
int: Return code of the command
|
|
62
174
|
"""
|
|
63
175
|
logger.debug(f"Running command: {' '.join(cmd)}")
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
176
|
+
process = subprocess.Popen(
|
|
177
|
+
cmd,
|
|
178
|
+
cwd=cwd,
|
|
179
|
+
env=env,
|
|
180
|
+
stdout=subprocess.PIPE,
|
|
181
|
+
stderr=subprocess.STDOUT,
|
|
182
|
+
text=True,
|
|
183
|
+
bufsize=1
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
# Stream output live into logger
|
|
187
|
+
for line in process.stdout:
|
|
188
|
+
logger.info(line.rstrip())
|
|
189
|
+
|
|
190
|
+
process.wait()
|
|
191
|
+
|
|
192
|
+
if process.returncode != 0:
|
|
193
|
+
logger.error(f"Command failed with exit code {process.returncode}: {' '.join(cmd)}")
|
|
194
|
+
if check:
|
|
195
|
+
sys.exit(process.returncode)
|
|
196
|
+
|
|
197
|
+
return process.returncode
|
|
68
198
|
|
|
69
199
|
|
|
70
200
|
def default_deployment_dir(args):
|
|
@@ -183,7 +313,7 @@ def display_vars(vars_dict):
|
|
|
183
313
|
Args:
|
|
184
314
|
vars_dict (dict): Dictionary of variables
|
|
185
315
|
"""
|
|
186
|
-
logger.
|
|
316
|
+
logger.debug(pprint.pformat(vars_dict, indent=2))
|
|
187
317
|
|
|
188
318
|
|
|
189
319
|
def install_plugins(plugins, method="galaxy"):
|
|
@@ -212,9 +342,9 @@ def install_plugins(plugins, method="galaxy"):
|
|
|
212
342
|
raise NotImplementedError(f"Plugin install method '{method}' is unsupported")
|
|
213
343
|
|
|
214
344
|
|
|
215
|
-
def run_playbook(inventory, vault_args, site_config, tags=None, dry_run=False):
|
|
345
|
+
def run_playbook(inventory, vault_args, site_config, tags=None, dry_run=False, extra_args_str=None):
|
|
216
346
|
"""
|
|
217
|
-
Run an Ansible playbook.
|
|
347
|
+
Run an Ansible playbook with optional extra args as a quoted string.
|
|
218
348
|
|
|
219
349
|
Args:
|
|
220
350
|
inventory (str): Inventory path
|
|
@@ -222,19 +352,27 @@ def run_playbook(inventory, vault_args, site_config, tags=None, dry_run=False):
|
|
|
222
352
|
site_config (str): Playbook YAML file
|
|
223
353
|
tags (str, optional): Tags to limit execution
|
|
224
354
|
dry_run (bool): If True, log the command instead of running
|
|
355
|
+
extra_args_str (str): String of extra args to pass to ansible-playbook (quoted)
|
|
225
356
|
"""
|
|
226
357
|
collections = (Path().cwd() / "ansible_collections").absolute()
|
|
227
358
|
env = os.environ.copy()
|
|
228
359
|
env['ANSIBLE_COLLECTIONS_PATH'] = str(collections)
|
|
229
|
-
|
|
230
|
-
|
|
360
|
+
|
|
361
|
+
# Safely tokenize the extra args string
|
|
362
|
+
extra_args = shlex.split(extra_args_str) if extra_args_str else []
|
|
363
|
+
|
|
364
|
+
cmd = ["ansible-playbook", "-i", inventory] + vault_args
|
|
365
|
+
if extra_args_str:
|
|
366
|
+
cmd.extend(shlex.split(extra_args_str))
|
|
231
367
|
if tags:
|
|
232
368
|
cmd.extend(["--tags", tags])
|
|
369
|
+
cmd.append(site_config)
|
|
233
370
|
|
|
234
371
|
if dry_run:
|
|
235
372
|
logger.info("Would run: %s", " ".join(cmd))
|
|
236
373
|
else:
|
|
237
|
-
|
|
374
|
+
from subprocess import run
|
|
375
|
+
run(cmd, env=env, check=True)
|
|
238
376
|
|
|
239
377
|
|
|
240
378
|
def cmd_install(args):
|
|
@@ -244,6 +382,10 @@ def cmd_install(args):
|
|
|
244
382
|
Args:
|
|
245
383
|
args (Namespace): Parsed command-line arguments
|
|
246
384
|
"""
|
|
385
|
+
# Settup file logging for installs
|
|
386
|
+
if not args.dry_run:
|
|
387
|
+
configure_file_logging(args.site_repo, args.version, args.inventory)
|
|
388
|
+
|
|
247
389
|
deploy_dir = args.deploy_dir or default_deployment_dir(args)
|
|
248
390
|
logger.info("Creating deployment directory: %s", deploy_dir)
|
|
249
391
|
deploy_dir = create_deployment_dir(deploy_dir, force=args.force)
|
|
@@ -266,9 +408,10 @@ def cmd_install(args):
|
|
|
266
408
|
logger.info("Cloning site repository: %s (version: %s)", args.site_repo, args.version)
|
|
267
409
|
clone_or_copy_site_repo(args.site_repo, "./", branch=args.version)
|
|
268
410
|
logger.info("Parsing ansible inventory")
|
|
269
|
-
|
|
411
|
+
with suppress_ansible_warnings():
|
|
412
|
+
vars_dict, plugins = parse_inventory(args.inventory, vault_pass_file)
|
|
270
413
|
display_vars(vars_dict)
|
|
271
|
-
|
|
414
|
+
|
|
272
415
|
if not args.dry_run:
|
|
273
416
|
logger.info("Installing plugins")
|
|
274
417
|
install_plugins(plugins, method=args.plugin_install_method)
|
|
@@ -278,10 +421,21 @@ def cmd_install(args):
|
|
|
278
421
|
|
|
279
422
|
if not args.no_pullremote:
|
|
280
423
|
logger.info("Pulling docker images")
|
|
424
|
+
registry = f"https://{vars_dict['docker_registry']}:{vars_dict['docker_registry_port']}"
|
|
425
|
+
logger.debug("Taking registry snapshot before pullremote...")
|
|
426
|
+
before_state = snapshot_registry(registry)
|
|
427
|
+
logger.debug(before_state)
|
|
281
428
|
run_playbook(args.inventory, vault_args, args.site_config,
|
|
282
|
-
tags="pullremote", dry_run=args.dry_run
|
|
429
|
+
tags="pullremote", dry_run=args.dry_run,
|
|
430
|
+
extra_args_str=args.ansible_args)
|
|
431
|
+
after_state = snapshot_registry(registry)
|
|
432
|
+
logger.debug("Taking registry snapshow after pullremote")
|
|
433
|
+
logger.debug(after_state)
|
|
434
|
+
report = compare_snapshots(before_state, after_state)
|
|
435
|
+
print_report(report)
|
|
283
436
|
logger.info("Running deployment")
|
|
284
|
-
run_playbook(args.inventory, vault_args, args.site_config,
|
|
437
|
+
run_playbook(args.inventory, vault_args, args.site_config,
|
|
438
|
+
dry_run=args.dry_run, extra_args_str=args.ansible_args)
|
|
285
439
|
logger.info("Deployment finished")
|
|
286
440
|
|
|
287
441
|
|
|
@@ -366,6 +520,10 @@ def main():
|
|
|
366
520
|
sp_install.add_argument("--no-pullremote", action="store_true", help="Skip pullremote tag")
|
|
367
521
|
sp_install.add_argument("--force", action="store_true", help="Force overwrite of deployment directory")
|
|
368
522
|
sp_install.add_argument("--dry-run", action="store_true", help="Dry run the deployment")
|
|
523
|
+
sp_install.add_argument(
|
|
524
|
+
"--ansible-args",
|
|
525
|
+
help="Quoted string of extra ansible-playbook args"
|
|
526
|
+
)
|
|
369
527
|
sp_install.set_defaults(func=cmd_install)
|
|
370
528
|
|
|
371
529
|
args = parser.parse_args()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: edd-tool
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: EDD deployment and plugin management tool
|
|
5
5
|
Author-email: Ewan Barr <ebarr@mpifr-bonn.mpg.de>
|
|
6
6
|
License: Copyright 2025 Ewan Barr
|
|
@@ -11,6 +11,10 @@ License: Copyright 2025 Ewan Barr
|
|
|
11
11
|
|
|
12
12
|
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
13
13
|
|
|
14
|
+
Project-URL: Homepage, https://gitlab.mpcdf.mpg.de/mpifr-bdg/edd_installer
|
|
15
|
+
Project-URL: Documentation, https://gitlab.mpcdf.mpg.de/mpifr-bdg/edd_installer
|
|
16
|
+
Project-URL: Repository, https://gitlab.mpcdf.mpg.de/mpifr-bdg/edd_installer.git
|
|
17
|
+
Project-URL: Bug Tracker, https://gitlab.mpcdf.mpg.de/mpifr-bdg/edd_installer/issues
|
|
14
18
|
Requires-Python: >=3.11
|
|
15
19
|
Description-Content-Type: text/markdown
|
|
16
20
|
License-File: LICENSE
|
|
@@ -48,29 +52,70 @@ edd-tool --help
|
|
|
48
52
|
## Basic usage
|
|
49
53
|
|
|
50
54
|
```
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
[--
|
|
54
|
-
|
|
55
|
+
$ edd-tool deploy --h
|
|
56
|
+
usage: edd-tool deploy [-h] [--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [--site-repo SITE_REPO] [--version VERSION]
|
|
57
|
+
[--deploy-dir DEPLOY_DIR] [--inventory INVENTORY] [--vault-pass-file VAULT_PASS_FILE]
|
|
58
|
+
[--site-config SITE_CONFIG] [--plugin-install-method {galaxy,git-submodule}] [--no-pullremote] [--force]
|
|
59
|
+
[--dry-run] [--ansible-args ANSIBLE_ARGS]
|
|
60
|
+
[config_profile]
|
|
55
61
|
|
|
56
62
|
positional arguments:
|
|
57
|
-
|
|
63
|
+
config_profile Optional profile name from ~/.edd-tool.rc (e.g. 'production', 'devel')
|
|
58
64
|
|
|
59
65
|
options:
|
|
60
66
|
-h, --help show this help message and exit
|
|
61
67
|
--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
|
|
62
68
|
Set the logging level (default: INFO)
|
|
69
|
+
--site-repo SITE_REPO
|
|
70
|
+
Git URL of the EDD site repository
|
|
63
71
|
--version VERSION Branch or tag for the site repository
|
|
64
72
|
--deploy-dir DEPLOY_DIR
|
|
65
73
|
Deployment directory
|
|
66
74
|
--inventory INVENTORY
|
|
67
75
|
Ansible inventory path (file, dir, or script)
|
|
68
76
|
--vault-pass-file VAULT_PASS_FILE
|
|
69
|
-
Path to vault password file
|
|
77
|
+
Path to vault password file (defaults to $ANSIBLE_VAULT_PASSWORD_FILE if set)
|
|
70
78
|
--site-config SITE_CONFIG
|
|
71
79
|
Path to site configuration YAML
|
|
72
80
|
--plugin-install-method {galaxy,git-submodule}
|
|
73
81
|
--no-pullremote Skip pullremote tag
|
|
74
82
|
--force Force overwrite of deployment directory
|
|
75
83
|
--dry-run Dry run the deployment
|
|
84
|
+
--ansible-args ANSIBLE_ARGS
|
|
85
|
+
Quoted string of extra ansible-playbook args
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Deployment profiles
|
|
89
|
+
|
|
90
|
+
To simplify the deployment interface it is possible to define deployment profiles in the `~/.edd-tool.rc` configuration file.
|
|
91
|
+
This will be used to set the default values for CLI arguments. For example `~/.edd-tool.rc` might contain:
|
|
92
|
+
|
|
93
|
+
```YAML
|
|
94
|
+
## Example ~/.edd-tool.rc
|
|
95
|
+
## Define reusable deployment profiles here
|
|
96
|
+
## Uncomment and update the profiles below to get started
|
|
97
|
+
|
|
98
|
+
production:
|
|
99
|
+
site_config: production_config.yml
|
|
100
|
+
site_repo: https://gitlab.com/site-repos/my-telescope-site.git
|
|
101
|
+
inventory: production
|
|
102
|
+
vault-pass-file: ~/.edd/production.pwd
|
|
103
|
+
|
|
104
|
+
development:
|
|
105
|
+
site_config: development_config.yml
|
|
106
|
+
site_repo: https://gitlab.com/site-repos/my-telescope-site.git
|
|
107
|
+
inventory: development
|
|
108
|
+
vault-pass-file: ~/.edd/development.pwd
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The name of a profile can be passed as a positional argument to the `deploy` command of `edd-tool`:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
edd-tool deploy development --force --version 250915.0
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
or
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
edd-tool deploy production --dry-run --force --version 250915.0
|
|
76
121
|
```
|
edd_tool-0.2.0/README.md
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# EDD Tool
|
|
2
|
-
|
|
3
|
-
`edd-tool` is a command-line utility for deploying and managing EDD (Effelsberg Direct Digitisation) backend instances.
|
|
4
|
-
It automates cloning site repositories, resolving variables from Ansible inventories, installing plugins, and running playbooks.
|
|
5
|
-
|
|
6
|
-
## Purpose
|
|
7
|
-
|
|
8
|
-
The `edd-tool` simplifies the deployment of EDD site repositories managing the docker update cycle and plugin installation phases of an EDD backend deployment.
|
|
9
|
-
|
|
10
|
-
## Installation
|
|
11
|
-
|
|
12
|
-
It is strongly recommended to install and run `edd-tool` inside a Python virtual environment to avoid dependency conflicts.
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
# Create and activate a virtual environment
|
|
16
|
-
python3 -m venv .venv
|
|
17
|
-
source .venv/bin/activate
|
|
18
|
-
|
|
19
|
-
# Install from PyPI
|
|
20
|
-
pip install edd-tool
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
You can verify the installation with:
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
edd-tool --help
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Basic usage
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
usage: edd-tool deploy [-h] [--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [--version VERSION] [--deploy-dir DEPLOY_DIR] --inventory
|
|
33
|
-
INVENTORY --vault-pass-file VAULT_PASS_FILE --site-config SITE_CONFIG
|
|
34
|
-
[--plugin-install-method {galaxy,git-submodule}] [--no-pullremote] [--force] [--dry-run]
|
|
35
|
-
project
|
|
36
|
-
|
|
37
|
-
positional arguments:
|
|
38
|
-
project Git URL of the EDD site repository
|
|
39
|
-
|
|
40
|
-
options:
|
|
41
|
-
-h, --help show this help message and exit
|
|
42
|
-
--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
|
|
43
|
-
Set the logging level (default: INFO)
|
|
44
|
-
--version VERSION Branch or tag for the site repository
|
|
45
|
-
--deploy-dir DEPLOY_DIR
|
|
46
|
-
Deployment directory
|
|
47
|
-
--inventory INVENTORY
|
|
48
|
-
Ansible inventory path (file, dir, or script)
|
|
49
|
-
--vault-pass-file VAULT_PASS_FILE
|
|
50
|
-
Path to vault password file
|
|
51
|
-
--site-config SITE_CONFIG
|
|
52
|
-
Path to site configuration YAML
|
|
53
|
-
--plugin-install-method {galaxy,git-submodule}
|
|
54
|
-
--no-pullremote Skip pullremote tag
|
|
55
|
-
--force Force overwrite of deployment directory
|
|
56
|
-
--dry-run Dry run the deployment
|
|
57
|
-
```
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|