I'm writing a playbook to setup development environment and build pipeline for a project. I would like to keep playbook decoupled from the actual infrastructure as much as possible, and just rely on groups, so I could setup the pipeline inside a local VM's as well as on the bare hardware with the same command, just using different group limiter.
Now the problem is, with local Vagrant boxes I need to add user vagrant to docker group, where as with bare metal servers some arbitrary user. What is the best practice to handle these kind of variations in the playbook, keeping it as abstract as possible? Should I use behavioral parameters, host variables, group variables, conditionals or facts gathering for this kind of stuff?
Is it even possible or reasonable to keep the playbook fully abstract, without any hardcoded values and adaptability to any environment?