Page MenuHomePhabricator

Automate Cassandra row/rack configuration using Netbox
Open, LowPublic

Description

Cassandra's data-center & row configuration is currently templated to cassandra-rackdc.properties via manually edited hiera values. This is a duplication of attributes stored in Netbox that could be eliminated.

From an IRC discussion with @Volans

[ ... ]
10:34 AM <volans> right now we have a sre.puppet.sync-netbox-hiera cookbook that does export the data from netbox, show the user a diff of what changed and once approved commits it to a
                  local-to-the-cumin hosts git repository that is then pushed to the puppetmasters that have a local checkout of the repo
10:35 AM <volans> there you have profile::netbox::host::location that has for physical hosts rack/row/site (with some pre-existing naming convention)
10:36 AM <volans> that data can be imported in any .pp easily and mangled at will to re-create the same name you have now hardcoded
10:37 AM <volans> the cookbook is automatically run when running the sre.dns.netbox one to force to keep things in sync (and there is an icinga check if there are unmerged changes in netbox)
[ ... ]
10:50 AM <volans> if you're worried by the moving parts you could also staticize the values into a file on the host and have puppet change it only if the file doesn't exist
10:50 AM <volans> if the file exists and the content is different just fail the puppet run
[ ... ]

Event Timeline

Eevans triaged this task as Low priority.Feb 1 2023, 6:06 PM

Basically you just need in your puppet manifest to:

# Get typology info from netbox data
include profile::netbox::host
$location = $profile::netbox::host::location

# And then use $location to create the values you need accessing its properties ('site', 'row', 'rack') like:
# $location['rack']

An example of the content is:

"rack" => "B2",
"row" => "eqiad-row-b",
"site" => "eqiad"

For Ganeti VMs it's slightly different but IIRC there are no Cassandra nodes on Ganeti.