def main():
    ''' Main entry point for module execution
    '''

    ib_spec = dict(
        name=dict(required=True, ib_req=True),
        view=dict(default='default', aliases=['dns_view'], ib_req=True),
        ipv6addr=dict(aliases=['ipv6'], ib_req=True),
        ttl=dict(type='int'),
        extattrs=dict(type='dict'),
        comment=dict(),
    )

    argument_spec = dict(provider=dict(required=True),
                         state=dict(default='present',
                                    choices=['present', 'absent']))

    argument_spec.update(ib_spec)
    argument_spec.update(WapiModule.provider_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=True)

    wapi = WapiModule(module)
    result = wapi.run(NIOS_AAAA_RECORD, ib_spec)

    module.exit_json(**result)
def main():
    ''' Main entry point for module execution
    '''
    option_spec = dict(
        # one of name or num is required; enforced by the function options()
        name=dict(),
        num=dict(type='int'),

        value=dict(required=True),

        use_option=dict(type='bool', default=True),
        vendor_class=dict(default='DHCP')
    )

    ib_spec = dict(
        network=dict(required=True, aliases=['name', 'cidr'], ib_req=True),
        network_view=dict(default='default', ib_req=True),

        options=dict(type='list', elements='dict', options=option_spec, transform=options),

        extattrs=dict(type='dict'),
        comment=dict(),
        container=dict(type='bool', ib_req=True)
    )

    argument_spec = dict(
        provider=dict(required=True),
        state=dict(default='present', choices=['present', 'absent'])
    )

    argument_spec.update(ib_spec)
    argument_spec.update(WapiModule.provider_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=True)

    # to get the argument ipaddr
    obj_filter = dict([(k, module.params[k]) for k, v in iteritems(ib_spec) if v.get('ib_req')])
    network_type, ib_spec = check_ip_addr_type(obj_filter, ib_spec)

    wapi = WapiModule(module)
    # to check for vendor specific dhcp option
    ib_spec = check_vendor_specific_dhcp_option(module, ib_spec)

    result = wapi.run(network_type, ib_spec)

    module.exit_json(**result)
예제 #3
0
def main():
    ''' Main entry point for module execution
    '''
    option_spec = dict(
        # one of name or num is required; enforced by the function options()
        name=dict(),
        num=dict(type='int'),
        value=dict(required=True),
        use_option=dict(type='bool', default=True),
        vendor_class=dict(default='DHCP'))

    ib_spec = dict(name=dict(required=True),
                   ipaddr=dict(required=True, aliases=['ipaddr'], ib_req=True),
                   mac=dict(required=True, aliases=['mac'], ib_req=True),
                   network=dict(required=True, aliases=['network']),
                   network_view=dict(default='default',
                                     aliases=['network_view']),
                   options=dict(type='list',
                                elements='dict',
                                options=option_spec,
                                transform=options),
                   extattrs=dict(type='dict'),
                   comment=dict())

    argument_spec = dict(provider=dict(required=True),
                         state=dict(default='present',
                                    choices=['present', 'absent']))

    argument_spec.update(ib_spec)
    argument_spec.update(WapiModule.provider_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=True)

    # to get the argument ipaddr
    obj_filter = dict([(k, module.params[k]) for k, v in iteritems(ib_spec)
                       if v.get('ib_req')])
    # to modify argument based on ipaddr type i.e. IPV4/IPV6
    fixed_address_ip_type, ib_spec, module = validate_ip_addr_type(
        obj_filter['ipaddr'], ib_spec, module)

    wapi = WapiModule(module)

    result = wapi.run(fixed_address_ip_type, ib_spec)

    module.exit_json(**result)
예제 #4
0
def main():
    # Module entry point
    ib_spec = dict(
        name=dict(required=False),
        view=dict(aliases=['dns_view'], ib_req=True),
        ipv4addr=dict(aliases=['ipv4'], ib_req=True),
        ipv6addr=dict(aliases=['ipv6'], ib_req=True),
        ptrdname=dict(ib_req=True),

        ttl=dict(type='int'),

        extattrs=dict(type='dict'),
        comment=dict(),
    )

    argument_spec = dict(
        provider=dict(required=True),
        state=dict(default='present', choices=['present', 'absent'])
    )

    argument_spec.update(ib_spec)
    argument_spec.update(WapiModule.provider_spec)

    mutually_exclusive = [('ipv4addr', 'ipv6addr')]
    required_one_of = [
        ['ipv4addr', 'ipv6addr']
    ]

    module = AnsibleModule(argument_spec=argument_spec,
                           mutually_exclusive=mutually_exclusive,
                           supports_check_mode=True,
                           required_one_of=required_one_of)

    if module.params['ipv4addr']:
        del ib_spec['ipv6addr']
    elif module.params['ipv6addr']:
        del ib_spec['ipv4addr']

    wapi = WapiModule(module)
    result = wapi.run(NIOS_PTR_RECORD, ib_spec)

    module.exit_json(**result)
def main():
    ''' Main entry point for module execution
    '''
    grid_spec = dict(
        name=dict(required=True),
    )

    ib_spec = dict(
        fqdn=dict(required=True, aliases=['name'], ib_req=True, update=False),
        zone_format=dict(default='FORWARD', aliases=['zone_format'], ib_req=False),
        view=dict(default='default', aliases=['dns_view'], ib_req=True),

        grid_primary=dict(type='list', elements='dict', options=grid_spec),
        grid_secondaries=dict(type='list', elements='dict', options=grid_spec),
        ns_group=dict(),
        restart_if_needed=dict(type='bool'),

        extattrs=dict(type='dict'),
        comment=dict()
    )

    argument_spec = dict(
        provider=dict(required=True),
        state=dict(default='present', choices=['present', 'absent'])
    )

    argument_spec.update(ib_spec)
    argument_spec.update(WapiModule.provider_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=True,
                           mutually_exclusive=[
                               ['ns_group', 'grid_primary'],
                               ['ns_group', 'grid_secondaries']
                           ])

    wapi = WapiModule(module)
    result = wapi.run(NIOS_ZONE, ib_spec)

    module.exit_json(**result)
def main():
    ''' Main entry point for module execution
    '''

    ib_spec = dict(
        name=dict(required=True, ib_req=True),
        view=dict(default='default', aliases=['dns_view'], ib_req=True),

        order=dict(type='int', ib_req=True),
        preference=dict(type='int', ib_req=True),
        replacement=dict(ib_req=True),
        services=dict(),
        flags=dict(),
        regexp=dict(),

        ttl=dict(type='int'),

        extattrs=dict(type='dict'),
        comment=dict(),
    )

    argument_spec = dict(
        provider=dict(required=True),
        state=dict(default='present', choices=['present', 'absent'])
    )

    argument_spec.update(ib_spec)
    argument_spec.update(WapiModule.provider_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=True)

    wapi = WapiModule(module)
    result = wapi.run('record:naptr', ib_spec)

    module.exit_json(**result)
예제 #7
0
def main():
    ''' Main entry point for module execution
    '''
    ipv4addr_spec = dict(ipv4addr=dict(required=True,
                                       aliases=['address'],
                                       ib_req=True),
                         configure_for_dhcp=dict(type='bool',
                                                 required=False,
                                                 aliases=['dhcp'],
                                                 ib_req=True),
                         mac=dict(required=False, aliases=['mac'],
                                  ib_req=True),
                         add=dict(type='bool', aliases=['add'],
                                  required=False),
                         remove=dict(type='bool',
                                     aliases=['remove'],
                                     required=False))

    ipv6addr_spec = dict(
        ipv6addr=dict(required=True, aliases=['address'], ib_req=True),
        configure_for_dhcp=dict(type='bool',
                                required=False,
                                aliases=['configure_for_dhcp'],
                                ib_req=True),
        mac=dict(required=False, aliases=['mac'], ib_req=True))

    ib_spec = dict(
        name=dict(required=True, ib_req=True),
        view=dict(default='default', aliases=['dns_view'], ib_req=True),
        ipv4addrs=dict(type='list',
                       aliases=['ipv4'],
                       elements='dict',
                       options=ipv4addr_spec,
                       transform=ipv4addrs),
        ipv6addrs=dict(type='list',
                       aliases=['ipv6'],
                       elements='dict',
                       options=ipv6addr_spec,
                       transform=ipv6addrs),
        configure_for_dns=dict(type='bool',
                               default=True,
                               required=False,
                               aliases=['dns'],
                               ib_req=True),
        aliases=dict(type='list'),
        ttl=dict(type='int'),
        extattrs=dict(type='dict'),
        comment=dict(),
    )

    argument_spec = dict(provider=dict(required=True),
                         state=dict(default='present',
                                    choices=['present', 'absent']))

    argument_spec.update(ib_spec)
    argument_spec.update(WapiModule.provider_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=True)

    wapi = WapiModule(module)
    result = wapi.run(NIOS_HOST_RECORD, ib_spec)

    module.exit_json(**result)
def main():
    '''entrypoint for module execution.'''
    argument_spec = dict(
        provider=dict(required=True),
        state=dict(default='present', choices=['present', 'absent']),
    )

    # cleanup tsig fields
    def clean_tsig(ext):
        if 'tsig_key' in ext and not ext['tsig_key']:
            del ext['tsig_key']
        if 'tsig_key' not in ext and 'tsig_key_name' in ext and not ext[
                'tsig_key_name']:
            del ext['tsig_key_name']
        if 'tsig_key' not in ext and 'tsig_key_alg' in ext:
            del ext['tsig_key_alg']

    def clean_grid_member(member):
        if member['preferred_primaries']:
            for ext in member['preferred_primaries']:
                clean_tsig(ext)
        if member['enable_preferred_primaries'] is False:
            del member['enable_preferred_primaries']
            del member['preferred_primaries']
        if member['lead'] is False:
            del member['lead']
        if member['grid_replicate'] is False:
            del member['grid_replicate']

    def ext_primaries_transform(module):
        if module.params['external_primaries']:
            for ext in module.params['external_primaries']:
                clean_tsig(ext)
        return module.params['external_primaries']

    def ext_secondaries_transform(module):
        if module.params['external_secondaries']:
            for ext in module.params['external_secondaries']:
                clean_tsig(ext)
        return module.params['external_secondaries']

    def grid_primary_preferred_transform(module):
        for member in module.params['grid_primary']:
            clean_grid_member(member)
        return module.params['grid_primary']

    def grid_secondaries_preferred_primaries_transform(module):
        for member in module.params['grid_secondaries']:
            clean_grid_member(member)
        return module.params['grid_secondaries']

    extserver_spec = dict(address=dict(required=True, ib_req=True),
                          name=dict(required=True, ib_req=True),
                          stealth=dict(type='bool', default=False),
                          tsig_key=dict(),
                          tsig_key_alg=dict(
                              choices=['HMAC-MD5', 'HMAC-SHA256'],
                              default='HMAC-MD5'),
                          tsig_key_name=dict(required=True))

    memberserver_spec = dict(
        name=dict(required=True, ib_req=True),
        enable_preferred_primaries=dict(type='bool', default=False),
        grid_replicate=dict(type='bool', default=False),
        lead=dict(type='bool', default=False),
        preferred_primaries=dict(type='list',
                                 elements='dict',
                                 options=extserver_spec,
                                 default=[]),
        stealth=dict(type='bool', default=False),
    )

    ib_spec = dict(
        name=dict(required=True, ib_req=True),
        grid_primary=dict(type='list',
                          elements='dict',
                          options=memberserver_spec,
                          transform=grid_primary_preferred_transform),
        grid_secondaries=dict(
            type='list',
            elements='dict',
            options=memberserver_spec,
            transform=grid_secondaries_preferred_primaries_transform),
        external_primaries=dict(type='list',
                                elements='dict',
                                options=extserver_spec,
                                transform=ext_primaries_transform),
        external_secondaries=dict(type='list',
                                  elements='dict',
                                  options=extserver_spec,
                                  transform=ext_secondaries_transform),
        is_grid_default=dict(type='bool', default=False),
        use_external_primary=dict(type='bool', default=False),
        extattrs=dict(),
        comment=dict(),
    )

    argument_spec.update(ib_spec)
    argument_spec.update(WapiModule.provider_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=True)

    wapi = WapiModule(module)
    result = wapi.run(NIOS_NSGROUP, ib_spec)

    module.exit_json(**result)
def main():
    ''' Main entry point for module execution
    '''
    ipv4_spec = dict(
        address=dict(),
        subnet_mask=dict(),
        gateway=dict(),
    )

    ipv6_spec = dict(
        virtual_ip=dict(),
        cidr_prefix=dict(type='int'),
        gateway=dict(),
    )

    port_spec = dict(
        auto_port_setting_enabled=dict(type='bool'),
        duplex=dict(),
        speed=dict(),
    )

    lan2_port_spec = dict(
        enabled=dict(type='bool'),
        network_setting=dict(type='list', elements='dict', options=ipv4_spec),
        v6_network_setting=dict(type='list',
                                elements='dict',
                                options=ipv6_spec),
    )

    ha_port_spec = dict(
        ha_ip_address=dict(),
        ha_port_setting=dict(type='list', elements='dict', options=port_spec),
        lan_port_setting=dict(type='list', elements='dict', options=port_spec),
        mgmt_lan=dict(),
        mgmt_ipv6addr=dict(),
    )

    node_spec = dict(
        lan2_physical_setting=dict(type='list',
                                   elements='dict',
                                   options=port_spec),
        lan_ha_port_setting=dict(type='list',
                                 elements='dict',
                                 options=ha_port_spec),
        mgmt_network_setting=dict(type='list',
                                  elements='dict',
                                  options=ipv4_spec),
        v6_mgmt_network_setting=dict(type='list',
                                     elements='dict',
                                     options=ipv6_spec),
    )

    mgmt_port_spec = dict(
        enabled=dict(type='bool'),
        security_access_enabled=dict(type='bool'),
        vpn_enabled=dict(type='bool'),
    )

    syslog_spec = dict(
        address=dict(),
        category_list=dict(type='list'),
        connection_type=dict(default='UDP'),
        local_interface=dict(default='ANY'),
        message_node_id=dict(default='LAN'),
        message_source=dict(default='ANY'),
        only_category_list=dict(type='bool'),
        port=dict(type='int', default=514),
        severity=dict(default='DEBUG'),
    )

    hw_spec = dict(
        hwmodel=dict(),
        hwtype=dict(),
    )

    pre_prov_spec = dict(
        hardware_info=dict(type='list', elements='dict', options=hw_spec),
        licenses=dict(type='list'),
    )

    ib_spec = dict(
        host_name=dict(required=True, aliases=['name'], ib_req=True),
        vip_setting=dict(type='list', elements='dict', options=ipv4_spec),
        ipv6_setting=dict(type='list', elements='dict', options=ipv6_spec),
        config_addr_type=dict(default='IPV4'),
        comment=dict(),
        enable_ha=dict(type='bool', default=False),
        router_id=dict(type='int'),
        lan2_enabled=dict(type='bool', default=False),
        lan2_port_setting=dict(type='list',
                               elements='dict',
                               options=lan2_port_spec),
        platform=dict(default='INFOBLOX'),
        node_info=dict(type='list', elements='dict', options=node_spec),
        mgmt_port_setting=dict(type='list',
                               elements='dict',
                               options=mgmt_port_spec),
        upgrade_group=dict(default='Default'),
        use_syslog_proxy_setting=dict(type='bool'),
        external_syslog_server_enable=dict(type='bool'),
        syslog_servers=dict(type='list', elements='dict', options=syslog_spec),
        pre_provisioning=dict(type='list',
                              elements='dict',
                              options=pre_prov_spec),
        extattrs=dict(type='dict'),
        create_token=dict(type='bool', default=False),
    )

    argument_spec = dict(provider=dict(required=True),
                         state=dict(default='present',
                                    choices=['present', 'absent']))

    argument_spec.update(ib_spec)
    argument_spec.update(WapiModule.provider_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=True)

    wapi = WapiModule(module)
    result = wapi.run(NIOS_MEMBER, ib_spec)
    module.exit_json(**result)