{"id":27359282,"url":"https://github.com/rackerlabs/tofu-openstack-flex-lab","last_synced_at":"2025-04-13T00:27:53.360Z","repository":{"id":260174637,"uuid":"874325521","full_name":"rackerlabs/tofu-openstack-flex-lab","owner":"rackerlabs","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-07T21:05:23.000Z","size":93,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-03-07T22:19:19.831Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rackerlabs.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-17T16:17:54.000Z","updated_at":"2025-03-07T21:05:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"391db83c-1928-40b4-9773-ae4b60c1624a","html_url":"https://github.com/rackerlabs/tofu-openstack-flex-lab","commit_stats":null,"previous_names":["rackerlabs/tofu-openstack-flex-lab"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rackerlabs%2Ftofu-openstack-flex-lab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rackerlabs%2Ftofu-openstack-flex-lab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rackerlabs%2Ftofu-openstack-flex-lab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rackerlabs%2Ftofu-openstack-flex-lab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rackerlabs","download_url":"https://codeload.github.com/rackerlabs/tofu-openstack-flex-lab/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650840,"owners_count":21139670,"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":"2025-04-13T00:27:53.284Z","updated_at":"2025-04-13T00:27:53.341Z","avatar_url":"https://github.com/rackerlabs.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"## openstack-flex-lab\nI am using opentofu but I call it terraform alot still :/\n\nThis builds out a lab environment as described at https://docs.rackspacecloud.com/ in an already available openstack endpoint. Once tofu has completed you can follow the steps in the linked documentation.\n\n### requirements\n\n- A python virtual environment\n- Install opentofu\n- Install openstackclient\n- Configure $HOME/.config/openstack/clouds.yaml with credentials\n\n### python virtual environment\nFor later use of they dynamic inventory script a python virtual environment is needed. Create your virtual environment the way you see fit and install the requirements.\n\n```bash\npip install -r requirements.txt\n```\n\n### tofu\nOpentofu or terraform is needed to build out the lab environment in an openstack deployment. Installation instructions for opentofu can be found [here](https://opentofu.org/docs/intro/install/).\n\nInstalling opentofu on a mac:\n```bash\nbrew install opentofu\n```\n\nOnce you have opentofu installed initialize it so that required plugins are installed\n```bash\ntofu init --upgrade\n```\n\u003e **ℹ️ Info:** If you encountered the following error on M1 or M2 MacBook you need to follow the steps provided below and use terraform instead of tofu\n```bash\n│ Error: Incompatible provider version\n│\n│ Provider registry.opentofu.org/hashicorp/template v2.2.0 does not have a package available for your current platform, darwin_arm64.\n│\n│ Provider releases are separate from OpenTofu CLI releases, so not all providers are available for all platforms. Other versions of this provider may have different platforms supported.\n```\n\u003e steps to resolve the issue:\n```bash\nbrew install kreuzwerker/taps/m1-terraform-provider-helper\nm1-terraform-provider-helper install hashicorp/template -v v2.2.0\nm1-terraform-provider-helper activate\nterraform init --upgrade\n```\n\nAt this point you can plan if you want to see what will be done but ultimatelay you will need to `apply`.  There are two requried variables to be passed:\n\n- `cloud`\n\nAs mentioned before you need an `$HOME/.config/openstack/clouds.yaml` file configured with an openstack cloud you intend to deploy your lab in.  This cloud is not the region cloud but one that can be used with a rackspace ddi.  Example:\n\n```yaml\nclouds:\n  rxt-sjc-example:\n    # note: $YOUR_PROJECT is the account DDI with Flex, so XXXXXXX_Flex\n    auth:\n      auth_url: https://keystone.api.sjc3.rackspacecloud.com/v3\n      project_name: \u003c DDI \u003e_Flex # $YOUR_PROJECT\n      project_domain_name: rackspace_cloud_domain\n      username: \u003c CLOUD USERNAME \u003e\n      password: \u003c CLOUD PASSWORD\u003e\n      user_domain_name: rackspace_cloud_domain\n    region_name: SJC3\n    interface: public\n    identity_api_version: \"3\"\n    insecure: true\n```\n\n- `ssh_public_key_path`\n\nThe ssh public key path is added to openstack and is required for ssh agent forwarding to be setup.  Specify the path to your public key and you will be good to go.\n\n### plan/apply\n```bash\ntofu plan -var \"cloud=\u003cCLOUD NAME IN clouds.yaml\u003e\" -var \"ssh_public_key_path=~/.ssh/id_rsa.pub\"\ntofu apply -var \"cloud=\u003cCLOUD NAME IN clouds.yaml\u003e\" -var \"ssh_public_key_path=~/.ssh/id_rsa.pub\"\n```\n\nOnce you `apply` the tofu config you will be given the ip address of your launcher node.  Also thanks to @luke8738 and some fancy cloudinit configs the launcher nodes has what you need isntalled and you are automatically in the genestack virtualenv.  Log into the launcher node and `cat /etc/motd` for details. \n\n#### ssh config to use the gateway\n\nOnce you have deployed the infra, its time to set your private key and use it to connect through the gateway. Add the following to `$HOME/.ssh/config`\n\n```bash\nHost \u003cYOUR_LAUNCHER_NODE_IP_RANGE\u003e\n  User ubuntu\n  IdentityFile ~/.ssh/id_rsa\n  ProxyCommand ssh -A gu=\u003cYOUR_USERNAME\u003e@ubuntu@%h@\u003cGATEWAY_ADDRESS\u003e nc %h %p\n  ForwardAgent yes\n  ForwardX11Trusted yes\n  ProxyCommand none\n  ControlMaster auto\n  ControlPath ~/.ssh/master-%r@%h:%p\n  TCPKeepAlive yes\n  StrictHostKeyChecking no\n  ServerAliveInterval 300\n```\n\n### Prepare for kubespray\n\nThe `prepare_for_kubespray.yaml` playbook as the name implies prepare the launcher node to run kubespray.  Inventory based on tofu/terraform, the `genestack_post_deploy.yaml` playbook and helper scripts are all copied to the launcher node.\n\n```bash\nOS_CLOUD=rxt-sjc-example ansible-playbook -i scripts/lab_inventory.py scripts/playbooks/prepare_for_kubespray.yaml -u ubuntu\n```\n\n### time for kubespray\n\nThe steps here closely follow the instructions at [genestack getting started](https://docs.rackspacecloud.com/genestack-getting-started/).\n\nFrom here log into the launcher node to complete the deploy\n```\nansible -m shell -a 'hostnamectl set-hostname {{ inventory_hostname }}' --become all\nansible -m shell -a \"grep 127.0.0.1 /etc/hosts | grep -q {{ inventory_hostname }} || sed -i 's/^127.0.0.1.*/127.0.0.1 {{ inventory_hostname }} localhost.localdomain localhost/' /etc/hosts\" --become all\ncd /opt/genestack/ansible/playbooks \u0026\u0026 ansible-playbook host-setup.yml\ncd /opt/genestack/submodules/kubespray \u0026\u0026 ansible-playbook cluster.yml -b -f 30 -T 30\n```\n\nThe kubespray deploy commonly takes about 30 minutes or so.  Once it is finished a helper script is in place to copy the kubeconfig to the launcher node:\n\n```\nget_kube_config.sh\n```\n\nNow that the kubeconfig is in place run the `genestack_post_deploy.yaml` file as ubuntu in the ubuntu home directory.  It is best to provide the `letsencrypt_email` variable on the command line so the playbook does not stop and prompt you in the middle of the run.\n\n```\nansible-playbook ~/genestack_post_deploy.yaml -e \"letsencrypt_email=\u003cVALID EMAIL ADDRESS\"\n```\n\n### Deploying GeneStack\n\nYou need to follow the [GeneStack doc](https://docs.rackspacecloud.com/openstack-overview/) from this point.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frackerlabs%2Ftofu-openstack-flex-lab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frackerlabs%2Ftofu-openstack-flex-lab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frackerlabs%2Ftofu-openstack-flex-lab/lists"}