Server Locality Using Razor and LLDP - PuppetConf 2014

Preview:

DESCRIPTION

Server Locality Using Razor and LLDP - Jonas Rosland, EMC

Citation preview

Server localitywith Razor and LLDP

Jonas RoslandDeveloper Advocate @EMC

@virtualswedepurevirtual.eu

emccode.github.io

About me

Loves automationUsing Razor and Puppet for 2 yearsSpends way too much time playing with new toolsRetro and indie gamer

Quick primer on RazorAwesome provisioning toolPolicy basedNo manual labor needed (except racking and cabling)Not even needing to find the MAC address or anything like thatJust create a policy, and boot up your servers

So what's in a policy?A few things:1. The repository to install from (repo)2. What to install (task)3. What to hand off to after deployment (broker)4. Stuff like root passwords and hostname5. Node metadata6. Tags (very important)

Something like this{ "name": "centos", "repo": { "name": "centos" }, "task": { "name": "centos" }, "broker": { "name": "noop" }, "enabled": true, "hostname": "host.lab.purevirtual.eu", "root_password": "secret", "max_count": 10, "node-metadata": { "who-is-awesome": "you", "favourite-mst3k-episode": "Pumaman" }, "tags": [{ "name": "small-vm"}]}

What happens when you boot up the server?It boots up the Razor MicorKernelFeeds all the HW info back to Razor

Like thisroot@razor:~# razor nodes node1 factsFrom http://localhost:8080/api/collections/nodes/node1:<snip> processorcount: 1 interfaces: enp0s3,lo ipaddress_enp0s3: 192.168.1.148 macaddress_enp0s3: 08:00:27:ad:77:a2 netmask_enp0s3: 255.255.255.0<snip> is_virtual: true uniqueid: 007f0100 blockdevice_sda_size: 8589934592 uuid: 7935347B-FE5C-4381-82DD-C81093109CCF<snip>

What happens after you boot up the server?Razor applies a policy if the HW info matches a tagA tag might look like:{ "name": "small","rule": ["and", ["=", ["num", ["fact", "processorcount"]], 1], ["=", ["fact", "is_virtual"], "true"]]}

So what if you have many servers that look alike?Razor grabs the next available one out of the "pool"Works very well if most of your servers run the same thingMight not apply if you want more control over what actually gets installed where

Example 1You have three racks of serversThey all look alikeYou want to install the top 10 with VMware vSphereThe bottom 10 with Cloudera Hadoop

Example 2You have three racks of serversThey are not alikeYou want to install the top 5 with OpenStack computeThe next 5 with VMware vSphereThe next 5 with Cloudera HadoopAnd the bottom 5 with EMC ScaleIOAnd you want each group in a certain order

Or maybe something like this?

What to do?

Enter Razor MicroKernel extensions

Extend the HW factsUse a script to collect more facts about a nodeAdd that into a few defined foldersZip it upPoint it out in the Razor config file...Profit!

MK extension folder info• the directory bin at the root of the zip is added to PATH

• the directory lib is added to LD_LIBRARY_PATH

• the directory lib/ruby is added to RUBYLIB

• the directory facts.d is used by Facter to load external facts

MK extension configuration/opt/razor/config.yaml:

microkernel: debug_level: debug kernel_args: # If this value is present, and points to a zip file, it will be # downloaded and unpacked by the MK client prior to checkin. This allows # for custom facts and other code to be shipped to the client without # having to rebuild the ISO image. # # If it is not set, no update will be sent, and the ISO will use only the # default facts, etc, available in the default build. # extension-zip: /opt/razor/mk-extension.zip

Server locality with Razor and LLDPUsing openlldp.rb created by Mike ArnoldAdding binaries and libraries for LLDPContained in a zip filePointed it out in the Razor config file...Result?

Result lldp_neighbor_chassisid_ens2f0: 00:1c:73:28:65:d8 lldp_neighbor_portid_ens2f0: Ethernet17 lldp_neighbor_sysname_ens2f0: razor-switch1 lldp_neighbor_mngaddr_ipv4_ens2f0: lldp_neighbor_mngaddr_ipv6_ens2f0: lldp_neighbor_pvid_ens2f0: 1 lldp_neighbor_mtu_ens2f0: 9236

Making a shiftRandom pools still existAdding control over what goes whereNot an or but an and scenarioGet both and enjoy the benefits!

DEMOTIME

Demo:

1. Show Razor facts without MK extension

2. Add MK extension

3. Show new facts getting in

4. Show tags that use the new facts

5. Show policies using the new tags

Questions?

Thank you!Jonas Rosland@virtualswede