planetary-social / ansible-scripts

Ansible automation scripts used at Planetary
MIT License
2 stars 3 forks source link

crosspost role accounts for historical redirects #59

Closed cooldracula closed 7 months ago

cooldracula commented 7 months ago

This pr adjusts our crosspost role to handle domain redirects. This comes from a situation where our previous domain tweeter.nos.social should now redirect to connect.nos.social.

My aim in the design is for there to be no state held on the server that is crucial for the playbook to run, while recognizing our inventory files as essentially the state of our servers. So redirects are specificed in the inventory file, and the role looks to see if redirects are defined and, if so, removes any enabled nginx config. The nginx template also checks for this var and adds a redirect section to the canonical domain's config.

I tested this with tweeter.ansible.fun redirecting to connect.ansible.fun and then with tweeter.nos.social redirecting to connectnos.social.

The role makes two assumptions, in regards to the redirects: 1.) that you have created an A record for the new domain pointing to this server 2.) the previous domains have certs residing on the server.

These feel like fair assumptions. The first is the assumption of any ansible play, and the second is the state the server would be in if you had run the nos-crossposting-service playbook on the server. If neither assumption is correct, you likely don't need to handle redirects and can just not include that variable in the inventory file.