Some quick background. I'm using ansible to automate setup of development environments for new projects. These are active development environments, not freshly provisioned machines, so some challenges come with the territory--in particular there are times when I would use a template to configure a new machine, but in an active dev environment I have to modify existing config files.
In one case I am configuring the ~/.ssh/config file to make it possible to SSH in to a vagrant box using a regular 'ssh vagrantguest' by taking the resulting config block from 'vagrant ssh-config'. This is a multi-line block. I have a playbook that does something like this:
- name: Retrieve ssh config from vagrant
shell: vagrant ssh-config --host vagrantguest chdir={{ project_path }}
changed_when: False
register: vagrant_ssh_config
- name: Add ssh config to ~/.ssh/config
lineinfile: path=~/.ssh/config line={{ vagrant_ssh_config.stdout }} regexp="^Host vagrantguest\n.*\n"
The variable, vagrant_ssh_config.stdout is added to the file but is surrounded in single-quotes. Is this a bug or expected behavior? Is there a way to remove these quotes? Or is there a better solution to this altogether?