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-1create a groupcus_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_ipvariable assigned to the other hosts and assign the next higher free IP - Group
cus_www_prod_lbandcus_www_prod_webinto the groupcus_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.ymlcontains variables for all servers in the group cus_www_prodinventory/host_vars/cus-www-prod-lb-1.ymlcontains 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_aliasesborgbackup_client_hooksletsencypt_partition_disksshorewall_rules_custommailrelay_opensmtpdssh_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.