From c36aa6ae507b2a0b413acbb450fef610c55c6c41 Mon Sep 17 00:00:00 2001 From: Kevin Breit Date: Wed, 9 May 2018 09:13:22 -0500 Subject: [PATCH] Panos/doc fragment (#37696) * Create PanOS module documentation fragment - Module documentation fragment currently holds 3 parameters - It most likely won't be used in every single module since there is some variance * Modified PanOS module for use doc_frags - Where documentation is consistent, module documentation now uses a documentation fragment instead of all documentation being contained in the module. * Formatting and syntax error fixes Updated some formatting errors to make ansibot happy. * Revisions for grammar --- .../modules/network/panos/panos_admin.py | 13 +--------- .../modules/network/panos/panos_check.py | 14 +---------- .../modules/network/panos/panos_commit.py | 13 +--------- .../modules/network/panos/panos_dag.py | 13 +--------- .../modules/network/panos/panos_dag_tags.py | 13 +--------- .../modules/network/panos/panos_import.py | 13 +--------- .../modules/network/panos/panos_interface.py | 13 +--------- .../modules/network/panos/panos_lic.py | 14 +---------- .../modules/network/panos/panos_loadcfg.py | 13 +--------- .../modules/network/panos/panos_mgtconfig.py | 13 +--------- lib/ansible/modules/network/panos/panos_pg.py | 13 +--------- .../modules/network/panos/panos_restart.py | 15 +---------- .../modules/network/panos/panos_sag.py | 13 +--------- .../utils/module_docs_fragments/panos.py | 25 +++++++++++++++++++ 14 files changed, 38 insertions(+), 160 deletions(-) create mode 100644 lib/ansible/utils/module_docs_fragments/panos.py diff --git a/lib/ansible/modules/network/panos/panos_admin.py b/lib/ansible/modules/network/panos/panos_admin.py index 87ab02117c3..399eae6a65e 100644 --- a/lib/ansible/modules/network/panos/panos_admin.py +++ b/lib/ansible/modules/network/panos/panos_admin.py @@ -36,18 +36,6 @@ version_added: "2.3" requirements: - pan-python options: - ip_address: - description: - - IP address (or hostname) of PAN-OS device - required: true - password: - description: - - password for authentication - required: true - username: - description: - - username for authentication - default: "admin" admin_username: description: - username for admin user @@ -64,6 +52,7 @@ options: - commit if changed type: bool default: 'yes' +extends_documentation_fragment: panos ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/network/panos/panos_check.py b/lib/ansible/modules/network/panos/panos_check.py index bfbda14e1e4..396e84036d7 100644 --- a/lib/ansible/modules/network/panos/panos_check.py +++ b/lib/ansible/modules/network/panos/panos_check.py @@ -31,19 +31,6 @@ version_added: "2.3" requirements: - pan-python options: - ip_address: - description: - - IP address (or hostname) of PAN-OS device - required: true - password: - description: - - password for authentication - required: true - username: - description: - - username for authentication - required: false - default: "admin" timeout: description: - timeout of API calls @@ -54,6 +41,7 @@ options: - time waited between checks required: false default: "0" +extends_documentation_fragment: panos ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/network/panos/panos_commit.py b/lib/ansible/modules/network/panos/panos_commit.py index 7239a1fcb07..ffc9964b3fa 100644 --- a/lib/ansible/modules/network/panos/panos_commit.py +++ b/lib/ansible/modules/network/panos/panos_commit.py @@ -31,18 +31,6 @@ version_added: "2.3" requirements: - pan-python options: - ip_address: - description: - - IP address (or hostname) of PAN-OS device - required: true - password: - description: - - password for authentication - required: true - username: - description: - - username for authentication - default: "admin" interval: description: - interval for checking commit job @@ -55,6 +43,7 @@ options: - if commit should be synchronous type: bool default: 'yes' +extends_documentation_fragment: panos ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/network/panos/panos_dag.py b/lib/ansible/modules/network/panos/panos_dag.py index 4c4c5c6808e..3c16935571b 100644 --- a/lib/ansible/modules/network/panos/panos_dag.py +++ b/lib/ansible/modules/network/panos/panos_dag.py @@ -30,18 +30,6 @@ version_added: "2.3" requirements: - pan-python options: - ip_address: - description: - - IP address (or hostname) of PAN-OS device - required: true - password: - description: - - password for authentication - required: true - username: - description: - - username for authentication - default: "admin" dag_name: description: - name of the dynamic address group @@ -55,6 +43,7 @@ options: - commit if changed type: bool default: 'yes' +extends_documentation_fragment: panos ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/network/panos/panos_dag_tags.py b/lib/ansible/modules/network/panos/panos_dag_tags.py index f506ad09350..09d4d45a56f 100644 --- a/lib/ansible/modules/network/panos/panos_dag_tags.py +++ b/lib/ansible/modules/network/panos/panos_dag_tags.py @@ -39,21 +39,9 @@ notes: - Checkmode is not supported. - Panorama is not supported. options: - ip_address: - description: - - IP address (or hostname) of PAN-OS device - required: true - password: - description: - - password for authentication - required: true api_key: description: - API key that can be used instead of I(username)/I(password) credentials. - username: - description: - - username for authentication - default: "admin" description: description: - The purpose / objective of the static Address Group @@ -74,6 +62,7 @@ options: ip_to_register: description: - IP that will be registered with the given tag names. +extends_documentation_fragment: panos ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/network/panos/panos_import.py b/lib/ansible/modules/network/panos/panos_import.py index e7dff9d18bd..782735198f1 100644 --- a/lib/ansible/modules/network/panos/panos_import.py +++ b/lib/ansible/modules/network/panos/panos_import.py @@ -35,18 +35,6 @@ requirements: - requests - requests_toolbelt options: - ip_address: - description: - - IP address (or hostname) of PAN-OS device. - required: true - password: - description: - - Password for device authentication. - required: true - username: - description: - - Username for device authentication. - default: "admin" category: description: - Category of file uploaded. The default is software. @@ -64,6 +52,7 @@ options: default: yes type: bool version_added: "2.6" +extends_documentation_fragment: panos ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/network/panos/panos_interface.py b/lib/ansible/modules/network/panos/panos_interface.py index 01d916467d0..f96d7213f35 100644 --- a/lib/ansible/modules/network/panos/panos_interface.py +++ b/lib/ansible/modules/network/panos/panos_interface.py @@ -37,18 +37,6 @@ requirements: notes: - Checkmode is not supported. options: - ip_address: - description: - - IP address (or hostname) of PAN-OS device being configured. - required: true - username: - description: - - Username credentials to use for auth. - default: "admin" - password: - description: - - Password credentials to use for auth. - required: true if_name: description: - Name of the interface to configure. @@ -66,6 +54,7 @@ options: description: - Commit if changed default: true +extends_documentation_fragment: panos ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/network/panos/panos_lic.py b/lib/ansible/modules/network/panos/panos_lic.py index 2354ba5d3e6..0ac7944566e 100644 --- a/lib/ansible/modules/network/panos/panos_lic.py +++ b/lib/ansible/modules/network/panos/panos_lic.py @@ -32,19 +32,6 @@ version_added: "2.3" requirements: - pan-python options: - ip_address: - description: - - IP address (or hostname) of PAN-OS device - required: true - password: - description: - - password for authentication - required: true - username: - description: - - username for authentication - required: false - default: "admin" auth_code: description: - authcode to be applied @@ -54,6 +41,7 @@ options: - whether to apply authcode even if device is already licensed required: false default: "false" +extends_documentation_fragment: panos ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/network/panos/panos_loadcfg.py b/lib/ansible/modules/network/panos/panos_loadcfg.py index d8f8cb38a4f..3fb9bf6852f 100644 --- a/lib/ansible/modules/network/panos/panos_loadcfg.py +++ b/lib/ansible/modules/network/panos/panos_loadcfg.py @@ -30,18 +30,6 @@ version_added: "2.3" requirements: - pan-python options: - ip_address: - description: - - IP address (or hostname) of PAN-OS device - required: true - password: - description: - - password for authentication - required: true - username: - description: - - username for authentication - default: "admin" file: description: - configuration file to load @@ -50,6 +38,7 @@ options: - commit if changed type: bool default: 'yes' +extends_documentation_fragment: panos ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/network/panos/panos_mgtconfig.py b/lib/ansible/modules/network/panos/panos_mgtconfig.py index 4ae8b948a5c..7385a20e26c 100644 --- a/lib/ansible/modules/network/panos/panos_mgtconfig.py +++ b/lib/ansible/modules/network/panos/panos_mgtconfig.py @@ -30,18 +30,6 @@ version_added: "2.3" requirements: - pan-python options: - ip_address: - description: - - IP address (or hostname) of PAN-OS device - required: true - password: - description: - - password for authentication - required: true - username: - description: - - username for authentication - default: "admin" dns_server_primary: description: - address of primary DNS server @@ -59,6 +47,7 @@ options: - commit if changed type: bool default: 'yes' +extends_documentation_fragment: panos ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/network/panos/panos_pg.py b/lib/ansible/modules/network/panos/panos_pg.py index 5607099f79b..d66d5131ae5 100644 --- a/lib/ansible/modules/network/panos/panos_pg.py +++ b/lib/ansible/modules/network/panos/panos_pg.py @@ -30,18 +30,6 @@ version_added: "2.3" requirements: - pan-python options: - ip_address: - description: - - IP address (or hostname) of PAN-OS device - required: true - password: - description: - - password for authentication - required: true - username: - description: - - username for authentication - default: "admin" pg_name: description: - name of the security profile group @@ -72,6 +60,7 @@ options: - commit if changed type: bool default: 'yes' +extends_documentation_fragment: panos ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/network/panos/panos_restart.py b/lib/ansible/modules/network/panos/panos_restart.py index 182fd9aba89..0444489e957 100644 --- a/lib/ansible/modules/network/panos/panos_restart.py +++ b/lib/ansible/modules/network/panos/panos_restart.py @@ -29,20 +29,7 @@ author: "Luigi Mori (@jtschichold), Ivan Bojer (@ivanbojer)" version_added: "2.3" requirements: - pan-python -options: - ip_address: - description: - - IP address (or hostname) of PAN-OS device - required: true - password: - description: - - password for authentication - required: true - username: - description: - - username for authentication - required: false - default: "admin" +extends_documentation_fragment: panos ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/network/panos/panos_sag.py b/lib/ansible/modules/network/panos/panos_sag.py index 12d56d8f587..5ecb5e31fbc 100755 --- a/lib/ansible/modules/network/panos/panos_sag.py +++ b/lib/ansible/modules/network/panos/panos_sag.py @@ -32,18 +32,6 @@ requirements: - pandevice can be obtained from PyPi U(https://pypi.python.org/pypi/pandevice) - xmltodict can be obtained from PyPi U(https://pypi.python.org/pypi/xmltodict) options: - ip_address: - description: - - IP address (or hostname) of PAN-OS device - required: true - password: - description: - - password for authentication - required: true - username: - description: - - username for authentication - default: "admin" api_key: description: - API key that can be used instead of I(username)/I(password) credentials. @@ -74,6 +62,7 @@ options: description: - The operation to perform Supported values are I(add)/I(list)/I(delete). required: true +extends_documentation_fragment: panos ''' EXAMPLES = ''' diff --git a/lib/ansible/utils/module_docs_fragments/panos.py b/lib/ansible/utils/module_docs_fragments/panos.py new file mode 100644 index 00000000000..eb666699f43 --- /dev/null +++ b/lib/ansible/utils/module_docs_fragments/panos.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +# Copyright: (c) 2016, techbizdev +# Copyright: (c) 2018, Kevin Breit (@kbreit) + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + + +class ModuleDocFragment(object): + # Standard files documentation fragment + DOCUMENTATION = ''' +options: + ip_address: + description: + - IP address (or hostname) of PAN-OS device. + required: true + password: + description: + - Password for authentication. + required: true + username: + description: + - Username for authentication. + default: "admin" +'''