maxlareo.cumuluslinux

CumulusLinux

Ansible Galaxy

一个用于通过 NCLU 模块管理 Cumulus Linux 的 Ansible 角色。

要求

仅支持 Cumulus Linux 3.2+ 版本,以前的版本不支持 NCLU。

角色变量

变量 描述 类型 默认值
cl_license CumulusLinux 许可证 字符串 ''
cl_hostname 设备的主机名 字符串 cumulus
cl_time_zone 时区 字符串 Etc/UTC
cl_time_ntp_servers NTP 服务器列表,可以添加 iburst 选项 数组 []
cl_time_ntp_source NTP 源接口 字符串 eth0
cl_locales 从 locale-gen 启用语言环境 数组 []
cl_dns_nameserver DNS 名称服务器,包括两个子数组 ipv4 和 ipv6 哈希 {}
cl_commands Ansible nclu 原子命令,使用 recursive 查找,允许 del/add 操作,优先执行 哈希 {}
cl_snmp 来自 net add snmp-server 的 snmp-server 设置,使用 recursive 查找 哈希 {}
cl_syslog 从两个子数组的哈希 ipv4 和 ipv6 的 syslog 设置,每个条目需要一个 IP + 端口,且可选一个协议(udp/tcp) 哈希 {}
cl_interface 来自 net add interface 的接口设置,使用 recursive 查找 哈希 {}
cl_bond 来自 net add bond 的绑定设置,使用 recursive 查找 哈希 {}
cl_vlan 来自 net add vlan 的 VLAN 设置,使用 recursive 查找 哈希 {}

依赖

自定义查找

递归查找

为了通过 Ansible 管理 Cumulus Linux 的接口配置,我编写了一个查找插件,可以从哈希构造变量,并递归地读取嵌套哈希,将其转换为字符串列表。

每个变量的层级将像这样添加到 nclu 命令:

变量:

cl_interface:
  swp1:
    ip:
      address: 192.168.1.1/24
    link:
      speed: 100
  swp2:
    bridge:
      trunk:
        vlans:
          - 1-5
          - 10,12

结果:

swp1 ip address 192.168.1.1/24
swp2 bridge trunk vlans 1-5
swp2 bridge trunk vlans 10,12

这种方式我认为对于复杂设置的变量结构更易读。

示例剧本

    - hosts: leaf01
      roles:
        - cumuluslinux
      vars:
        cl_license: [email protected]|thequickbrownfoxjumpsoverthelazydog312
        cl_hostname: leaf01
        cl_time_zone: Europe/Paris
        cl_time_ntp_servers:
          - 0.cumulusnetworks.pool.ntp.org iburst
          - 1.cumulusnetworks.pool.ntp.org 
          - 2.cumulusnetworks.pool.ntp.org 
          - 3.cumulusnetworks.pool.ntp.org 
        cl_time_ntp_source: eth1
        cl_locales:
          - en_US.UTF-8 UTF-8
          - fr_FR.UTF-8 UTF-8
        cl_dns_nameserver:
          ipv4:
            - 9.9.9.9
            - 1.1.1.1
          ipv6:
            - 2620:fe::fe
        cl_interface:
          swp1:
            ip:
              address: 192.168.1.1/24
            link:
              speed: 100
          swp2:
            bridge:
              trunk:
                vlans:
                  - 1-5
                  - 10,12
        cl_snmp:
          listening-address:
            ip:
              - 192.168.1.10
              - 192.168.1.20
          readonly-community:
            my_rocommunity:
              access: any
        cl_commands:
          add:
            vrf: mgmt
          del:
            snmp-server: all
        cl_syslog:
          ipv4:
            - ip: 192.168.1.10
              port: 5000
              proto: tcp
            - ip: 192.168.1.20
              port: 6000
          ipv6:
            - ip: 2001:db8::1
              port: 5000
        cl_bond:
          uplink:
            bond:
              slaves:
                - swp1
                - swp2
        cl_vlan:
          100:
            ip:
              adress:
                - 10.10.10.0/24

许可证

MIT

作者信息

Maxime Lareo

反馈、错误报告、请求等

欢迎 联系

关于项目

Manage CumulusLinux via NCLU

安装
ansible-galaxy install maxlareo.cumuluslinux
许可证
mit
下载
119
拥有者