debops.netbase default variables

General configuration, APT packages

netbase__enabled

Enable or disable support for local host and network database management.

netbase__enabled: True
netbase__base_packages

List of base APT packages to linstall for netbase support.

netbase__base_packages: [ 'netbase', 'libcap2-bin' ]
netbase__packages

List of additional APT packages to install for netbase support.

netbase__packages: []

Hostname and domain

netbase__hostname_config_enabled

Enable or disable configuration of the hostname based on presence of the cap_sys_admin POSIX capability. Hostname will still be defined in /etc/hosts if the local domain configuration is enabled.

netbase__hostname_config_enabled: '{{ True
                                      if (((ansible_system_capabilities_enforced|d())|bool and
                                           "cap_sys_admin" in ansible_system_capabilities) or
                                          not (ansible_system_capabilities_enforced|d(True))|bool)
                                      else False }}'
netbase__hostname

Set a hostname for a given host. It should contain only characters supported in the DNS: alphanumeric, and a dash; no dots or other punctuation.

By default, the role will configure the hostname based on the Ansible inventory configuration. To preserve existing hostname, set the value to '{{ ansible_hostname }}'.

netbase__hostname: '{{ (inventory_hostname_short | d(inventory_hostname.split(".")[0]))
                       if (inventory_hostname_short | d(inventory_hostname.split(".")[0]) != "localhost")
                       else ansible_hostname }}'
netbase__domain

Define a local domain for a given host. This domain will be added in the /etc/hosts database and will override any information coming from the DNS service. If it's set to an empty string, the domain will not be configured in the /etc/hosts database.

To configure local domain based on Ansible inventory host configuration, you can set the value to: '{{ inventory_hostname.split(".")[1:] | join(".") }}'

netbase__domain: ''
netbase__host_ipv4_address

The IPv4 address which will be used to create the host record in the /etc/hosts database with the FQDN and the hostname. If the host does not have a proper IPv4 address associated with it and you want to use IPv4 networking, you can use 127.0.1.1 to set the hostname.

netbase__host_ipv4_address: '{{ ansible_default_ipv4.address | d() }}'
netbase__host_ipv6_address

The IPv6 address which will be used to create the host record in the /etc/hosts database with the FQDN and the hostname.

netbase__host_ipv6_address: '{{ ansible_default_ipv6.address | d() }}'
netbase__domain_host_entry

The actual /etc/hosts entry with the local domain definition. It will be set as the IPv4 and/or IPv6 addresses defined in above variables.

netbase__domain_host_entry: '{{ [ netbase__hostname + "." + netbase__domain, netbase__hostname ]
                                if netbase__domain|d() else [] }}'

Host database in /etc/hosts

The netbase__*_hosts variables below define the host records in the /etc/hosts database. See netbase__hosts for more details.

netbase__hosts_config_type

The host database configuration method used by the role.

If lineinfile, the configuration will be done using the lineinfile Ansible module. This allows the database to be updated by other mechanisms than Ansible, but the configuration is very slow. This is suitable for small number of host entries, otherwise you should think about setting up a local DNS server instead.

If template, the hosts database will be generated using the template Ansible module. This makes the configuration much faster, which is useful with large list of hosts, but the database cannot be modified by other tools, the changes will not be preserved by Ansible.

netbase__hosts_config_type: '{{ "template"
                                if ((netbase__hosts
                                     | combine(netbase__group_hosts, netbase__host_hosts)).keys()
                                    | count > 15)
                                else "lineinfile" }}'
netbase__default_hosts

The default set of host database entries, defined by the role.

netbase__default_hosts:

  - '127.0.0.1': [ 'localhost' ]
  - '127.0.1.1': []
  - '::1':       [ 'localhost', 'ip6-localhost', 'ip6-loopback' ]
  - 'ff02::1':   [ 'ip6-allnodes' ]
  - 'ff02::2':   [ 'ip6-allrouters' ]

  - name:  '{{ netbase__host_ipv4_address }}'
    value: '{{ netbase__domain_host_entry }}'
    separator: '{{ True
                   if (netbase__host_ipv4_address != "127.0.1.1")
                   else False }}'

  - name:  '{{ netbase__host_ipv6_address }}'
    value: '{{ netbase__domain_host_entry }}'
netbase__hosts

YAML list of host entries which should be present on all hosts in the Ansible inventory.

Since the host database is supposed to be the same across all hosts, you should most likely stick to using this variable and define it for the all inventory group.

netbase__hosts: []
netbase__group_hosts

YAML list of host entries which should be present on hosts in a specific Ansible inventory group.

netbase__group_hosts: []
netbase__host_hosts

YAML list of host entries which should be present on specific hosts in the Ansible inventory.

netbase__host_hosts: []
netbase__combined_hosts

The variable which combines all other hosts lists and is used in the role tasks and templates.

netbase__combined_hosts: '{{ netbase__default_hosts
                            + netbase__hosts
                            + netbase__group_hosts
                            + netbase__host_hosts }}'

Network database in /etc/networks

These variables define what network entries should be present in the /etc/networks database. Each dictionary key is a network name and value should be a string or a YAML list of a class A, B or C network address and optional aliases. Example:

netbase__networks:
  'net.example.org': '192.0.2.0'

Entries with empty values will be removed from the database. See the networks(5) manual page for more details.

netbase__networks

YAML dictionary of network entries which should be present on all hosts in the Ansible inventory.

Since the network database is supposed to be the same across all hosts, you should most likely stick to using this variable and define it for the all inventory group.

netbase__networks: {}
netbase__group_networks

YAML dictionary of network entries which should be present on hosts in a specific Ansible inventory group.

netbase__group_networks: {}
netbase__host_networks

YAML dictionary of network entries which should be present on specific hosts in the Ansible inventory.

netbase__host_networks: {}