Skip to content

Commit

Permalink
Merge pull request #153 from freifunkMUC/salt-3006
Browse files Browse the repository at this point in the history
Upgrade to Salt 3006
  • Loading branch information
DasSkelett authored Feb 16, 2024
2 parents b82ab95 + 81ad1ef commit 306391c
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 56 deletions.
21 changes: 9 additions & 12 deletions _modules/ddns.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Support for RFC 2136 dynamic DNS updates.
Expand All @@ -23,7 +22,6 @@
{"keyname.": "keycontent"}
"""
from __future__ import absolute_import, print_function, unicode_literals

# Import python libs
import logging
Expand All @@ -41,7 +39,6 @@

import salt.utils.files
import salt.utils.json
from salt.ext import six


def __virtual__():
Expand All @@ -66,7 +63,7 @@ def _config(name, key=None, **kwargs):
if name in kwargs:
value = kwargs[name]
else:
value = __salt__["config.option"]("ddns.{0}".format(key))
value = __salt__["config.option"]("ddns.{}".format(key))
if not value:
value = None
return value
Expand Down Expand Up @@ -104,15 +101,15 @@ def add_host(
if res is False:
return False

fqdn = "{0}.{1}.".format(name, zone)
fqdn = "{}.{}.".format(name, zone)
parts = ip.split(".")[::-1]
popped = []

# Iterate over possible reverse zones
while len(parts) > 1:
p = parts.pop(0)
popped.append(p)
zone = "{0}.{1}".format(".".join(parts), "in-addr.arpa.")
zone = "{}.{}".format(".".join(parts), "in-addr.arpa.")
name = ".".join(popped)
ptr = update(
zone, name, ttl, "PTR", fqdn, nameserver, timeout, replace, port, **kwargs
Expand All @@ -134,7 +131,7 @@ def delete_host(zone, name, nameserver="127.0.0.1", timeout=5, port=53, **kwargs
salt ns1 ddns.delete_host example.com host1
"""
fqdn = "{0}.{1}".format(name, zone)
fqdn = "{}.{}".format(name, zone)
request = dns.message.make_query(fqdn, "A")
answer = dns.query.udp(request, nameserver, timeout, port)
try:
Expand All @@ -155,7 +152,7 @@ def delete_host(zone, name, nameserver="127.0.0.1", timeout=5, port=53, **kwargs
while len(parts) > 1:
p = parts.pop(0)
popped.append(p)
zone = "{0}.{1}".format(".".join(parts), "in-addr.arpa.")
zone = "{}.{}".format(".".join(parts), "in-addr.arpa.")
name = ".".join(popped)
ptr = delete(
zone,
Expand Down Expand Up @@ -197,12 +194,12 @@ def update(
salt ns1 ddns.update example.com host1 60 A 10.0.0.1
"""
name = six.text_type(name)
name = str(name)

if name[-1:] == ".":
fqdn = name
else:
fqdn = "{0}.{1}".format(name, zone)
fqdn = "{}.{}".format(name, zone)

request = dns.message.make_query(fqdn, rdtype)
answer = dns.query.udp(request, nameserver, timeout, port)
Expand Down Expand Up @@ -265,12 +262,12 @@ def delete(
salt ns1 ddns.delete example.com host1 A
"""
name = six.text_type(name)
name = str(name)

if name[-1:] == ".":
fqdn = name
else:
fqdn = "{0}.{1}".format(name, zone)
fqdn = "{}.{}".format(name, zone)

request = dns.message.make_query(fqdn, (rdtype or "ANY"))
answer = dns.query.udp(request, nameserver, timeout, port)
Expand Down
8 changes: 1 addition & 7 deletions _pillar/netbox.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
A module that adds data to the Pillar structure from a NetBox API.
Expand Down Expand Up @@ -48,17 +47,12 @@
Whether should retrieve the prefixes of the site the device belongs to.
"""

from __future__ import absolute_import, print_function, unicode_literals
import logging
import six

# Import Salt libs
import salt.utils.http

if six.PY3:
import ipaddress
else:
import salt.ext.ipaddress as ipaddress
import ipaddress

log = logging.getLogger(__name__)

Expand Down
12 changes: 6 additions & 6 deletions apt/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ salt-repo-key:
file.managed:
- name: /usr/share/keyrings/salt-archive-keyring.gpg
{% if 'Ubuntu' in grains.lsb_distrib_id %}
- source: https://repo.saltproject.io/py3/{{ grains.lsb_distrib_id | lower }}/{{ grains.osrelease }}/{{ grains.osarch }}/latest/salt-archive-keyring.gpg
- source: https://repo.saltproject.io/salt/py3/{{ grains.lsb_distrib_id | lower }}/{{ grains.osrelease }}/{{ grains.osarch }}/SALT-PROJECT-GPG-PUBKEY-2023.gpg
{% elif 'Raspbian' in grains.lsb_distrib_id %}
- source: http://repo.saltproject.io/py3/debian/{{ grains.osmajorrelease }}/{{ grains.osarch }}/latest/salt-archive-keyring.gpg
- source: http://repo.saltproject.io/salt/py3/debian/{{ grains.osmajorrelease }}/{{ grains.osarch }}/SALT-PROJECT-GPG-PUBKEY-2023.gpg
{% else %}
- source: http://repo.saltproject.io/py3/{{ grains.lsb_distrib_id | lower }}/{{ grains.osmajorrelease }}/{{ grains.osarch }}/latest/salt-archive-keyring.gpg # noqa: 204
- source: http://repo.saltproject.io/salt/py3/{{ grains.lsb_distrib_id | lower }}/{{ grains.osmajorrelease }}/{{ grains.osarch }}/SALT-PROJECT-GPG-PUBKEY-2023.gpg
{% endif %}
- skip_verify: True

salt-repo:
pkgrepo.managed:
{% if 'Ubuntu' in grains.lsb_distrib_id %}
- name: deb [arch={{ grains.osarch }} signed-by=/usr/share/keyrings/salt-archive-keyring.gpg] http://repo.saltproject.io/py3/{{ grains.lsb_distrib_id | lower }}/{{ grains.osrelease }}/{{ grains.osarch }}/latest {{ grains.oscodename }} main
- name: deb [arch={{ grains.osarch }} signed-by=/usr/share/keyrings/salt-archive-keyring.gpg] http://repo.saltproject.io/salt/py3/{{ grains.lsb_distrib_id | lower }}/{{ grains.osrelease }}/{{ grains.osarch }}/latest {{ grains.oscodename }} main
{% elif 'Raspbian' in grains.lsb_distrib_id %}
- name: deb [arch={{ grains.osarch }} signed-by=/usr/share/keyrings/salt-archive-keyring.gpg] http://repo.saltproject.io/py3/debian/{{ grains.osmajorrelease }}/{{ grains.osarch }}/latest {{ grains.oscodename }} main
- name: deb [arch={{ grains.osarch }} signed-by=/usr/share/keyrings/salt-archive-keyring.gpg] http://repo.saltproject.io/salt/py3/debian/{{ grains.osmajorrelease }}/{{ grains.osarch }}/latest {{ grains.oscodename }} main
{% else %}
- name: deb [arch={{ grains.osarch }} signed-by=/usr/share/keyrings/salt-archive-keyring.gpg] http://repo.saltproject.io/py3/{{ grains.lsb_distrib_id | lower }}/{{ grains.osmajorrelease }}/{{ grains.osarch }}/latest {{ grains.oscodename }} main # noqa: 204
- name: deb [arch={{ grains.osarch }} signed-by=/usr/share/keyrings/salt-archive-keyring.gpg] http://repo.saltproject.io/salt/py3/{{ grains.lsb_distrib_id | lower }}/{{ grains.osmajorrelease }}/{{ grains.osarch }}/latest {{ grains.oscodename }} main # noqa: 204
{% endif %}
- file: /etc/apt/sources.list.d/saltstack.list
- clean_file: True
Expand Down
15 changes: 8 additions & 7 deletions dhcp-server/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
#

# salt started complaining as this key is present in another formula...
python3-netifaces-dhcp:
pkg.installed:
- name: python3-netifaces
netifaces-dhcp:
pip.installed: # Install into Salt's Python environment
- name: netifaces

python3-netaddr:
pkg.installed
netaddr-dhcp:
pip.installed: # Install into Salt's Python environment
- name: netaddr

isc-dhcp-server:
pkg.installed:
Expand Down Expand Up @@ -43,8 +44,8 @@ dhcpd-pools:
- template: jinja
- require:
- file: /etc/systemd/system/isc-dhcp-server.service
- pkg: python3-netifaces-dhcp
- pkg: python3-netaddr
- pip: netifaces-dhcp
- pip: netaddr-dhcp
- watch_in:
- service: isc-dhcp-server

28 changes: 12 additions & 16 deletions dns-server/auth/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
include:
- dns-server

python-dnspython:
pkg.installed:
- name: python3-dnspython

# Bind options
/etc/bind/named.conf.options:
file.managed:
Expand Down Expand Up @@ -166,7 +162,7 @@ record-A-{{ node_id }}:
- keyalgorithm: hmac-sha512
- replace_on_change: True
- require:
- pkg: python-dnspython
- pip: dnspython
- file: dns-key

record-PTR-{{ node_id }}:
Expand All @@ -182,7 +178,7 @@ record-PTR-{{ node_id }}:
- keyalgorithm: hmac-sha512
- replace_on_change: True
- require:
- pkg: python-dnspython
- pip: dnspython
- file: dns-key

{% endif %}
Expand All @@ -201,7 +197,7 @@ record-AAAA-{{ node_id }}:
- keyalgorithm: hmac-sha512
- replace_on_change: True
- require:
- pkg: python-dnspython
- pip: dnspython
- file: dns-key

record-PTR6-{{ node_id }}:
Expand All @@ -217,7 +213,7 @@ record-PTR6-{{ node_id }}:
- keyalgorithm: hmac-sha512
- replace_on_change: True
- require:
- pkg: python-dnspython
- pip: dnspython
- file: dns-key

{%- endif %}
Expand All @@ -237,7 +233,7 @@ record-A-overlay-{{ node_id }}:
- keyalgorithm: hmac-sha512
- replace_on_change: True
- require:
- pkg: python-dnspython
- pip: dnspython
- file: dns-key
{% endif %}

Expand All @@ -258,7 +254,7 @@ record-A-external-{{ node_id }}:
- keyalgorithm: hmac-sha512
- replace_on_change: True
- require:
- pkg: python-dnspython
- pip: dnspython
- file: dns-key
{%- endif -%}

Expand All @@ -278,7 +274,7 @@ record-AAAA-external-{{ node_id }}:
- keyalgorithm: hmac-sha512
- replace_on_change: True
- require:
- pkg: python-dnspython
- pip: dnspython
- file: dns-key

{%- endif %}
Expand Down Expand Up @@ -325,7 +321,7 @@ record-CNAME-{{ cname }}:
- keyalgorithm: hmac-sha512
- replace_on_change: True
- require:
- pkg: python-dnspython
- pip: dnspython
- file: dns-key

# we create a cname ov.ffmuc.net entry for each in.ffmuc.net entry
Expand All @@ -347,7 +343,7 @@ record-CNAME-{{ cname_ov }}:
- keyalgorithm: hmac-sha512
- replace_on_change: True
- require:
- pkg: python-dnspython
- pip: dnspython
- file: dns-key
{% endif %}

Expand Down Expand Up @@ -376,7 +372,7 @@ record-A-extra-{{ dns_entry }}:
- keyalgorithm: hmac-sha512
- replace_on_change: True
- require:
- pkg: python-dnspython
- pip: dnspython
- file: dns-key

{%- endif %}
Expand All @@ -395,7 +391,7 @@ record-AAAA-extra-{{ dns_entry }}:
- keyalgorithm: hmac-sha512
- replace_on_change: True
- require:
- pkg: python-dnspython
- pip: dnspython
- file: dns-key
{%- endif %}

Expand All @@ -417,7 +413,7 @@ record-{{ loop.index }}-{{ record.get('type') }}-{{ record.get('name') }}.{{ rec
- keyalgorithm: hmac-sha512
- replace_on_change: True
- require:
- pkg: python-dnspython
- pip: dnspython
- file: dns-key
{%- endfor %}{# for record in custom_records #}

Expand Down
6 changes: 4 additions & 2 deletions dns-server/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ bind9:
dns_pkgs:
pkg.installed:
- pkgs:
- python3-dnspython
- python-dnspython
- dnsutils
- bind9-dnsutils

dnspython:
pip.installed: # Install into Salt's Python environment
- reload_modules: True

# Reload command
rndc-reload:
cmd.run:
Expand Down
1 change: 1 addition & 0 deletions duplicity/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ duplicity_repo:

b2sdk:
pip.installed:
- pip_bin: /usr/bin/pip3 # Required with Salt Onedir packaging, otherwise dependency is installed into Salt's custom Python environment
- require:
- pkg: duplicity-packages
{% endif %}
Expand Down
1 change: 0 additions & 1 deletion ff_base/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ ffmuc_packages:
- sysstat
- dnsutils
- curl
- iftop
- iptraf
- speedtest-cli
- dmidecode
Expand Down
3 changes: 2 additions & 1 deletion icinga2/services/base-services.conf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ apply Service "salt-minion" {

vars.procs_critical = "1:"
vars.procs_warning = "1:"
vars.procs_command = "salt-minion"
# vars.procs_command = "python3.10"
vars.procs_argument = "salt-minion" # salt-minion 3006+ starts salt-minion as argument to the python3.10 command
check_interval = 2m
max_check_attempts = 3
retry_interval = 1m
Expand Down
8 changes: 4 additions & 4 deletions wireguard/init.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% set interfaces = salt['pillar.get']('netbox:interfaces') %}
python3-netifaces:
pkg.installed
netifaces:
pip.installed # Install into Salt's Python environment

python3-netaddr:
pkg.installed
netaddr:
pip.installed # Install into Salt's Python environment

iptables-persistent:
pkg.installed
Expand Down

0 comments on commit 306391c

Please sign in to comment.