Skip to content

Commit 911e62b

Browse files
committed
Add dns-use-ipv4 option for DNS
In our environment, our DNS server requires passing the "-4" argument to the nsupdate command. This change adds support for configuring OSIA to use this option when using the nsupdate dns provider.
1 parent 0ab4628 commit 911e62b

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ default:
8484
zone: ''
8585
key_file: ''
8686
ttl: 0
87+
use_ipv4: false
8788
```
8889

8990
Every key here is overridible by the argument passed to the installer.

Diff for: osia/cli.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ def _read_list(in_str: str) -> List[str]:
7272
'dns_ttl': {'help': 'TTL of the records', 'type': int},
7373
'dns_key_file': {'help': 'Keyfile used to access dns server via nsupdate'},
7474
'dns_zone': {'help': 'Zone on server where the record will be stored'},
75-
'dns_server': {'help': 'Address of server with running bind'}
75+
'dns_server': {'help': 'Address of server with running bind'},
76+
'dns_use_ipv4': {'help': 'Use only IPv4 for DNS settings', 'action': 'store_const',
77+
'const': True}
7678
}
7779
}
7880

Diff for: osia/installer/dns/nsupdate.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,18 @@
2222

2323
class NSUpdate(DNSUtil):
2424
"""Implementation of DNSUtil specific for nsupdate dns provider"""
25-
def __init__(self, key_file=None, server=None, zone=None, **kwargs):
25+
def __init__(self, key_file=None, server=None, zone=None, use_ipv4=False, **kwargs):
2626
super().__init__(**kwargs)
2727
self.key_file = key_file
2828
self.server = server
2929
self.zone = zone
30+
self.use_ipv4 = use_ipv4
3031

3132
def _exec_nsupdate(self, string: str):
32-
with Popen(["nsupdate", "-k", self.key_file], stdin=PIPE, universal_newlines=True) as nsu:
33+
nsupdate_args = ["nsupdate", "-k", self.key_file]
34+
if self.use_ipv4:
35+
nsupdate_args.append('-4')
36+
with Popen(nsupdate_args, stdin=PIPE, universal_newlines=True) as nsu:
3337
nsu.communicate(string)
3438
self.modified = True
3539

0 commit comments

Comments
 (0)