def main(): ansible_module = AnsibleModule( argument_spec=dict( hostname=dict(required=False), setup_dns=dict(required=True, type='bool'), setup_ca=dict(required=True, type='bool'), ), ) ansible_module._ansible_debug = True setup_logging() ansible_log = AnsibleModuleLog(ansible_module) # set values ############################################################# options.host_name = ansible_module.params.get('hostname') options.setup_dns = ansible_module.params.get('setup_dns') options.setup_ca = ansible_module.params.get('setup_ca') # Configuration for ipalib, we will bootstrap and finalize later, after # we are sure we have the configuration file ready. cfg = dict( context='installer', confdir=paths.ETC_IPA, in_server=True, # make sure host name specified by user is used instead of default host=options.host_name, ) if options.setup_ca: # we have an IPA-integrated CA cfg['ca_host'] = options.host_name api.bootstrap(**cfg) api.finalize() api.Backend.ldap2.connect() # setup ds ###################################################### fstore = sysrestore.FileStore(paths.SYSRESTORE) if hasattr(tasks, "configure_tmpfiles"): # Make sure the files we crated in /var/run are recreated at startup tasks.configure_tmpfiles() if hasattr(service, "enable_services"): # Enable configured services and update DNS SRV records service.enable_services(options.host_name) api.Command.dns_update_system_records() if not options.setup_dns: # After DNS and AD trust are configured and services are # enabled, create a dummy instance to dump DNS configuration. bind = bindinstance.BindInstance(fstore) bind.create_file_with_system_records() with redirect_stdout(ansible_log): services.knownservices.ipa.enable() ansible_module.exit_json(changed=True)
def main(): ansible_module = AnsibleModule( argument_spec=dict( # basic ip_addresses=dict(required=False, type='list', default=[]), domain=dict(required=True), realm=dict(required=True), hostname=dict(required=True), # server setup_dns=dict(required=True, type='bool'), setup_ca=dict(required=True, type='bool'), # dns zonemgr=dict(required=False), forwarders=dict(required=True, type='list'), forward_policy=dict(default='first', choices=['first', 'only']), no_dnssec_validation=dict(required=False, type='bool', default=False), # additional dns_ip_addresses=dict(required=True, type='list'), dns_reverse_zones=dict(required=True, type='list'), ), ) ansible_module._ansible_debug = True setup_logging() ansible_log = AnsibleModuleLog(ansible_module) # set values ############################################################ # basic options.ip_addresses = ansible_module_get_parsed_ip_addresses( ansible_module) options.domain_name = ansible_module.params.get('domain') options.realm_name = ansible_module.params.get('realm') options.host_name = ansible_module.params.get('hostname') # server options.setup_dns = ansible_module.params.get('setup_dns') options.setup_ca = ansible_module.params.get('setup_ca') # dns options.zonemgr = ansible_module.params.get('zonemgr') options.forwarders = ansible_module.params.get('forwarders') options.forward_policy = ansible_module.params.get('forward_policy') options.no_dnssec_validation = ansible_module.params.get( 'no_dnssec_validation') # additional dns.ip_addresses = ansible_module_get_parsed_ip_addresses( ansible_module, 'dns_ip_addresses') dns.reverse_zones = ansible_module.params.get('dns_reverse_zones') # init ################################################################## fstore = sysrestore.FileStore(paths.SYSRESTORE) api_Backend_ldap2(options.host_name, options.setup_ca, connect=True) # setup dns ############################################################# with redirect_stdout(ansible_log): if options.setup_dns: dns.install(False, False, options) else: # Create a BIND instance bind = bindinstance.BindInstance(fstore) bind.set_output(ansible_log) bind.setup(options.host_name, options.ip_addresses, options.realm_name, options.domain_name, (), 'first', (), zonemgr=options.zonemgr, no_dnssec_validation=options.no_dnssec_validation) bind.create_file_with_system_records() # done ################################################################## ansible_module.exit_json(changed=True)