Changes

Jump to navigation Jump to search
Adds example for testing
== SSH Configuration ==
<code>vagrant ssh-config</code><ref>https://www.vagrantup.com/docs/cli/ssh_config.html</ref> will output a valid configuration for ssh directly into the guest without needing to invoke vagrant at all (aka <code>vagrant ssh</code>). This also allows you to confirm that your provisioning scripts are looking for the right key in the right place. And last but certainly not least, this is how you would run Ansible "manually", outside of Vagrant, against your Vagrant guest. This is a quicker way to run an Ansible playbook without having to do a full 'vagrant provision'<ref>https://docs.ansible.com/ansible/guide_vagrant.html#running-ansible-manually</ref>
 
== Manual Plays ==
Say you have a play that you want to test on your Vagrant box.
<source lang="yaml">
- name: This is a play at the top level of a file
hosts: all
# become: true
tasks:
- name: say hi
tags: foo
shell: echo "hi..."
- name: Install unattended-upgrades
package:
name={{item}}
state=latest
update_cache=yes
force=yes
with_items:
- unattended-upgrades
 
- name: Overwrite /etc/apt/apt.conf.d/10periodic
template: src=10periodic.j2 dest=/etc/apt/apt.conf.d/10periodic owner=root group=root mode=0644
</source>
Assuming you have <code>-o IdentitiesOnly=yes</code> in your <code>ansible.cfg</code> file to avoid the 'host unreachable' errors, you can invoke
<code>ansible-playbook --private-key=.vagrant/machines/qualitybox/virtualbox/private_key -u vagrant -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory test.yml</code>
 
You can also test your connection with
<code>ssh -o IdentitiesOnly=true -i .vagrant/machines/qualitybox/virtualbox/private_key -p 2222 vagrant@127.0.0.1</code>
== ToDo ==
4,558

edits

Navigation menu