vyos: Docs fixes
This commit is contained in:
parent
d76a4e71c2
commit
ecc7e445b5
3 changed files with 26 additions and 21 deletions
|
@ -24,7 +24,7 @@ author: "Peter Sprygada (@privateip)"
|
||||||
short_description: Run one or more commands on VyOS devices
|
short_description: Run one or more commands on VyOS devices
|
||||||
description:
|
description:
|
||||||
- The command module allows running one or more commands on remote
|
- The command module allows running one or more commands on remote
|
||||||
devices running VyOS. The mdoule commands can also be introspected
|
devices running VyOS. This module can also be introspected
|
||||||
to validate key parameters before returning successfully. If the
|
to validate key parameters before returning successfully. If the
|
||||||
conditional statements are not met in the wait period, the task
|
conditional statements are not met in the wait period, the task
|
||||||
fails.
|
fails.
|
||||||
|
@ -36,7 +36,7 @@ options:
|
||||||
running VyOS. The output from the command execution is
|
running VyOS. The output from the command execution is
|
||||||
returned to the playbook. If the I(wait_for) argument is
|
returned to the playbook. If the I(wait_for) argument is
|
||||||
provided, the module is not returned until the condition is
|
provided, the module is not returned until the condition is
|
||||||
satistifed or the number of retries has been exceeded.
|
satisfied or the number of retries has been exceeded.
|
||||||
required: true
|
required: true
|
||||||
wait_for:
|
wait_for:
|
||||||
description:
|
description:
|
||||||
|
@ -44,7 +44,7 @@ options:
|
||||||
and what conditionals to apply. This argument will cause
|
and what conditionals to apply. This argument will cause
|
||||||
the task to wait for a particular conditional to be true
|
the task to wait for a particular conditional to be true
|
||||||
before moving forward. If the conditional is not true
|
before moving forward. If the conditional is not true
|
||||||
by the configured retries, the task fails. See examples.
|
by the configured I(retries), the task fails. See examples.
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
aliases: ['waitfor']
|
aliases: ['waitfor']
|
||||||
|
@ -52,13 +52,13 @@ options:
|
||||||
description:
|
description:
|
||||||
- Specifies the number of retries a command should be tried
|
- Specifies the number of retries a command should be tried
|
||||||
before it is considered failed. The command is run on the
|
before it is considered failed. The command is run on the
|
||||||
target device every retry and evaluated against the waitfor
|
target device every retry and evaluated against the I(wait_for)
|
||||||
conditionals
|
conditionals.
|
||||||
required: false
|
required: false
|
||||||
default: 10
|
default: 10
|
||||||
interval:
|
interval:
|
||||||
description:
|
description:
|
||||||
- Configures the interval in seconds to wait between retries
|
- Configures the interval in seconds to wait between I(retries)
|
||||||
of the command. If the command does not pass the specified
|
of the command. If the command does not pass the specified
|
||||||
conditional, the interval indicates how to long to wait before
|
conditional, the interval indicates how to long to wait before
|
||||||
trying the command again.
|
trying the command again.
|
||||||
|
@ -115,16 +115,19 @@ warnings:
|
||||||
type: list
|
type: list
|
||||||
sample: ['...', '...']
|
sample: ['...', '...']
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ansible.module_utils.netcmd import CommandRunner, FailedConditionsError
|
from ansible.module_utils.netcmd import CommandRunner, FailedConditionsError
|
||||||
from ansible.module_utils.vyos import NetworkModule, NetworkError
|
from ansible.module_utils.vyos import NetworkModule, NetworkError
|
||||||
from ansible.module_utils.vyos import vyos_argument_spec, get_exception
|
from ansible.module_utils.vyos import vyos_argument_spec, get_exception
|
||||||
|
|
||||||
|
|
||||||
def to_lines(stdout):
|
def to_lines(stdout):
|
||||||
for item in stdout:
|
for item in stdout:
|
||||||
if isinstance(item, basestring):
|
if isinstance(item, basestring):
|
||||||
item = str(item).split('\n')
|
item = str(item).split('\n')
|
||||||
yield item
|
yield item
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Main entry point for Ansible module execution
|
"""Main entry point for Ansible module execution
|
||||||
"""
|
"""
|
||||||
|
@ -140,7 +143,6 @@ def main():
|
||||||
connect_on_load=False,
|
connect_on_load=False,
|
||||||
supports_check_mode=True)
|
supports_check_mode=True)
|
||||||
|
|
||||||
|
|
||||||
commands = module.params['commands']
|
commands = module.params['commands']
|
||||||
conditionals = module.params['wait_for'] or list()
|
conditionals = module.params['wait_for'] or list()
|
||||||
|
|
||||||
|
@ -192,4 +194,3 @@ def main():
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
|
@ -39,31 +39,28 @@ options:
|
||||||
default: null
|
default: null
|
||||||
src:
|
src:
|
||||||
description:
|
description:
|
||||||
- The C(src) argument provides the path to the configuration
|
- Path to the configuration file to load.
|
||||||
file to load.
|
|
||||||
required: no
|
required: no
|
||||||
default: null
|
default: null
|
||||||
rollback:
|
rollback:
|
||||||
description:
|
description:
|
||||||
- This argument will rollback the device configuration to the
|
- Rollback the device configuration to the
|
||||||
revision specified. If the specified rollback revision does
|
revision specified. If the specified rollback revision does
|
||||||
not exist, then the module will produce an error and fail.
|
not exist, then the module will produce an error and fail.
|
||||||
- NOTE THIS WILL CAUSE THE DEVICE TO REBOOT AUTOMATICALLY
|
- NOTE THIS WILL CAUSE THE DEVICE TO REBOOT AUTOMATICALLY.
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
update_config:
|
update_config:
|
||||||
description:
|
description:
|
||||||
- This argument will control whether or not the configuration
|
- Should the configuration on the remote device be updated with the
|
||||||
on the remote device is udpated with the calculated changes.
|
calculated changes. When set to true, the configuration will be updated
|
||||||
When set to true, the configuration will be updated and
|
and when set to false, the configuration will not be updated.
|
||||||
when set to false, the configuration will not be updated.
|
|
||||||
required: false
|
required: false
|
||||||
default: true
|
default: true
|
||||||
choices: ['yes', 'no']
|
choices: ['yes', 'no']
|
||||||
backup_config:
|
backup_config:
|
||||||
description:
|
description:
|
||||||
- The C(backup_config) argument will instruct the module to
|
- Create a local backup copy of the current running configuration
|
||||||
create a local backup copy of the current running configuration
|
|
||||||
prior to making any changes. The configuration file will be
|
prior to making any changes. The configuration file will be
|
||||||
stored in the backups folder in the root of the playbook or role.
|
stored in the backups folder in the root of the playbook or role.
|
||||||
required: false
|
required: false
|
||||||
|
@ -119,6 +116,7 @@ def invoke(name, *args, **kwargs):
|
||||||
if func:
|
if func:
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def config_to_commands(config):
|
def config_to_commands(config):
|
||||||
set_format = config.startswith('set') or config.startswith('delete')
|
set_format = config.startswith('set') or config.startswith('delete')
|
||||||
candidate = NetworkConfig(indent=4, contents=config, device_os='junos')
|
candidate = NetworkConfig(indent=4, contents=config, device_os='junos')
|
||||||
|
@ -135,15 +133,18 @@ def config_to_commands(config):
|
||||||
commands = str(candidate).split('\n')
|
commands = str(candidate).split('\n')
|
||||||
return commands
|
return commands
|
||||||
|
|
||||||
|
|
||||||
def do_lines(module, result):
|
def do_lines(module, result):
|
||||||
commands = module.params['lines']
|
commands = module.params['lines']
|
||||||
result.update(load_config(module, commands))
|
result.update(load_config(module, commands))
|
||||||
|
|
||||||
|
|
||||||
def do_src(module, result):
|
def do_src(module, result):
|
||||||
contents = module.params['src']
|
contents = module.params['src']
|
||||||
commands = config_to_commands(contents)
|
commands = config_to_commands(contents)
|
||||||
result.update(load_config(module, commands))
|
result.update(load_config(module, commands))
|
||||||
|
|
||||||
|
|
||||||
def do_rollback(module, result):
|
def do_rollback(module, result):
|
||||||
rollback = 'rollback %s' % module.params['rollback']
|
rollback = 'rollback %s' % module.params['rollback']
|
||||||
prompt = re.compile('\[confirm\]')
|
prompt = re.compile('\[confirm\]')
|
||||||
|
@ -156,6 +157,7 @@ def do_rollback(module, result):
|
||||||
cmds = [str(c) for c in exc.kwargs.get('commands', list())]
|
cmds = [str(c) for c in exc.kwargs.get('commands', list())]
|
||||||
module.fail_json(msg=str(exc), commands=cmds)
|
module.fail_json(msg=str(exc), commands=cmds)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
|
|
|
@ -23,7 +23,7 @@ author: "Peter Sprygada (@privateip)"
|
||||||
short_description: Collect facts from remote devices running OS
|
short_description: Collect facts from remote devices running OS
|
||||||
description:
|
description:
|
||||||
- Collects a base set of device facts from a remote device that
|
- Collects a base set of device facts from a remote device that
|
||||||
is running VyOS. The M(vyos_facts) module prepends all of the
|
is running VyOS. This module prepends all of the
|
||||||
base network fact keys with U(ansible_net_<fact>). The facts
|
base network fact keys with U(ansible_net_<fact>). The facts
|
||||||
module will always collect a base set of facts from the device
|
module will always collect a base set of facts from the device
|
||||||
and can enable or disable collection of additional facts.
|
and can enable or disable collection of additional facts.
|
||||||
|
@ -32,7 +32,7 @@ options:
|
||||||
gather_subset:
|
gather_subset:
|
||||||
description:
|
description:
|
||||||
- When supplied, this argument will restrict the facts collected
|
- When supplied, this argument will restrict the facts collected
|
||||||
to a given subset. Possible values for this argument inlcude
|
to a given subset. Possible values for this argument include
|
||||||
all, hardware, config, and interfaces. Can specify a list of
|
all, hardware, config, and interfaces. Can specify a list of
|
||||||
values to include a larger subset. Values can also be used
|
values to include a larger subset. Values can also be used
|
||||||
with an initial M(!) to specify that a specific subset should
|
with an initial M(!) to specify that a specific subset should
|
||||||
|
@ -103,6 +103,7 @@ import re
|
||||||
from ansible.module_utils.netcmd import CommandRunner
|
from ansible.module_utils.netcmd import CommandRunner
|
||||||
from ansible.module_utils.vyos import NetworkModule
|
from ansible.module_utils.vyos import NetworkModule
|
||||||
|
|
||||||
|
|
||||||
class FactsBase(object):
|
class FactsBase(object):
|
||||||
|
|
||||||
def __init__(self, runner):
|
def __init__(self, runner):
|
||||||
|
@ -111,6 +112,7 @@ class FactsBase(object):
|
||||||
|
|
||||||
self.commands()
|
self.commands()
|
||||||
|
|
||||||
|
|
||||||
class Default(FactsBase):
|
class Default(FactsBase):
|
||||||
|
|
||||||
def commands(self):
|
def commands(self):
|
||||||
|
@ -236,6 +238,7 @@ FACT_SUBSETS = dict(
|
||||||
|
|
||||||
VALID_SUBSETS = frozenset(FACT_SUBSETS.keys())
|
VALID_SUBSETS = frozenset(FACT_SUBSETS.keys())
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
spec = dict(
|
spec = dict(
|
||||||
gather_subset=dict(default=['!config'], type='list')
|
gather_subset=dict(default=['!config'], type='list')
|
||||||
|
@ -305,4 +308,3 @@ def main():
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue