Blame utils/gen_module_docs.py

Packit Service 0a38ef
import sys
Packit Service 0a38ef
Packit Service 0a38ef
param_docs = {
Packit Service 0a38ef
    "ccache": "The local ccache",
Packit Service 0a38ef
    "installer_ccache": "The installer ccache setting",
Packit Service 0a38ef
    "_top_dir": "The installer _top_dir setting",
Packit Service 0a38ef
    "_ca_enabled": "The installer _ca_enabled setting",
Packit Service 0a38ef
    "_add_to_ipaservers": "The installer _add_to_ipaservers setting",
Packit Service 0a38ef
    "_ca_subject": "The installer _ca_subject setting",
Packit Service 0a38ef
    "_subject_base": "The installer _subject_base setting",
Packit Service 0a38ef
    "config_setup_ca": "The config setup_ca setting",
Packit Service 0a38ef
    "config_master_host_name": "The config master_host_name setting",
Packit Service 0a38ef
    "config_ca_host_name": "The config ca_host_name setting",
Packit Service 0a38ef
    "config_ips": "The config ips setting",
Packit Service 0a38ef
    "_ca_file": "The installer _ca_file setting",
Packit Service 0a38ef
    "_kra_enabled": "The installer _kra_enabled setting",
Packit Service 0a38ef
    "_dirsrv_pkcs12_info": "The installer _dirsrv_pkcs12_info setting",
Packit Service 0a38ef
    "_pkinit_pkcs12_info": "The installer _pkinit_pkcs12_info setting",
Packit Service 0a38ef
    "_http_pkcs12_info": "The installer _http_pkcs12_info setting",
Packit Service 0a38ef
    "ds_ca_subject": "The ds.ca_subject setting",
Packit Service 0a38ef
    "ca_subject": "The installer ca_subject setting",
Packit Service 0a38ef
    "_hostname_overridden": "The installer _hostname_overridden setting",
Packit Service 0a38ef
    "_kra_host_name": "The installer _kra_host_name setting",
Packit Service 0a38ef
    "_http_ca_cert": "The installer _http_ca_cert setting",
Packit Service 0a38ef
    "_update_hosts_file": "The installer _update_host_file setting",
Packit Service 0a38ef
    "sssd": "The installer sssd setting",
Packit Service 0a38ef
    "dnsok": "The installer dnsok setting",
Packit Service 0a38ef
Packit Service 0a38ef
    "dm_password":  "Directory Manager password",
Packit Service 0a38ef
    "password": "Admin user kerberos password",
Packit Service 0a38ef
    "ip_addresses": "List of Master Server IP Addresses",
Packit Service 0a38ef
    "domain": "Primary DNS domain of the IPA deployment",
Packit Service 0a38ef
    "realm": "Kerberos realm name of the IPA deployment",
Packit Service 0a38ef
    "hostname": "Fully qualified name of this host",
Packit Service 0a38ef
    "ca_cert_file": [
Packit Service 0a38ef
        "A CA certificate to use. Do not acquire the IPA CA certificate via",
Packit Service 0a38ef
        "automated means"
Packit Service 0a38ef
    ],
Packit Service 0a38ef
    "ca_cert_files": [
Packit Service 0a38ef
        "List of files containing CA certificates for the service certificate",
Packit Service 0a38ef
        "files"
Packit Service 0a38ef
    ],
Packit Service 0a38ef
    "no_host_dns": "Do not use DNS for hostname lookup during installation",
Packit Service 0a38ef
    "setup_adtrust": "Configure AD trust capability",
Packit Service 0a38ef
    "setup_ca": "Configure a dogtag CA",
Packit Service 0a38ef
    "setup_kra": "Configure a dogtag KRA",
Packit Service 0a38ef
    "setup_dns": "Configure bind with our zone",
Packit Service 0a38ef
    "force_join": "Force client enrollment even if already enrolled",
Packit Service 0a38ef
    "subject_base": [
Packit Service 0a38ef
        "The certificate subject base (default O=<realm-name>).",
Packit Service 0a38ef
        "RDNs are in LDAP order (most specific RDN first)."
Packit Service 0a38ef
    ],
Packit Service 0a38ef
    "server": "Fully qualified name of IPA server to enroll to",
Packit Service 0a38ef
    "dirman_password": "Directory Manager (master) password",
Packit Service 0a38ef
    "no_pkinit": "Disable pkinit setup steps",
Packit Service 0a38ef
    "no_ui_redirect": "Do not automatically redirect to the Web UI",
Packit Service 0a38ef
    "external_ca": "External ca setting",
Packit Service 0a38ef
    "setup_adtrust": "Configure AD trust capability",
Packit Service 0a38ef
    "external_cert_files": [
Packit Service 0a38ef
      "File containing the IPA CA certificate and the external CA certificate",
Packit Service 0a38ef
      "chain"
Packit Service 0a38ef
    ],
Packit Service 0a38ef
    "reverse_zones": "The reverse DNS zones to use",
Packit Service 0a38ef
    "no_reverse": "Do not create new reverse DNS zone",
Packit Service 0a38ef
    "auto_reverse": "Create necessary reverse zones",
Packit Service 0a38ef
    "forwarders": "Add DNS forwarders",
Packit Service 0a38ef
    "no_forwarders": "Do not add any DNS forwarders, use root servers instead",
Packit Service 0a38ef
    "auto_forwarders": "Use DNS forwarders configured in /etc/resolv.conf",
Packit Service 0a38ef
    "forward_policy": "DNS forwarding policy for global forwarders",
Packit Service 0a38ef
    "enable_compat": "Enable support for trusted domains for old clients",
Packit Service 0a38ef
    "netbios_name": "NetBIOS name of the IPA domain",
Packit Service 0a38ef
    "rid_base": "Start value for mapping UIDs and GIDs to RIDs",
Packit Service 0a38ef
    "secondary_rid_base": [
Packit Service 0a38ef
        "Start value of the secondary range for mapping UIDs and GIDs to RIDs"
Packit Service 0a38ef
    ],
Packit Service 0a38ef
    "pki_config_override": "Path to ini file with config overrides",
Packit Service 0a38ef
    "servers": "Fully qualified name of IPA servers to enroll to",
Packit Service 0a38ef
    "hidden_replica": "Install a hidden replica",
Packit Service 0a38ef
    "dirsrv_config_file": [
Packit Service 0a38ef
        "The path to LDIF file that will be used to modify configuration of",
Packit Service 0a38ef
        "dse.ldif during installation of the directory server instance"
Packit Service 0a38ef
    ],
Packit Service 0a38ef
    "dirsrv_cert_files": [
Packit Service 0a38ef
        "Files containing the Directory Server SSL certificate and private key"
Packit Service 0a38ef
    ],
Packit Service 0a38ef
    "http_cert_files": [
Packit Service 0a38ef
        "File containing the Apache Server SSL certificate and private key"
Packit Service 0a38ef
    ],
Packit Service 0a38ef
    "pkinit_cert_files": [
Packit Service 0a38ef
        "File containing the Kerberos KDC SSL certificate and private key"
Packit Service 0a38ef
    ],
Packit Service 0a38ef
    "no_ntp": "Do not configure ntp",
Packit Service 0a38ef
    "ntp_servers": "ntp servers to use",
Packit Service 0a38ef
    "ntp_pool": "ntp server pool to use",
Packit Service 0a38ef
    "no_dnssec_validation": "Disable DNSSEC validation",
Packit Service 0a38ef
    "master": "Master host name",
Packit Service 0a38ef
    "master_password": "kerberos master password (normally autogenerated)",
Packit Service 0a38ef
    "principal": [
Packit Service 0a38ef
        "User Principal allowed to promote replicas and join IPA realm"
Packit Service 0a38ef
    ],
Packit Service 0a38ef
    "dirsrv_pin": "The password to unlock the Directory Server private key",
Packit Service 0a38ef
    "http_pin": "The password to unlock the Apache Server private key",
Packit Service 0a38ef
    "pkinit_pin": "The password to unlock the Kerberos KDC private key",
Packit Service 0a38ef
    "dirsrv_cert_name":
Packit Service 0a38ef
        "Name of the Directory Server SSL certificate to install",
Packit Service 0a38ef
    "http_cert_name": "Name of the Apache Server SSL certificate to install",
Packit Service 0a38ef
    "pkinit_cert_name": "Name of the Kerberos KDC SSL certificate to install",
Packit Service 0a38ef
    "keytab": "Path to backed up keytab from previous enrollment",
Packit Service 0a38ef
    "mkhomedir": "Create home directories for users on their first login",
Packit Service 0a38ef
    "adtrust_netbios_name": "The adtrust netbios_name setting",
Packit Service 0a38ef
    "adtrust_reset_netbios_name": "The adtrust reset_netbios_name setting",
Packit Service 0a38ef
    "zonemgr":
Packit Service 0a38ef
        "DNS zone manager e-mail address. Defaults to hostmaster@DOMAIN",
Packit Service 0a38ef
    "ssh_trust_dns": "Configure OpenSSH client to trust DNS SSHFP records",
Packit Service 0a38ef
    "dns_ip_addresses": "The dns ip_addresses setting",
Packit Service 0a38ef
    "dns_reverse_zones": "The dns reverse_zones setting",
Packit Service 0a38ef
    "no_ssh": "Do not configure OpenSSH client",
Packit Service 0a38ef
    "no_sshd": "Do not configure OpenSSH server",
Packit Service 0a38ef
    "no_dns_sshfp": "Do not automatically create DNS SSHFP records",
Packit Service 0a38ef
    "allow_zone_overlap": "Create DNS zone even if it already exists",
Packit Service 0a38ef
    "skip_conncheck": "Skip connection check to remote master",
Packit Service 0a38ef
    "idstart": "The starting value for the IDs range (default random)",
Packit Service 0a38ef
    "idmax": "The max value for the IDs range (default idstart+199999)",
Packit Service 0a38ef
    "no_hbac_allow": "Don't install allow_all HBAC rule",
Packit Service 0a38ef
    "domainlevel": "The domain level",
Packit Service 0a38ef
    "external_ca_type": "Type of the external CA",
Packit Service 0a38ef
    "external_ca_profile": [
Packit Service 0a38ef
        "Specify the certificate profile/template to use at the external CA"
Packit Service 0a38ef
    ],
Packit Service 0a38ef
    "force": "Installer force parameter",
Packit Service 0a38ef
    "ca_signing_algorithm": "Signing algorithm of the IPA CA certificate",
Packit Service 0a38ef
    "debug": "Turn on extra debugging",
Packit Service 0a38ef
    "basedn": "The basedn of the IPA server (of the form dc=example,dc=com)",
Packit Service 0a38ef
    "allow_repair": [
Packit Service 0a38ef
      "Allow repair of already joined hosts. Contrary to ipaclient_force_join",
Packit Service 0a38ef
      "the host entry will not be changed on the server"
Packit Service 0a38ef
    ],
Packit Service 0a38ef
    "backup": "File to backup",
Packit Service 0a38ef
    "fqdn": [
Packit Service 0a38ef
        "The fully-qualified hostname of the host to add/modify/remove"
Packit Service 0a38ef
    ],
Packit Service 0a38ef
    "certificates": "A list of host certificates",
Packit Service 0a38ef
    "sshpubkey": "The SSH public key for the host",
Packit Service 0a38ef
    "ipaddress": "The IP address for the host",
Packit Service 0a38ef
    "random": "Generate a random password to be used in bulk enrollment",
Packit Service 0a38ef
    "state": "The desired host state",
Packit Service 0a38ef
    "kdc": "The name or address of the host running the KDC",
Packit Service 0a38ef
    "admin_keytab": "The path to a local admin keytab",
Packit Service 0a38ef
    "kinit_attempts": "Repeat the request for host Kerberos ticket X times",
Packit Service 0a38ef
    "automount_location": "The automount location",
Packit Service 0a38ef
    "firefox_dir": [
Packit Service 0a38ef
        "Specify directory where Firefox is installed (for example",
Packit Service 0a38ef
        "'/usr/lib/firefox')"
Packit Service 0a38ef
    ],
Packit Service 0a38ef
    "client_domain": "Primary DNS domain of the IPA deployment",
Packit Service 0a38ef
    "nisdomain": "The NIS domain name",
Packit Service 0a38ef
    "ca_enabled": "Whether the Certificate Authority is enabled or not",
Packit Service 0a38ef
    "on_master": "Whether the configuration is done on the master or not",
Packit Service 0a38ef
    "enable_dns_updates": [
Packit Service 0a38ef
        "Configures the machine to attempt dns updates when the ip address",
Packit Service 0a38ef
        "changes"
Packit Service 0a38ef
    ],
Packit Service 0a38ef
    "all_ip_addresses": [
Packit Service 0a38ef
        "All routable IP addresses configured on any interface will be added",
Packit Service 0a38ef
        "to DNS"
Packit Service 0a38ef
    ],
Packit Service 0a38ef
    "request_cert": "Request certificate for the machine",
Packit Service 0a38ef
    "preserve_sssd": "Preserve old SSSD configuration if possible",
Packit Service 0a38ef
    "no_sudo": "Do not configure SSSD as data source for sudo",
Packit Service 0a38ef
    "fixed_primary":
Packit Service 0a38ef
        "Configure sssd to use fixed server as primary IPA server",
Packit Service 0a38ef
    "permit": "Disable access rules by default, permit all access",
Packit Service 0a38ef
    "no_krb5_offline_passwords": [
Packit Service 0a38ef
        "Configure SSSD not to store user password when the server is offline"
Packit Service 0a38ef
    ],
Packit Service 0a38ef
    "force_ntpd": [
Packit Service 0a38ef
        "Stop and disable any time&date synchronization services besides ntpd",
Packit Service 0a38ef
        "Deprecated since 4.7"
Packit Service 0a38ef
    ],
Packit Service 0a38ef
    "no_nisdomain": "Do not configure NIS domain name",
Packit Service 0a38ef
    "configure_firefox": "Configure Firefox to use IPA domain credentials",
Packit Service 0a38ef
}
Packit Service 0a38ef
Packit Service 0a38ef
Packit Service 0a38ef
def gen_module_docs(module_in):
Packit Service 0a38ef
    with open(module_in) as in_f:
Packit Service 0a38ef
        in_lines = in_f.readlines()
Packit Service 0a38ef
Packit Service 0a38ef
    arg_spec = False
Packit Service 0a38ef
    args = []
Packit Service 0a38ef
    i = 0
Packit Service 0a38ef
    while i < len(in_lines):
Packit Service 0a38ef
        line = in_lines[i]
Packit Service 0a38ef
        stripped = line.strip()
Packit Service 0a38ef
        # print("stripped: %s" % repr(stripped))
Packit Service 0a38ef
        if stripped.startswith("# "):
Packit Service 0a38ef
            pass
Packit Service 0a38ef
        elif stripped.startswith("argument_spec=dict()"):
Packit Service 0a38ef
            pass
Packit Service 0a38ef
        elif stripped.startswith("argument_spec=dict("):
Packit Service 0a38ef
            arg_spec = True
Packit Service 0a38ef
        elif stripped.startswith("),") and arg_spec:
Packit Service 0a38ef
            arg_spec = False
Packit Service 0a38ef
        elif arg_spec:
Packit Service 0a38ef
            # if not "dict=(" in stripped:
Packit Service 0a38ef
            #     print("%s: Bad argument dict line '%s'" % (module_in,
Packit Service 0a38ef
            #                                                stripped))
Packit Service 0a38ef
            while ")," not in stripped and i < len(in_lines) - 1:
Packit Service 0a38ef
                next_stripped = in_lines[i+1].strip()
Packit Service 0a38ef
                if not next_stripped.startswith("# "):
Packit Service 0a38ef
                    stripped += next_stripped
Packit Service 0a38ef
                i += 1
Packit Service 0a38ef
            # print("stripped: '%s'" % stripped)
Packit Service 0a38ef
Packit Service 0a38ef
            try:
Packit Service 0a38ef
                param, _dict = stripped.split("=", 1)
Packit Service 0a38ef
            except Exception:
Packit Service 0a38ef
                print("Failed to split line '%s'" % stripped)
Packit Service 0a38ef
                sys.exit(1)
Packit Service 0a38ef
Packit Service 0a38ef
            # print("_dict: '%s'" % _dict)
Packit Service 0a38ef
            if not _dict.startswith("dict(") or not _dict.endswith("),"):
Packit Service 0a38ef
                print("%s: Bad argument dict line 2 '%s'" % (module_in, _dict))
Packit Service 0a38ef
                sys.exit(1)
Packit Service 0a38ef
            else:
Packit Service 0a38ef
                _dict = _dict[5:-2]
Packit Service 0a38ef
Packit Service 0a38ef
            if param not in param_docs:
Packit Service 0a38ef
                print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
Packit Service 0a38ef
                print("%s: param '%s' is not in param_docs" % (module_in,
Packit Service 0a38ef
                                                               param))
Packit Service 0a38ef
                print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
Packit Service 0a38ef
                sys.exit(1)
Packit Service 0a38ef
Packit Service 0a38ef
            # print("param: '%s', dict: '%s'" % (param, _dict))
Packit Service 0a38ef
Packit Service 0a38ef
            opts = _dict.split(',')
Packit Service 0a38ef
            opts = [o.strip() for o in opts]
Packit Service 0a38ef
            required = False
Packit Service 0a38ef
            # no_log = False
Packit Service 0a38ef
            if "required=True" in opts:
Packit Service 0a38ef
                required = True
Packit Service 0a38ef
            # if "no_log=True" in opts:
Packit Service 0a38ef
            #     no_log = True
Packit Service 0a38ef
Packit Service 0a38ef
            # args.append([param, required, no_log])
Packit Service 0a38ef
            args.append([param, required])
Packit Service 0a38ef
        i += 1
Packit Service 0a38ef
Packit Service 0a38ef
    # print("%s: %s" % (module_in, repr(args)))
Packit Service 0a38ef
Packit Service 0a38ef
    def add_options(args):
Packit Service 0a38ef
        for param, required in args:
Packit Service 0a38ef
            out_lines.append("  %s:\n" % param)
Packit Service 0a38ef
            if isinstance(param_docs[param], list):
Packit Service 0a38ef
                out_lines.append("    description:\n")
Packit Service 0a38ef
                for x in param_docs[param]:
Packit Service 0a38ef
                    out_lines.append("      %s\n" % x)
Packit Service 0a38ef
            else:
Packit Service 0a38ef
                out_lines.append("    description: %s\n" % param_docs[param])
Packit Service 0a38ef
            out_lines.append("    required: %s\n" % ("yes", "no")[required])
Packit Service 0a38ef
Packit Service 0a38ef
    out_lines = []
Packit Service 0a38ef
    options = False
Packit Service 0a38ef
    in_options = False
Packit Service 0a38ef
    changed = False
Packit Service 0a38ef
    docs = False
Packit Service 0a38ef
    for line in in_lines:
Packit Service 0a38ef
        stripped = line.strip()
Packit Service 0a38ef
        if stripped.startswith("DOCUMENTATION = '''"):
Packit Service 0a38ef
            docs = True
Packit Service 0a38ef
        elif stripped.startswith("options:"):
Packit Service 0a38ef
            out_lines.append(line)
Packit Service 0a38ef
            add_options(args)
Packit Service 0a38ef
            options = True
Packit Service 0a38ef
            in_options = True
Packit Service 0a38ef
            changed = True
Packit Service 0a38ef
            continue
Packit Service 0a38ef
        elif stripped.startswith("author:"):
Packit Service 0a38ef
            if not options:
Packit Service 0a38ef
                add_options(args)
Packit Service 0a38ef
                options = True
Packit Service 0a38ef
                changed = True
Packit Service 0a38ef
            in_options = False
Packit Service 0a38ef
        elif stripped.startswith("'''"):
Packit Service 0a38ef
            if not options:
Packit Service 0a38ef
                add_options(args)
Packit Service 0a38ef
                options = True
Packit Service 0a38ef
                changed = True
Packit Service 0a38ef
            in_options = False
Packit Service 0a38ef
            docs = False
Packit Service 0a38ef
        elif docs and in_options:
Packit Service 0a38ef
            continue
Packit Service 0a38ef
Packit Service 0a38ef
        out_lines.append(line)
Packit Service 0a38ef
Packit Service 0a38ef
    print(module_in)
Packit Service 0a38ef
    # for line in out_lines:
Packit Service 0a38ef
    #     sys.stdout.write(line)
Packit Service 0a38ef
Packit Service 0a38ef
    if changed:
Packit Service 0a38ef
        with open(module_in, "w") as out_f:
Packit Service 0a38ef
            for line in out_lines:
Packit Service 0a38ef
                out_f.write(line)
Packit Service 0a38ef
Packit Service 0a38ef
Packit Service 0a38ef
gen_module_docs(sys.argv[1])