Skip to content

Adding new servers to the inventory

Newly created servers have to be defined in the playbook-infrastructure-company below the inventory/ directory.

inventory/hosts

First add the new servers to the inventory/hosts file:

  • For a new server cus-www-prod-lb-1 create a group cus_www_prod_lb
  • Get the public IP from the cloud providers WebUI and set it with nic_pub_ip
  • Look at the nic_wg_mesh_ip variable assigned to the other hosts and assign the next higher free IP
  • Group cus_www_prod_lb and cus_www_prod_web into the group cus_www_prod

Example inventory/hosts entry:

[cus_www_prod_lb]
cus-www-prod-lb-1 nic_wg_mesh_ip=172.16.0.20 nic_pub_ip=1.2.3.4
[cus_www_prod_web]
cus-www-prod-web-1 nic_wg_mesh_ip=172.16.0.21 nic_pub_ip=1.3.5.7

[cus_www_prod:children]
cus_www_prod_lb
cus_www_prod_web

inventory/{group,host}_vars/

Variables can be assigned to groups or individual servers:

  • inventory/group_vars/cus_www_prod.yml contains variables for all servers in the group cus_www_prod
  • inventory/host_vars/cus-www-prod-lb-1.yml contains variables for the server cus-www-prod-lb-1

This is to enhance the oversight and have most all inventory variables in one directory inventory/group_vars/, it is Blunix Stack default to create a group for each logical group of instances even if there is only once instance:

[cus_www_prod_lb]
cus-www-prod-lb-1 nic_wg_mesh_ip=172.16.0.20 nic_pub_ip=1.2.3.4

There is only one loadbalancer, yet we still create a group cus_www_prod_lb.

New server variables

The following variables are most commonly defined for new servers:

  • wg_mesh_aliases
  • borgbackup_client_hooks
  • letsencypt_
  • partition_disks
  • shorewall_rules_custom
  • mailrelay_opensmtpd
  • ssh_users

It is good practice to look at the other files inside inventory/group_vars/*yml for "inspiration" of what needs to defined.

Variable precedence

If the same variable is defined in multiple places, Ansible will complain (warning) during execution and take precedence in a specific order.