In many projects, you might have custom DNS entries, for example for your development environment, or because something is prototype without a real DNS entry yet, or simply for convenience to not remember weird IP addresses.
Currently, these special domains might be used in the configuration of a project (say, the DB server is db1.acme.local), and that’s version controlled and everything, but creating the actual DNS entry (in the hosts file for example) is still manual and therefore error prone.
Has anyone figured out a nice solution to this? Or do you all have super quick IT departments that’ll give you real domains instantly?^^
LemmyLurker ( @LemmyLurker@beehaw.org ) English2•2 years agoYou could use a script to automate editing the hostfile on windows or /etc/hosts on Linux. If you define a section in the file with comments, the script should just replace the relevant entries for the project inside the section, and leave the rest alone. You can have multiple sections and multiple scripts that can coexist. Works well for my work project. It’s included in a general setup script which can be run as often as needed to keep stuff like this updated on our local machines.
towerful ( @towerful@beehaw.org ) English2•2 years agoYou could run dnsmasq or some other simple DNS resolver. Either on you computer, or as an additional device (a cheapo OpenWRT or Mikrotik would do it as an additional network device. Turn off everything except the DNS).
Have a wildcard subdomain that points to your dev env.
Use that DNS for your dev env, and have it reach out to actual DNS resolvers. Scary le Poo ( @Scary_le_Poo@beehaw.org ) English1•2 years agoSet up a pihole and then when you want to add a new address, just do it in the front end. You can run it on your desktop for example. As a bonus action, you get the benefits of having a pihole!
https://github.com/DesktopECHO/Pi-Hole-for-WSL1
This is by far the easiest and most simple solution
mrGarbanzo ( @mrGarbanzo@beehaw.org ) English1•2 years agoMost new projects / experiments would run under a directory for a testing subdomain that was already established for the sake of saving the most time. I once asked for and was granted access to our company’s DNS server and outside provider for setting these up if needed. Otherwise it was editing the local hosts file on my machine or doing that for a different user for collaboration purposes. Looking back, I probably could have scripted these host file edits but didn’t need to this very often.
george ( @george@midwest.social ) English1•2 years agodocker-compose gives host names to everything, so you can just use those. If it’s local, then whoever is setting it up needs to give it a DNS record.
Borger ( @Borger@lemmy.blahaj.zone ) English1•2 years agoNot a DevOps eng so this might not be the most elegant answer but you could write an Ansible playbook to edit a hosts file on the target server and trigger that after deployment, within your CI/CD pipeline.
In an ideal situation, though, all your servers connect to a centralised DNS server (usually your gateway) where those domain names are managed.
For reference, I found a tool that does what I’m looking for: https://github.com/guumaster/hostctl
parad10x ( @parad10x@beehaw.org ) English1•2 years agoIf it’s just editing
/etc/hosts
you can probably do some scripting to do it automatically. i.e. for Python, you might be able to use something like https://github.com/jonhadfield/python-hosts and integrate it into your test setup script.