jonjozwiak.bluecat-ipam-rest

角色名称

该角色通过 Bluecat Address Manager (Proteus) REST API 获取和释放 IP 地址及其关联的 DNS 名称。它执行快速部署,而不是完整部署。输入目标主机名后,它在获取 IP 时设置以下变量,以便在后续任务中使用:

ipAddress
ipNetmask
ipGateway

该角色已在 Bluecat Address Manager 8.1.0 中测试。

要求

该角色使用“ipaddr”过滤器来返回给定 CIDR 的子网掩码。这需要 python netaddr 模块(来自 python-netaddr / python3-netaddr RPM)。或者,您可以从角色中删除 ipNetmask 部分。

角色变量

变量可以在剧本的顶部部分或包含角色部分中设置,如剧本示例所示。顶部部分的变量会覆盖任务部分中的变量。

# 拥有 API 访问权限的用户的 Bluecat Address Manager 凭据 
bluecat_username: "apiuser"
bluecat_password: "apipassword"
bluecat_url: "https://bcn_proteus.example.com"

# 来自 Bluecat 的配置和视图详细信息
bluecat_configuration_name: "示例"
bluecat_dns_view: "内部"

# 传递给 bluecat API 获取 IP 调用的属性(只能定义一个)
address_properties: "offset=192.168.30.15"          # 从此地址开始
address_properties: "skip=192.168.30.1-192.168.30.15"        # 跳过这些地址
address_properties: "|excludeDHCPRange=true"        # 跳过 DHCP 范围
address_properties: "skip=10.10.10.128-10.10.11.200,10.10.11.210|offset=10.10.10.100|excludeDHCPRange=true|" # 全部合并

# 如果使用自签名证书请选择“否”,如果证书有效请选择“是”
validate_certs: "no"

# 确定是获取还是释放 IP/DNS 名称。 默认值为存在。 选项包括:
#    创建或获取 IP/DNS:  present, acquire 
#    根据主机名查找 IP: 	get, lookup
#    释放 IP/DNS:		absent, release
state: "present"

# 要获取或释放的主机名 
target_hostname: "host.example.com"

# 要获取 IP 的网络 CIDR
bluecat_network_cidr: "192.168.30.0/24"

依赖关系

示例剧本

注意:顶部的变量会覆盖下面的包含角色变量。如果您在任务中的 include_role 中设置变量,请不要在顶部的变量中声明。

- name: 部署和释放 IP 地址
  hosts: localhost
  vars:
    bluecat_username: "apiuser"
    bluecat_password: "apipassword"
    bluecat_url: "https://bcn_proteus.example.com"
    bluecat_configuration_name: "示例"
    bluecat_network_cidr: "192.168.30.0/24"     # 要获取 IP 的网络 CIDR
    bluecat_dns_view: "内部"
    address_properties: "offset=192.168.30.15"          # 从此地址开始
    #address_properties: "skip=192.168.30.1-192.168.30.15"        # 跳过这些地址
    #address_properties: "|excludeDHCPRange=true"        # 跳过 DHCP 范围
    validate_certs: "no"        # 如果使用自签名证书请选择“否”.. 
  gather_facts: false
  tasks:
    - name: 获取 IP 地址 
      include_role: 
        name: jonjozwiak.bluecat-ipam-rest 
      vars: 
        target_hostname: "ansibletest.example.com"

    - name: 对返回的 IP 地址进行操作
      debug: var=ipAddress

    - name: 获取 IP 地址
      include_role:
        name: jonjozwiak.bluecat-ipam-rest
      vars:
        target_hostname: "ansibletest2.example.com"

    - name: 对返回的 IP 地址进行操作 
      debug: msg="IP 地址: <{{ipAddress}}>.  子网掩码: <{{ipNetmask}}>. 网关: <{{ipGateway}}>."

    - name: 释放 IP 地址 
      include_role:
        name: jonjozwiak.bluecat-ipam-rest
      vars:
        target_hostname: "ansibletest.example.com"
        state: absent

    - name: 释放 IP 地址 
      include_role:
        name: jonjozwiak.bluecat-ipam-rest
      vars:
        target_hostname: "ansibletest2.example.com"
        state: absent

许可证

GPLv3

作者信息

Jon Jozwiak

关于项目

Bluecat IPAM role using the REST API

安装
ansible-galaxy install jonjozwiak.bluecat-ipam-rest
许可证
gpl-3.0
下载
20.7k
拥有者