This commit is contained in:
mwiegand 2021-06-21 13:40:47 +02:00
parent 1a5e3cd388
commit ca0966a33b
3 changed files with 12 additions and 7 deletions

View file

@ -32,7 +32,7 @@ actions = {
hosts = {} hosts = {}
for source in node.metadata.get('apt/sources'): for source in node.metadata.get('apt/sources'):
host = urlparse(source.split()[1]).hostname host = repo.libs.apt.AptSource(source).url.hostname
hosts\ hosts\
.setdefault(host, set())\ .setdefault(host, set())\
.add(source) .add(source)

View file

@ -0,0 +1,2 @@
#sudo systemctl unmask influxdb.service
#sudo systemctl start influxdb

View file

@ -1,15 +1,18 @@
# https://manpages.debian.org/jessie/apt/sources.list.5.de.html # https://manpages.debian.org/jessie/apt/sources.list.5.de.html
from urllib.parse import urlparse from urllib.parse import urlparse
from re import search, sub from re import match, search, sub
class AptSource(): class AptSource():
def __init__(self, string): def __init__(self, string):
self.options = { if match(r'\[.*\]', string):
k:v.split('=') for k,v in ( self.options = {
e.split('=') for e in search(r'\[(.*)\]', string)[1].split() k:v.split('=') for k,v in (
) e.split('=') for e in search(r'\[(.*)\]', string)[1].split()
} )
}
else:
self.options = {}
parts = sub(r'\[.*\]', '', string).split() parts = sub(r'\[.*\]', '', string).split()
self.type = parts[0] self.type = parts[0]
self.url = urlparse(parts[1]) self.url = urlparse(parts[1])