{"id":21047838,"url":"https://github.com/opsdisk/rack-bob","last_synced_at":"2025-05-15T19:31:59.386Z","repository":{"id":94246886,"uuid":"48620921","full_name":"opsdisk/rack-bob","owner":"opsdisk","description":"Build servers with Rackspace's rack binary","archived":false,"fork":false,"pushed_at":"2016-01-09T06:54:17.000Z","size":11,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-03-01T11:50:47.157Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/opsdisk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-26T19:10:01.000Z","updated_at":"2023-03-17T11:26:13.238Z","dependencies_parsed_at":"2023-03-17T11:31:15.282Z","dependency_job_id":null,"html_url":"https://github.com/opsdisk/rack-bob","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opsdisk%2Frack-bob","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opsdisk%2Frack-bob/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opsdisk%2Frack-bob/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opsdisk%2Frack-bob/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opsdisk","download_url":"https://codeload.github.com/opsdisk/rack-bob/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225369787,"owners_count":17463644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T14:38:27.331Z","updated_at":"2024-11-19T14:38:28.029Z","avatar_url":"https://github.com/opsdisk.png","language":"Python","readme":"#### Motivation\nShort for Rackspace bob-the-builder, this script builds servers with Rackspace's `rack` binary [https://github.com/rackspace/rack]([https://github.com/rackspace/rack). The goal of the project was to combine a number of DevOps concepts I've been learning lately.\n\n1. Minimize building servers by hand/GUI and treat infrastructure-as-code by utilizing an API.  Other cloud providers, like Digital Ocean, also provide this feature with their API [https://developers.digitalocean.com/](https://developers.digitalocean.com/)\n\n2. Minimize hand off to Ansible which will configure the servers based on pre-defined playbooks.  Ansible allows you to logically configure servers.\n\nIn plain English, this can be described as:\n    \n    I want to build a Ubuntu server with 2 CPUs and 4 GB of memory in Dallas, use this SSH key and this root password, and add an additional NIC with an IP address of 10.10.20.2.  When that's done, harden the OS, the SSH server, update the .bash_aliases file, and install Apache web server.\n\nMy old workflow consisted of:\n\n* Using a web GUI to pick the hardware specifications\n* SSH'ing in and copying/pasting a BASH type of file to configure the server based on role\n\n`rack-bob.py` cuts down the manual spin up and configuration time from minutes to seconds.  This solution was custom for me, but hopefully others can utilize it for their needs.\n\n#### Overview\n`rack-bob.py` is a Python wrapper that builds servers in a specific order.  I had issues with `pyrax` and `python-novaclient` libraries and their dependencies and the `rack` binary just worked out of the box. The script allows SSH key injection, root password injection, and internal network configuration (IPs are assigned in the order they are built).  The internal network configuration allows one to add an additional NIC to allow communication on a private subnet.  For example, you could spin up a web server (with a public and private IP) and database server (with only a private IP).  The web server only communicates with the database server over the private IP.\n\nIt also writes a .json file to disk complete with all the server details.  Sensitive info has been replaces with `X`'s and `Y`'s.\n\n```\n{\n    \"domain\": \"example.com\",\n    \"flavorName\": \"8 GB General Purpose v1\",\n    \"rootPassHash\": \"$6$rounds=40000$3CsKE8qCEwC4huI9$RVh0284e2.iAG69KN9FoA/luUC6GpaFgBizjVJzMU.V7VM3YKc82q10pbbQjtFF6iOLJdSrC.fWDi2Php3sv5/\",\n    \"Progress\": 100,\n    \"gateway\": \"10.10.20.1\",\n    \"Metadata\": {},\n    \"Status\": \"ACTIVE\",\n    \"Updated\": \"2016-01-07T05:48:42Z\",\n    \"networkAndMask\": \"10.10.20.0 255.255.255.0\",\n    \"TenantID\": \"XXXXXX\",\n    \"allocationPool\": \"start=10.10.20.2,end=10.10.20.254\",\n    \"imageName\": \"Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)\",\n    \"SecurityGroups\": null,\n    \"keyNamePub\": \"123456-SSHKEY.pub\",\n    \"rootPass\": \"07lmmrP2F7bnOf0HnkP\",\n    \"PublicIPv4\": \"104.239.XX.YY\",\n    \"Name\": \"123456-WWW\",\n    \"PublicIPv6\": \"2001:4800:7820:101:be76:4eff:XXXX:YYYY\",\n    \"Created\": \"2016-01-07T05:48:19Z\",\n    \"KeyName\": \"123456-SSHKEY\",\n    \"PrivateIPv4\": \"10.10.20.2\",\n    \"CIDR\": \"10.10.20.0/24\",\n    \"ID\": \"0221dee5-c9df-4550-XXXXX-4cf134cYYYY\",\n    \"ansibleRoles\": [\n        \"common\",\n        \"WWW\"\n    ],\n    \"Image\": \"09de0a66-3156-48b4-90a5-1cf25a905207\",\n    \"internalNetworkName\": \"123456-INTERNAL-NETWORK\",\n    \"Flavor\": \"general1-8\",\n    \"region\": \"DFW\"\n}\n```\n\n#### Switches\n```\nusage: rack_bob.py [-h] [-a] [-c CONFIGFILE] [-l] [-p PREFIXID] [-s]\n\nRack Bob the Builder\n\noptional arguments:\n  -h, --help     show this help message and exit\n  -a             Make preparations to pass variables to Ansible\n  -c CONFIGFILE  .json configuration file to read in with server details\n  -l             Create individual SSL certificates and keys for each box\n  -p PREFIXID    Server prefix ID (e.g., customer ID, Account number), default\n                 is 123456\n  -s             Create individual SSH keys for each box (default is to create\n                 1 for all boxes)\n\n```\n* Read server build configuration information from a .json file with `-c` switch. Otherwise, a global dictionary is used.\n\n* Make preparations for a post-Ansible deployment with the `-a` switch.  This switch also places SSH/SSL keys in the correct location and creates the `hosts` and `site.yml` files for a streamlined Ansible configuration and deployment. \n\n* Create individual SSL certificates for servers if they are need with `-l` switch\n\n* Prefix a customer/account ID to distinguish servers, networks, and subnets with the `-p` switch\n\n* Create individual passphrase-less SSH keys for each server with the `-s` switch\n\n#### servers.json\nExample file\n```\n{   \n    \"internalNetworkName\": \"INTERNAL-NETWORK\",\n    \"CIDR\": \"10.10.20.0/24\",\n    \"networkAndMask\": \"10.10.20.0 255.255.255.0\",\n    \"gateway\": \"10.10.20.1\",\n    \"allocationPool\": \"start=10.10.20.2,end=10.10.20.254\",\n    \"domain\": \"example.com\",\n    \"servers\": [\n                    {\n                       \"region\": \"DFW\",\n                       \"srvName\": \"WWW\",\n                       \"imageName\": \"Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)\",\n                       \"flavorName\": \"2 GB General Purpose v1\",\n                       \"ansibleRoles\": [\"common\", \"WWW\"]\n                    },\n               ]\n}\n```\n\n#### Future Work\nThere is a lot more to learn in the automation and DevOps world, and I'm sure this is not the most efficient or simplest way to do things...it will likely be a work in progress.  All of the code can be found on the Opsdisk Github repository here: https://github.com/opsdisk/rack-bob.  Comments, suggestions, and improvements are always welcome.  Be sure to follow [@opsdisk](https://twitter.com/opsdisk) on Twitter for the latest updates. ","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopsdisk%2Frack-bob","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopsdisk%2Frack-bob","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopsdisk%2Frack-bob/lists"}