示例#1
0
def playbook():
    pb = Playbook(log)
    pb.profile_nxos()
    pb.ansible_password = '******'
    pb.file = '/tmp/{}.yaml'.format(ansible_module)
    pb.name = '{} task'.format(ansible_module)
    pb.add_host(ansible_host)
    return pb
示例#2
0
def playbook():
    pb = Playbook(log)
    pb.profile_nxos()
    # Since profile_nxos() sets ansible_connection to httpapi,
    # we need to change it here to network_cli since NxosNxapi()
    # can change httpapi-related parameters, like http port,
    # etc, which would break our connection when using httpapi.
    pb.ansible_connection = 'network_cli'
    pb.ansible_password = '******'
    pb.file = '/tmp/{}.yaml'.format(ansible_module)
    pb.name = '{} task'.format(ansible_module)
    pb.add_host(ansible_host)
    return pb
#!/usr/bin/env python3
# unit_test/cisco/nxos/unit_test_nxos_gir_profile_management.py
# Status = BETA
our_version = 100
from ask.common.playbook import Playbook
from ask.common.log import Log
from ask.cisco.nxos.nxos_gir_profile_management import NxosGirProfileManagement

log_level_console = 'INFO'
log_level_file = 'DEBUG'
log = Log('my_log', log_level_console, log_level_file)

pb = Playbook(log)
pb.profile_nxos()
pb.ansible_password = '******'
pb.name = 'nxos_gir_profile_management example'
pb.add_host('dc-101')
pb.file = '/tmp/nxos_gir_profile_management.yaml'

commands = list()
commands.append('router ospf 1')
commands.append('isolate')
task = NxosGirProfileManagement(log)
task.commands = commands
task.mode = 'maintenance'
task.state = 'present'
task.task_name = 'gir mode {} state {}'.format(task.mode, task.state)
task.commit()

pb.add_task(task)
pb.append_playbook()
示例#4
0
    task.commit()
    pb.add_task(task)

def task_nxos_bfd_interfaces(pb):
    task = NxosBfdInterfaces(log)
    task.name = 'Ethernet1/49'
    task.echo = 'enable'
    task.add_interface()
    task.state = 'merged'
    task.task_name = 'enable bfd echo on {}'.format(task.name)
    task.commit()
    pb.add_task(task)

log = Log('test_playbook', 'INFO', 'DEBUG')
pb = Playbook(log)
pb.profile_nxos() # commonly used NXOS settings
pb.ansible_connection = 'network_cli' # profile_nxos() sets this to httpapi
pb.ansible_password = '******'
# write the playbook to a file
pb.file = '/tmp/playbook.yaml'
# Creates a single playbook with two tasks
task_nxos_interfaces(pb)
task_nxos_bfd_interfaces(pb)
pb.add_host('t301')  # host in Ansible inventory
pb.add_environment('no_proxy', '*')
pb.add_vars('my_var1', 'my_var_value1')
pb.add_vars('my_var2', 'my_var_value2')
pb.append_playbook()
pb.write_playbook()
# We can also write the playbook to standard output
pb.file = 'STDOUT'