debops.netbase default variables

General configuration, APT packages

netbase__enabled

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

netbase__enabled: '{{ False
                      if (ansible_virtualization_type == "docker" and
                          ansible_virtualization_role == "guest")
                      else True }}'
netbase__base_packages

List of base APT packages to linstall for netbase support.

netbase__base_packages: [ 'netbase', 'libcap2-bin', 'dbus' ]
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. The role will also avoid configuring the hostname in containers, which usually cannot change their own hostname directory due to host restrictions. 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) and
                                          (ansible_virtualization_type is undefined or
                                           ansible_virtualization_type not in ["lxc", "docker", "openvz"]))
                                      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. If not changed, the DNS domain is defined based on the following rules:

If the host has been installed with a domain, and its FQDN points to the 127.0.1.1 address, the role will check on the remote host if a given FQDN exists in the DNS database. If the FQDN can be resolved, the 127.0.1.1 entry will be removed from the /etc/hosts file to allow the DNS database to provide the correct IP address. If the FQDN is not found in DNS database, the existing entry will be left intact.

If the host has been configured with a domain in /etc/hosts file which is also present in the DNS database, and its FQDN points to any other IP address than 127.0.1.1, the role will generate the IPv4 and IPv6 entries for this domain which should preserve the existing configuration.

If the host has been installed without a domain specified, a domain will be generated based on the ansible_host variable (if it's set to a FQDN address) and saved in the /etc/hosts database. The host's FQDN and hostname will point to the default IPv4 and IPv6 addresses of the host. If the Ansible inventory does not have a FQDN defined for a given host in the ansible_host variable, the host is assumed to be standalone and a domain will not be generated for it.

netbase__domain: '{{ ""
                     if (ansible_local | d() and ansible_local.netbase | d() and
                         (((ansible_local.netbase.self_address | d()) != "127.0.1.1" and
                           (not ansible_local.netbase.self_local_hostname | d()) | bool) or
                          ((ansible_local.netbase.self_address | d()) == "127.0.1.1" and
                            ansible_local.netbase.self_domain | d() and
                            ansible_local.netbase.self_domain_source in ["dns"])))
                     else (ansible_local.netbase.self_domain
                           if (ansible_local | d() and ansible_local.netbase | d() and
                               (ansible_local.netbase.self_domain | d()) and
                               (ansible_local.netbase.self_local_hostname | d()) | bool)
                           else ((ansible_host | d(ansible_ssh_host | d("0"))).split(".")[1:] | join(".")
                                 if (not (ansible_host | d(ansible_ssh_host | d("0"))) | ansible.utils.ipaddr)
                                 else (inventory_hostname.split(".")[1:] | join(".")
                                       if (inventory_hostname.split(".") | count > 1)
                                       else ""))) }}'
netbase__aliases

List of additional alias names defined for the current host, including its hostname, in the /etc/hosts database. This list is automatically generated using the Ansible local facts. If you plan to change it, ensure that the hostname is specified first to avoid any issues with name resolution.

netbase__aliases: '{{ ([netbase__hostname]
                       + ansible_local.netbase.self_aliases | d([]) | unique) }}'
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())
                                if (ansible_domain | d() and
                                    ansible_local | d() and ansible_local.netbase | d() and
                                    ansible_local.netbase.self_domain_source in ["dns"])
                                else ansible_local.netbase.self_address | d("127.0.1.1") }}'
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__aliases)
                                if netbase__domain | d()
                                else (netbase__hostname
                                      if (not ansible_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" and
                       (ansible_local | d() and ansible_local.netbase | d() and
                        ansible_local.netbase.self_domain_source not in ["dns"]))
                   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: {}

Configuration variables for other Ansible roles

netbase__python__dependent_packages3

Configuration for the debops.python Ansible role.

netbase__python__dependent_packages3:

  - 'python3-dnspython'
netbase__python__dependent_packages2

Configuration for the debops.python Ansible role.

netbase__python__dependent_packages2:

  - 'python-dnspython'