To answer your specific question:
Use a user variable rewritten by Vagrantfile. For example, it will be ubuntu if in aws or vagrant if you are in a vagrant state.
A more theoretical answer:
I had the same problem with stray assemblies, and I decided to leave the toy somewhere available so that all stray assemblies would pick it up and run it to configure the server.
For example, a playbook looks like this:
- hosts: all tasks: - name: remove apparmor apt: name=apparmor purge=true state=absent
and then each of my stray repositories launched it and launched using
box.vm.provision :ansible do |ansible| ansible.playbook = 'vagrant_extra.yml' ansible.sudo = true ansible.limit = 'all' end
The best solution, I think, is to use the packer to create your own stray image, which has all the things that are supported there, so that
- You do not need to spend time creating an image yourself, and
- your fields match the prod fields.
source share