mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-29 19:04:42 +00:00
utils/[galaxyify-playbook,gen_module_docs].py: flake8 fixes
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
def galaxify_playbook(playbook_in):
|
def galaxify_playbook(playbook_in):
|
||||||
p1 = re.compile('(ipa.*:)$')
|
p1 = re.compile('(ipa.*:)$')
|
||||||
p2 = re.compile('(name:) (ipa.*)$')
|
p2 = re.compile('(name:) (ipa.*)$')
|
||||||
lines = [ ]
|
lines = []
|
||||||
|
|
||||||
with open(playbook_in) as in_f:
|
with open(playbook_in) as in_f:
|
||||||
changed = False
|
changed = False
|
||||||
@@ -16,7 +16,7 @@ def galaxify_playbook(playbook_in):
|
|||||||
if stripped.startswith("- name:") or \
|
if stripped.startswith("- name:") or \
|
||||||
stripped.startswith("- block:"):
|
stripped.startswith("- block:"):
|
||||||
changeable = True
|
changeable = True
|
||||||
elif stripped in [ "set_fact:", "vars:" ]:
|
elif stripped in ["set_fact:", "vars:"]:
|
||||||
changeable = False
|
changeable = False
|
||||||
include_role = False
|
include_role = False
|
||||||
elif stripped.startswith("include_role:"):
|
elif stripped.startswith("include_role:"):
|
||||||
@@ -24,8 +24,8 @@ def galaxify_playbook(playbook_in):
|
|||||||
elif include_role and stripped.startswith("name:"):
|
elif include_role and stripped.startswith("name:"):
|
||||||
line = p2.sub(r'\1 freeipa.ansible_freeipa.\2', line)
|
line = p2.sub(r'\1 freeipa.ansible_freeipa.\2', line)
|
||||||
changed = True
|
changed = True
|
||||||
elif changeable and \
|
elif changeable and not stripped.startswith(
|
||||||
not stripped.startswith("freeipa.ansible_freeipa."):
|
"freeipa.ansible_freeipa."):
|
||||||
line = p1.sub(r'freeipa.ansible_freeipa.\1', line)
|
line = p1.sub(r'freeipa.ansible_freeipa.\1', line)
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
@@ -36,4 +36,5 @@ def galaxify_playbook(playbook_in):
|
|||||||
for line in lines:
|
for line in lines:
|
||||||
out_f.write(line)
|
out_f.write(line)
|
||||||
|
|
||||||
|
|
||||||
galaxify_playbook(sys.argv[1])
|
galaxify_playbook(sys.argv[1])
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import re
|
|
||||||
|
|
||||||
param_docs = {
|
param_docs = {
|
||||||
"ccache": "The local ccache",
|
"ccache": "The local ccache",
|
||||||
@@ -59,8 +57,8 @@ param_docs = {
|
|||||||
"external_ca": "External ca setting",
|
"external_ca": "External ca setting",
|
||||||
"setup_adtrust": "Configure AD trust capability",
|
"setup_adtrust": "Configure AD trust capability",
|
||||||
"external_cert_files": [
|
"external_cert_files": [
|
||||||
"File containing the IPA CA certificate and the external CA certificate",
|
"File containing the IPA CA certificate and the external CA certificate",
|
||||||
"chain"
|
"chain"
|
||||||
],
|
],
|
||||||
"reverse_zones": "The reverse DNS zones to use",
|
"reverse_zones": "The reverse DNS zones to use",
|
||||||
"no_reverse": "Do not create new reverse DNS zone",
|
"no_reverse": "Do not create new reverse DNS zone",
|
||||||
@@ -103,14 +101,16 @@ param_docs = {
|
|||||||
"dirsrv_pin": "The password to unlock the Directory Server private key",
|
"dirsrv_pin": "The password to unlock the Directory Server private key",
|
||||||
"http_pin": "The password to unlock the Apache Server private key",
|
"http_pin": "The password to unlock the Apache Server private key",
|
||||||
"pkinit_pin": "The password to unlock the Kerberos KDC private key",
|
"pkinit_pin": "The password to unlock the Kerberos KDC private key",
|
||||||
"dirsrv_cert_name": "Name of the Directory Server SSL certificate to install",
|
"dirsrv_cert_name":
|
||||||
|
"Name of the Directory Server SSL certificate to install",
|
||||||
"http_cert_name": "Name of the Apache Server SSL certificate to install",
|
"http_cert_name": "Name of the Apache Server SSL certificate to install",
|
||||||
"pkinit_cert_name": "Name of the Kerberos KDC SSL certificate to install",
|
"pkinit_cert_name": "Name of the Kerberos KDC SSL certificate to install",
|
||||||
"keytab": "Path to backed up keytab from previous enrollment",
|
"keytab": "Path to backed up keytab from previous enrollment",
|
||||||
"mkhomedir": "Create home directories for users on their first login",
|
"mkhomedir": "Create home directories for users on their first login",
|
||||||
"adtrust_netbios_name": "The adtrust netbios_name setting",
|
"adtrust_netbios_name": "The adtrust netbios_name setting",
|
||||||
"adtrust_reset_netbios_name": "The adtrust reset_netbios_name setting",
|
"adtrust_reset_netbios_name": "The adtrust reset_netbios_name setting",
|
||||||
"zonemgr": "DNS zone manager e-mail address. Defaults to hostmaster@DOMAIN",
|
"zonemgr":
|
||||||
|
"DNS zone manager e-mail address. Defaults to hostmaster@DOMAIN",
|
||||||
"ssh_trust_dns": "Configure OpenSSH client to trust DNS SSHFP records",
|
"ssh_trust_dns": "Configure OpenSSH client to trust DNS SSHFP records",
|
||||||
"dns_ip_addresses": "The dns ip_addresses setting",
|
"dns_ip_addresses": "The dns ip_addresses setting",
|
||||||
"dns_reverse_zones": "The dns reverse_zones setting",
|
"dns_reverse_zones": "The dns reverse_zones setting",
|
||||||
@@ -132,8 +132,8 @@ param_docs = {
|
|||||||
"debug": "Turn on extra debugging",
|
"debug": "Turn on extra debugging",
|
||||||
"basedn": "The basedn of the IPA server (of the form dc=example,dc=com)",
|
"basedn": "The basedn of the IPA server (of the form dc=example,dc=com)",
|
||||||
"allow_repair": [
|
"allow_repair": [
|
||||||
"Allow repair of already joined hosts. Contrary to ipaclient_force_join",
|
"Allow repair of already joined hosts. Contrary to ipaclient_force_join",
|
||||||
"the host entry will not be changed on the server"
|
"the host entry will not be changed on the server"
|
||||||
],
|
],
|
||||||
"backup": "File to backup",
|
"backup": "File to backup",
|
||||||
"fqdn": [
|
"fqdn": [
|
||||||
@@ -167,7 +167,8 @@ param_docs = {
|
|||||||
"request_cert": "Request certificate for the machine",
|
"request_cert": "Request certificate for the machine",
|
||||||
"preserve_sssd": "Preserve old SSSD configuration if possible",
|
"preserve_sssd": "Preserve old SSSD configuration if possible",
|
||||||
"no_sudo": "Do not configure SSSD as data source for sudo",
|
"no_sudo": "Do not configure SSSD as data source for sudo",
|
||||||
"fixed_primary": "Configure sssd to use fixed server as primary IPA server",
|
"fixed_primary":
|
||||||
|
"Configure sssd to use fixed server as primary IPA server",
|
||||||
"permit": "Disable access rules by default, permit all access",
|
"permit": "Disable access rules by default, permit all access",
|
||||||
"no_krb5_offline_passwords": [
|
"no_krb5_offline_passwords": [
|
||||||
"Configure SSSD not to store user password when the server is offline"
|
"Configure SSSD not to store user password when the server is offline"
|
||||||
@@ -182,8 +183,6 @@ param_docs = {
|
|||||||
|
|
||||||
|
|
||||||
def gen_module_docs(module_in):
|
def gen_module_docs(module_in):
|
||||||
lines = [ ]
|
|
||||||
|
|
||||||
with open(module_in) as in_f:
|
with open(module_in) as in_f:
|
||||||
in_lines = in_f.readlines()
|
in_lines = in_f.readlines()
|
||||||
|
|
||||||
@@ -193,7 +192,7 @@ def gen_module_docs(module_in):
|
|||||||
while i < len(in_lines):
|
while i < len(in_lines):
|
||||||
line = in_lines[i]
|
line = in_lines[i]
|
||||||
stripped = line.strip()
|
stripped = line.strip()
|
||||||
#print("stripped: %s" % repr(stripped))
|
# print("stripped: %s" % repr(stripped))
|
||||||
if stripped.startswith("# "):
|
if stripped.startswith("# "):
|
||||||
pass
|
pass
|
||||||
elif stripped.startswith("argument_spec=dict()"):
|
elif stripped.startswith("argument_spec=dict()"):
|
||||||
@@ -203,23 +202,23 @@ def gen_module_docs(module_in):
|
|||||||
elif stripped.startswith("),") and arg_spec:
|
elif stripped.startswith("),") and arg_spec:
|
||||||
arg_spec = False
|
arg_spec = False
|
||||||
elif arg_spec:
|
elif arg_spec:
|
||||||
#if not "dict=(" in stripped:
|
# if not "dict=(" in stripped:
|
||||||
# print("%s: Bad argument dict line '%s'" % (module_in,
|
# print("%s: Bad argument dict line '%s'" % (module_in,
|
||||||
# stripped))
|
# stripped))
|
||||||
while ")," not in stripped and i < len(in_lines) - 1:
|
while ")," not in stripped and i < len(in_lines) - 1:
|
||||||
next_stripped = in_lines[i+1].strip()
|
next_stripped = in_lines[i+1].strip()
|
||||||
if not next_stripped.startswith("# "):
|
if not next_stripped.startswith("# "):
|
||||||
stripped += next_stripped
|
stripped += next_stripped
|
||||||
i += 1
|
i += 1
|
||||||
#print("stripped: '%s'" % stripped)
|
# print("stripped: '%s'" % stripped)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
param, _dict = stripped.split("=", 1)
|
param, _dict = stripped.split("=", 1)
|
||||||
except:
|
except Exception:
|
||||||
print("Failed to split line '%s'" % stripped)
|
print("Failed to split line '%s'" % stripped)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
#print("_dict: '%s'" % _dict)
|
# print("_dict: '%s'" % _dict)
|
||||||
if not _dict.startswith("dict(") or not _dict.endswith("),"):
|
if not _dict.startswith("dict(") or not _dict.endswith("),"):
|
||||||
print("%s: Bad argument dict line 2 '%s'" % (module_in, _dict))
|
print("%s: Bad argument dict line 2 '%s'" % (module_in, _dict))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@@ -228,26 +227,27 @@ def gen_module_docs(module_in):
|
|||||||
|
|
||||||
if param not in param_docs:
|
if param not in param_docs:
|
||||||
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
||||||
print("%s: param '%s' is not in param_docs" % (module_in, param))
|
print("%s: param '%s' is not in param_docs" % (module_in,
|
||||||
|
param))
|
||||||
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
#print("param: '%s', dict: '%s'" % (param, _dict))
|
# print("param: '%s', dict: '%s'" % (param, _dict))
|
||||||
|
|
||||||
opts = _dict.split(',')
|
opts = _dict.split(',')
|
||||||
opts = [ o.strip() for o in opts ]
|
opts = [o.strip() for o in opts]
|
||||||
required = False
|
required = False
|
||||||
#no_log = False
|
# no_log = False
|
||||||
if "required=True" in opts:
|
if "required=True" in opts:
|
||||||
required = True
|
required = True
|
||||||
#if "no_log=True" in opts:
|
# if "no_log=True" in opts:
|
||||||
# no_log = True
|
# no_log = True
|
||||||
|
|
||||||
#args.append([param, required, no_log])
|
# args.append([param, required, no_log])
|
||||||
args.append([param, required])
|
args.append([param, required])
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
#print("%s: %s" % (module_in, repr(args)))
|
# print("%s: %s" % (module_in, repr(args)))
|
||||||
|
|
||||||
def add_options(args):
|
def add_options(args):
|
||||||
for param, required in args:
|
for param, required in args:
|
||||||
@@ -258,8 +258,8 @@ def gen_module_docs(module_in):
|
|||||||
out_lines.append(" %s\n" % x)
|
out_lines.append(" %s\n" % x)
|
||||||
else:
|
else:
|
||||||
out_lines.append(" description: %s\n" % param_docs[param])
|
out_lines.append(" description: %s\n" % param_docs[param])
|
||||||
out_lines.append(" required: %s\n" % ("yes","no")[required])
|
out_lines.append(" required: %s\n" % ("yes", "no")[required])
|
||||||
|
|
||||||
out_lines = []
|
out_lines = []
|
||||||
options = False
|
options = False
|
||||||
in_options = False
|
in_options = False
|
||||||
@@ -295,12 +295,13 @@ def gen_module_docs(module_in):
|
|||||||
out_lines.append(line)
|
out_lines.append(line)
|
||||||
|
|
||||||
print(module_in)
|
print(module_in)
|
||||||
#for line in out_lines:
|
# for line in out_lines:
|
||||||
# sys.stdout.write(line)
|
# sys.stdout.write(line)
|
||||||
|
|
||||||
if changed:
|
if changed:
|
||||||
with open(module_in, "w") as out_f:
|
with open(module_in, "w") as out_f:
|
||||||
for line in out_lines:
|
for line in out_lines:
|
||||||
out_f.write(line)
|
out_f.write(line)
|
||||||
|
|
||||||
|
|
||||||
gen_module_docs(sys.argv[1])
|
gen_module_docs(sys.argv[1])
|
||||||
|
|||||||
Reference in New Issue
Block a user