erjac77 / nornir_f5

F5 plugins for Nornir.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nornir_f5

Build Status codecov made-with-python Python Version Code style: black GitHub license

Collection of Nornir plugins to interact with F5 systems and deploy declaratives to F5 Automation Toolchain (ATC) services like AS3, DO, and TS.

Installation

Pip

pip install nornir-f5

Poetry

poetry add nornir-f5

Usage

from nornir import InitNornir
from nornir.core.task import Result, Task
from nornir_utils.plugins.functions import print_result

from nornir_f5.plugins.tasks import (
    atc,
    bigip_cm_config_sync,
    bigip_cm_failover_status,
)

def as3_post(task: Task, as3_tenant: str) -> Result:
    # Get the failover status of the device.
    failover_status = task.run(
        name="Get failover status", task=bigip_cm_failover_status
    ).result

    # If it's the ACTIVE device, send the declaration and perform a sync.
    if failover_status == "ACTIVE":
        task.run(
            name="POST AS3 Declaration from file",
            task=atc,
            atc_method="POST",
            atc_service="AS3",
            as3_tenant=as3_tenant,
            atc_declaration_file=task.host["appsvcs"][as3_tenant][
                "atc_declaration_file"
            ],
        )

        task.run(
            name="Synchronize the devices",
            task=bigip_cm_config_sync,
            device_group=task.host["device_group"],
        )

        return Result(
            host=task.host,
            result="ACTIVE device, AS3 declaration successfully deployed.",
        )
    # Else, do nothing...
    else:
        return Result(host=task.host, result="STANDBY device, skipped.")

nr = InitNornir(config_file="config.yml")
nr = nr.filter(platform="f5_bigip")

result = nr.run(
    name="AS3 POST",
    task=as3_post,
    as3_tenant="Simple_01",
)

print_result(result)

Plugins

Connections

  • f5: Connects to an F5 REST server.

Tasks

  • atc: Deploys ATC declaratives on a BIG-IP/IQ system.
  • atc_info: Returns the version and release information of the ATC service instance.
  • bigip_cm_config_sync: Synchronizes the configuration between BIG-IP systems.
  • bigip_cm_failover_status: Gets the failover status of the BIG-IP system.
  • bigip_cm_sync_status: Gets the configuration synchronization status of the BIG-IP system.
  • bigip_shared_file_transfer_uploads: Uploads a file to a BIG-IP system.
  • bigip_shared_iapp_lx_package: Manages Javascript LX packages on a BIG-IP system.
  • bigip_sys_version: Gets software version information for the BIG-IP system.
  • bigip_util_unix_ls: Lists information about the file(s) or directory content on a BIG-IP system.
  • bigip_util_unix_rm: Deletes a file on a BIG-IP system.

Authors

  • Eric Jacob (@erjac77)

About

F5 plugins for Nornir.

License:Apache License 2.0


Languages

Language:Python 100.0%