This repository has been archived by the owner on Apr 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e757cf8
commit aa26139
Showing
21 changed files
with
1,469 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2019 Red Hat | ||
# GNU General Public License v3.0+ | ||
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
""" | ||
The module file for junos_facts | ||
""" | ||
|
||
from __future__ import absolute_import, division, print_function | ||
__metaclass__ = type | ||
|
||
|
||
ANSIBLE_METADATA = {'metadata_version': '1.1', | ||
'status': ['preview'], | ||
'supported_by': 'network'} | ||
|
||
|
||
DOCUMENTATION = """ | ||
--- | ||
module: junos_facts | ||
version_added: 2.9 | ||
short_description: Get facts about junos devices. | ||
description: | ||
- Collects facts from network devices running the junos operating | ||
system. This module places the facts gathered in the fact tree keyed by the | ||
respective resource name. The facts module will always collect a | ||
base set of facts from the device and can enable or disable | ||
collection of additional facts. | ||
author: Daniel Mellado (@danielmellado) | ||
options: | ||
gather_subset: | ||
description: | ||
- When supplied, this argument will restrict the facts collected | ||
to a given subset. Possible values for this argument include | ||
all, min, hardware, config, legacy, and interfaces. Can specify a | ||
list of values to include a larger subset. Values can also be used | ||
with an initial C(M(!)) to specify that a specific subset should | ||
not be collected. | ||
required: false | ||
default: 'all' | ||
version_added: "2.2" | ||
gather_network_resources: | ||
description: | ||
- When supplied, this argument will restrict the facts collected | ||
to a given subset. Possible values for this argument include | ||
all and the resources like interfaces, vlans etc. | ||
Can specify a list of values to include a larger subset. Values | ||
can also be used with an initial C(M(!)) to specify that a | ||
specific subset should not be collected. | ||
required: false | ||
version_added: "2.9" | ||
""" | ||
|
||
EXAMPLES = """ | ||
# Gather all facts | ||
- junos_facts: | ||
gather_subset: all | ||
gather_network_resources: all | ||
# Collect only the vlans facts | ||
- junos_facts: | ||
gather_subset: | ||
- !all | ||
- !min | ||
gather_network_resources: | ||
- vlans | ||
# Do not collect vlans facts | ||
- junos_facts: | ||
gather_network_resources: | ||
- "!vlans" | ||
# Collect vlans and minimal default facts | ||
- junos_facts: | ||
gather_subset: min | ||
gather_network_resources: vlans | ||
""" | ||
|
||
RETURN = """ | ||
See the respective resource module parameters for the tree. | ||
""" | ||
|
||
from ansible.module_utils.basic import AnsibleModule | ||
from ansible.module_utils.network.junos.argspec.facts.facts import FactsArgs | ||
from ansible.module_utils.network.junos.facts.facts import Facts | ||
|
||
|
||
def main(): | ||
""" | ||
Main entry point for module execution | ||
:returns: ansible_facts | ||
""" | ||
module = AnsibleModule(argument_spec=FactsArgs.argument_spec, | ||
supports_check_mode=True) | ||
warnings = ['default value for `gather_subset` ' | ||
'will be changed to `min` from `!config` v2.11 onwards'] | ||
|
||
result = Facts(module).get_facts() | ||
|
||
ansible_facts, additional_warnings = result | ||
warnings.extend(additional_warnings) | ||
|
||
module.exit_json(ansible_facts=ansible_facts, warnings=warnings) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,274 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2019 Red Hat | ||
# GNU General Public License v3.0+ | ||
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
############################################# | ||
# WARNING # | ||
############################################# | ||
# | ||
# This file is auto generated by the resource | ||
# module builder playbook. | ||
# | ||
# Do not edit this file manually. | ||
# | ||
# Changes to this file will be over written | ||
# by the resource module builder. | ||
# | ||
# Changes should be made in the model used to | ||
# generate this file or in the resource module | ||
# builder template. | ||
# | ||
############################################# | ||
|
||
""" | ||
The module file for junos_vlans | ||
""" | ||
|
||
from __future__ import absolute_import, division, print_function | ||
__metaclass__ = type | ||
|
||
ANSIBLE_METADATA = { | ||
'metadata_version': '1.1', | ||
'status': ['preview'], | ||
'supported_by': 'network' | ||
} | ||
|
||
DOCUMENTATION = """ | ||
--- | ||
module: junos_vlans | ||
version_added: 2.9 | ||
short_description: Create and manage VLAN configurations on Junos OS | ||
description: This module creates and manages VLAN configurations on Junos OS. | ||
author: Daniel Mellado (@danielmellado) | ||
requirements: | ||
- ncclient (>=v0.6.4) | ||
notes: | ||
- This module requires the netconf system service be enabled on | ||
the remote device being managed | ||
- Tested against Junos OS 18.4R1 | ||
- This module works with connection C(netconf). See L(the Junos OS Platform Options,../network/user_guide/platform_junos.html). | ||
options: | ||
config: | ||
description: A dictionary of Vlan options | ||
type: list | ||
elements: dict | ||
suboptions: | ||
vlan_id: | ||
description: | ||
- IEEE 802.1q VLAN identifier for VLAN (1..4094). | ||
type: int | ||
required: true | ||
name: | ||
description: | ||
- Name of VLAN. | ||
type: str | ||
required: true | ||
description: | ||
description: | ||
- Text description of VLANs | ||
state: | ||
description: | ||
- The state the configuration should be left in. | ||
type: str | ||
choices: | ||
- merged | ||
- replaced | ||
- overridden | ||
- deleted | ||
default: merged | ||
""" | ||
EXAMPLES = """ | ||
Using merged | ||
############# | ||
# Before State | ||
# ------------ | ||
# | ||
# admin# show vlans | ||
# vlan-2 { | ||
# vlan-id 2; | ||
# } | ||
# vlan-3 { | ||
# vlan-id 3; | ||
# } | ||
- name: Merge JUNOS vlan | ||
junos_vlans: | ||
config: | ||
- name: vlan-1 | ||
vlan-id: 1 | ||
state: merged | ||
# After State | ||
# ----------- | ||
# | ||
# admin# show vlans | ||
# vlan-1 { | ||
# vlan-id 1; | ||
# } | ||
# vlan-2 { | ||
# vlan-id 2; | ||
# } | ||
# vlan-3 { | ||
# vlan-id 3; | ||
# } | ||
Using replaced | ||
############# | ||
# Before State | ||
# ------------ | ||
# | ||
# admin# show vlans | ||
# vlan-1 { | ||
# vlan-id 1; | ||
# } | ||
# vlan-2 { | ||
# vlan-id 2; | ||
# } | ||
# vlan-3 { | ||
# vlan-id 3; | ||
# } | ||
- name: Replace JUNOS vlan | ||
junos_vlans: | ||
config: | ||
- name: vlan-1 | ||
vlan-id: 10 | ||
- name: vlan-3 | ||
vlan-id: 30 | ||
state: replaced | ||
# After State | ||
# ----------- | ||
# | ||
# admin# show vlans | ||
# vlan-1 { | ||
# vlan-id 10; | ||
# } | ||
# vlan-2 { | ||
# vlan-id 2; | ||
# } | ||
# vlan-3 { | ||
# vlan-id 30; | ||
# } | ||
Using overridden | ||
################ | ||
# Before State | ||
# ------------ | ||
# | ||
# admin# show vlans | ||
# vlan-1 { | ||
# vlan-id 1; | ||
# } | ||
# vlan-2 { | ||
# vlan-id 2; | ||
# } | ||
# vlan-3 { | ||
# vlan-id 3; | ||
# } | ||
- name: Override JUNOS vlan | ||
junos_vlans: | ||
config: | ||
- name: vlan-4 | ||
vlan-id: 100 | ||
- name: vlan-2 | ||
vlan-id: 200 | ||
state: overridden | ||
# After State | ||
# ----------- | ||
# | ||
# admin# show vlans | ||
# vlan-2 { | ||
# vlan-id 200; | ||
# } | ||
# vlan-4 { | ||
# vlan-id 100; | ||
# } | ||
Using deleted | ||
############# | ||
# Before State | ||
# ------------ | ||
# | ||
# admin# show vlans | ||
# vlan-1 { | ||
# vlan-id 1; | ||
# } | ||
# vlan-2 { | ||
# vlan-id 2; | ||
# } | ||
# vlan-3 { | ||
# vlan-id 3; | ||
# } | ||
- name: Delete JUNOS vlan | ||
junos_vlans: | ||
config: | ||
- name: vlan-1 | ||
state: deleted | ||
# After State | ||
# ----------- | ||
# | ||
# admin# show vlans | ||
# vlan-2 { | ||
# vlan-id 2; | ||
# } | ||
# vlan-3 { | ||
# vlan-id 3; | ||
# } | ||
""" | ||
RETURN = """ | ||
before: | ||
description: The configuration prior to the model invocation. | ||
returned: always | ||
sample: > | ||
The configuration returned will always be in the same format | ||
of the parameters above. | ||
after: | ||
description: The resulting configuration model invocation. | ||
returned: when changed | ||
sample: > | ||
The configuration returned will always be in the same format | ||
of the parameters above. | ||
commands: | ||
description: The set of commands pushed to the remote device. | ||
returned: always | ||
type: list | ||
sample: ['command 1', 'command 2', 'command 3'] | ||
""" | ||
|
||
|
||
from ansible.module_utils.basic import AnsibleModule | ||
from ansible.module_utils.network.junos.argspec.vlans.vlans import VlansArgs | ||
from ansible.module_utils.network.junos.config.vlans.vlans import Vlans | ||
|
||
|
||
def main(): | ||
""" | ||
Main entry point for module execution | ||
:returns: the result form module invocation | ||
""" | ||
module = AnsibleModule(argument_spec=VlansArgs.argument_spec, | ||
supports_check_mode=True) | ||
|
||
result = Vlans(module).execute_module() | ||
module.exit_json(**result) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Oops, something went wrong.