Let me first say: apologies, my question feels so general and I’m so new that I’m not sure which tags belong to it, and I’ve spend a bunch of time between AI and index searching that I still don’t really know the answers to my concern.
I’m trying to figure out what would be the ideal or conventional way to bootstrap a server such that a single playbook and inventory can be used with idempotence to do two things that change inventory attributes:
- ansible_user: Root login with password at first, swap to key-only and create deploy user.
- ansible_host: Put up Wireguard, shift sshd to only listen to it–future connections use the Wireguard IP
I could, of course, manually change each of these and use different playbooks for stages. However, correct me if I’m wrong, but that doesn’t seem to me as though I would be leveraging Ansible fully.
I’m under the impression that a single playbook should be able to be run repeatedly for a given server from first run and any following changes; is that how things are conventionally done?
I’ve considered automating via roles in a playbook, but I’d really want to attach root/deploy users and wireguard, private/public (or both) IPs to a single host at the inventory level.
I’ve also considered using multiple entries in inventory, but that somewhat breaks my idea of the spirit of idempotence and if I had, say fail2ban aggressively enabled and hit, say port 22 when it is set to block any IP trying to reach it there, well… it just seems as though there’s probably better logic set up as–at least to me–I feel there must be already well established conventions to handle such a situation–at least with bootstrapping from root to a deploy user, right?