tnargav 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +31 -0
- data/.gitsetup.yml +5 -0
- data/.travis.yml +7 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +1067 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +89 -0
- data/Rakefile +18 -0
- data/bin/vagrant +106 -0
- data/config/default.rb +36 -0
- data/contrib/README.md +12 -0
- data/contrib/bash/completion.sh +3 -0
- data/contrib/emacs/vagrant.el +8 -0
- data/contrib/vim/vagrantfile.vim +9 -0
- data/keys/README.md +17 -0
- data/keys/vagrant +27 -0
- data/keys/vagrant.pub +1 -0
- data/lib/vagrant/action/builder.rb +174 -0
- data/lib/vagrant/action/builtin/box_add.rb +81 -0
- data/lib/vagrant/action/builtin/call.rb +67 -0
- data/lib/vagrant/action/builtin/config_validate.rb +30 -0
- data/lib/vagrant/action/builtin/confirm.rb +38 -0
- data/lib/vagrant/action/builtin/destroy_confirm.rb +21 -0
- data/lib/vagrant/action/builtin/env_set.rb +24 -0
- data/lib/vagrant/action/builtin/graceful_halt.rb +73 -0
- data/lib/vagrant/action/builtin/handle_box_url.rb +77 -0
- data/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb +134 -0
- data/lib/vagrant/action/builtin/lock.rb +57 -0
- data/lib/vagrant/action/builtin/nfs.rb +118 -0
- data/lib/vagrant/action/builtin/provision.rb +70 -0
- data/lib/vagrant/action/builtin/set_hostname.rb +27 -0
- data/lib/vagrant/action/builtin/ssh_exec.rb +42 -0
- data/lib/vagrant/action/builtin/ssh_run.rb +43 -0
- data/lib/vagrant/action/general/package.rb +103 -0
- data/lib/vagrant/action/hook.rb +107 -0
- data/lib/vagrant/action/runner.rb +69 -0
- data/lib/vagrant/action/warden.rb +103 -0
- data/lib/vagrant/action.rb +43 -0
- data/lib/vagrant/batch_action.rb +113 -0
- data/lib/vagrant/box.rb +97 -0
- data/lib/vagrant/box_collection.rb +375 -0
- data/lib/vagrant/cli.rb +82 -0
- data/lib/vagrant/config/loader.rb +222 -0
- data/lib/vagrant/config/v1/dummy_config.rb +13 -0
- data/lib/vagrant/config/v1/loader.rb +105 -0
- data/lib/vagrant/config/v1/root.rb +60 -0
- data/lib/vagrant/config/v1.rb +9 -0
- data/lib/vagrant/config/v2/dummy_config.rb +13 -0
- data/lib/vagrant/config/v2/loader.rb +141 -0
- data/lib/vagrant/config/v2/root.rb +105 -0
- data/lib/vagrant/config/v2/util.rb +21 -0
- data/lib/vagrant/config/v2.rb +9 -0
- data/lib/vagrant/config/version_base.rb +80 -0
- data/lib/vagrant/config.rb +61 -0
- data/lib/vagrant/environment.rb +843 -0
- data/lib/vagrant/errors.rb +570 -0
- data/lib/vagrant/guest.rb +163 -0
- data/lib/vagrant/hosts.rb +28 -0
- data/lib/vagrant/machine.rb +325 -0
- data/lib/vagrant/machine_state.rb +45 -0
- data/lib/vagrant/plugin/v1/command.rb +169 -0
- data/lib/vagrant/plugin/v1/communicator.rb +98 -0
- data/lib/vagrant/plugin/v1/config.rb +112 -0
- data/lib/vagrant/plugin/v1/errors.rb +15 -0
- data/lib/vagrant/plugin/v1/guest.rb +92 -0
- data/lib/vagrant/plugin/v1/host.rb +66 -0
- data/lib/vagrant/plugin/v1/manager.rb +131 -0
- data/lib/vagrant/plugin/v1/plugin.rb +229 -0
- data/lib/vagrant/plugin/v1/provider.rb +68 -0
- data/lib/vagrant/plugin/v1/provisioner.rb +50 -0
- data/lib/vagrant/plugin/v1.rb +19 -0
- data/lib/vagrant/plugin/v2/command.rb +234 -0
- data/lib/vagrant/plugin/v2/communicator.rb +98 -0
- data/lib/vagrant/plugin/v2/components.rb +47 -0
- data/lib/vagrant/plugin/v2/config.rb +136 -0
- data/lib/vagrant/plugin/v2/errors.rb +15 -0
- data/lib/vagrant/plugin/v2/guest.rb +78 -0
- data/lib/vagrant/plugin/v2/host.rb +66 -0
- data/lib/vagrant/plugin/v2/manager.rb +173 -0
- data/lib/vagrant/plugin/v2/plugin.rb +226 -0
- data/lib/vagrant/plugin/v2/provider.rb +69 -0
- data/lib/vagrant/plugin/v2/provisioner.rb +47 -0
- data/lib/vagrant/plugin/v2.rb +22 -0
- data/lib/vagrant/plugin.rb +6 -0
- data/lib/vagrant/registry.rb +78 -0
- data/lib/vagrant/ui.rb +215 -0
- data/lib/vagrant/util/ansi_escape_code_remover.rb +34 -0
- data/lib/vagrant/util/busy.rb +59 -0
- data/lib/vagrant/util/counter.rb +24 -0
- data/lib/vagrant/util/downloader.rb +146 -0
- data/lib/vagrant/util/file_checksum.rb +38 -0
- data/lib/vagrant/util/file_mode.rb +12 -0
- data/lib/vagrant/util/hash_with_indifferent_access.rb +63 -0
- data/lib/vagrant/util/is_port_open.rb +38 -0
- data/lib/vagrant/util/line_ending_helpers.rb +14 -0
- data/lib/vagrant/util/network_ip.rb +28 -0
- data/lib/vagrant/util/platform.rb +58 -0
- data/lib/vagrant/util/retryable.rb +31 -0
- data/lib/vagrant/util/safe_chdir.rb +33 -0
- data/lib/vagrant/util/safe_exec.rb +36 -0
- data/lib/vagrant/util/safe_puts.rb +31 -0
- data/lib/vagrant/util/scoped_hash_override.rb +45 -0
- data/lib/vagrant/util/ssh.rb +150 -0
- data/lib/vagrant/util/stacked_proc_runner.rb +35 -0
- data/lib/vagrant/util/string_block_editor.rb +77 -0
- data/lib/vagrant/util/subprocess.rb +273 -0
- data/lib/vagrant/util/template_renderer.rb +83 -0
- data/lib/vagrant/util/which.rb +43 -0
- data/lib/vagrant/util.rb +12 -0
- data/lib/vagrant/version.rb +6 -0
- data/lib/vagrant.rb +258 -0
- data/plugins/README.md +5 -0
- data/plugins/commands/box/command/add.rb +51 -0
- data/plugins/commands/box/command/list.rb +41 -0
- data/plugins/commands/box/command/remove.rb +37 -0
- data/plugins/commands/box/command/repackage.rb +43 -0
- data/plugins/commands/box/command/root.rb +75 -0
- data/plugins/commands/box/plugin.rb +15 -0
- data/plugins/commands/destroy/command.rb +31 -0
- data/plugins/commands/destroy/plugin.rb +18 -0
- data/plugins/commands/halt/command.rb +33 -0
- data/plugins/commands/halt/plugin.rb +18 -0
- data/plugins/commands/init/command.rb +40 -0
- data/plugins/commands/init/plugin.rb +18 -0
- data/plugins/commands/package/command.rb +83 -0
- data/plugins/commands/package/plugin.rb +18 -0
- data/plugins/commands/plugin/action/bundler_check.rb +25 -0
- data/plugins/commands/plugin/action/install_gem.rb +81 -0
- data/plugins/commands/plugin/action/license_plugin.rb +54 -0
- data/plugins/commands/plugin/action/list_plugins.rb +54 -0
- data/plugins/commands/plugin/action/prune_gems.rb +149 -0
- data/plugins/commands/plugin/action/uninstall_plugin.rb +23 -0
- data/plugins/commands/plugin/action.rb +52 -0
- data/plugins/commands/plugin/command/base.rb +22 -0
- data/plugins/commands/plugin/command/install.rb +58 -0
- data/plugins/commands/plugin/command/license.rb +31 -0
- data/plugins/commands/plugin/command/list.rb +28 -0
- data/plugins/commands/plugin/command/root.rb +75 -0
- data/plugins/commands/plugin/command/uninstall.rb +28 -0
- data/plugins/commands/plugin/gem_helper.rb +74 -0
- data/plugins/commands/plugin/plugin.rb +22 -0
- data/plugins/commands/plugin/state_file.rb +57 -0
- data/plugins/commands/provision/command.rb +34 -0
- data/plugins/commands/provision/plugin.rb +18 -0
- data/plugins/commands/reload/command.rb +37 -0
- data/plugins/commands/reload/plugin.rb +18 -0
- data/plugins/commands/resume/command.rb +25 -0
- data/plugins/commands/resume/plugin.rb +17 -0
- data/plugins/commands/ssh/command.rb +63 -0
- data/plugins/commands/ssh/plugin.rb +17 -0
- data/plugins/commands/ssh_config/command.rb +49 -0
- data/plugins/commands/ssh_config/plugin.rb +18 -0
- data/plugins/commands/status/command.rb +39 -0
- data/plugins/commands/status/plugin.rb +18 -0
- data/plugins/commands/suspend/command.rb +25 -0
- data/plugins/commands/suspend/plugin.rb +18 -0
- data/plugins/commands/up/command.rb +57 -0
- data/plugins/commands/up/plugin.rb +17 -0
- data/plugins/commands/up/start_mixins.rb +26 -0
- data/plugins/communicators/ssh/communicator.rb +342 -0
- data/plugins/communicators/ssh/plugin.rb +19 -0
- data/plugins/guests/arch/cap/change_host_name.rb +18 -0
- data/plugins/guests/arch/cap/configure_networks.rb +23 -0
- data/plugins/guests/arch/guest.rb +11 -0
- data/plugins/guests/arch/plugin.rb +25 -0
- data/plugins/guests/debian/cap/change_host_name.rb +18 -0
- data/plugins/guests/debian/cap/configure_networks.rb +61 -0
- data/plugins/guests/debian/guest.rb +9 -0
- data/plugins/guests/debian/plugin.rb +25 -0
- data/plugins/guests/fedora/cap/configure_networks.rb +59 -0
- data/plugins/guests/fedora/cap/network_scripts_dir.rb +15 -0
- data/plugins/guests/fedora/guest.rb +11 -0
- data/plugins/guests/fedora/plugin.rb +25 -0
- data/plugins/guests/freebsd/cap/change_host_name.rb +14 -0
- data/plugins/guests/freebsd/cap/configure_networks.rb +39 -0
- data/plugins/guests/freebsd/cap/halt.rb +16 -0
- data/plugins/guests/freebsd/cap/mount_nfs_folder.rb +14 -0
- data/plugins/guests/freebsd/guest.rb +14 -0
- data/plugins/guests/freebsd/plugin.rb +35 -0
- data/plugins/guests/gentoo/cap/change_host_name.rb +17 -0
- data/plugins/guests/gentoo/cap/configure_networks.rb +43 -0
- data/plugins/guests/gentoo/guest.rb +9 -0
- data/plugins/guests/gentoo/plugin.rb +25 -0
- data/plugins/guests/linux/cap/halt.rb +16 -0
- data/plugins/guests/linux/cap/mount_nfs.rb +30 -0
- data/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb +40 -0
- data/plugins/guests/linux/cap/read_ip_address.rb +17 -0
- data/plugins/guests/linux/cap/shell_expand_guest_path.rb +26 -0
- data/plugins/guests/linux/guest.rb +11 -0
- data/plugins/guests/linux/plugin.rb +40 -0
- data/plugins/guests/openbsd/cap/halt.rb +16 -0
- data/plugins/guests/openbsd/guest.rb +11 -0
- data/plugins/guests/openbsd/plugin.rb +20 -0
- data/plugins/guests/pld/cap/network_scripts_dir.rb +11 -0
- data/plugins/guests/pld/guest.rb +11 -0
- data/plugins/guests/pld/plugin.rb +20 -0
- data/plugins/guests/redhat/cap/change_host_name.rb +18 -0
- data/plugins/guests/redhat/cap/configure_networks.rb +60 -0
- data/plugins/guests/redhat/cap/network_scripts_dir.rb +11 -0
- data/plugins/guests/redhat/guest.rb +11 -0
- data/plugins/guests/redhat/plugin.rb +30 -0
- data/plugins/guests/solaris/cap/change_host_name.rb +17 -0
- data/plugins/guests/solaris/cap/configure_networks.rb +25 -0
- data/plugins/guests/solaris/cap/halt.rb +21 -0
- data/plugins/guests/solaris/cap/mount_virtualbox_shared_folder.rb +28 -0
- data/plugins/guests/solaris/config.rb +18 -0
- data/plugins/guests/solaris/guest.rb +14 -0
- data/plugins/guests/solaris/plugin.rb +40 -0
- data/plugins/guests/suse/cap/change_host_name.rb +18 -0
- data/plugins/guests/suse/cap/network_scripts_dir.rb +11 -0
- data/plugins/guests/suse/guest.rb +11 -0
- data/plugins/guests/suse/plugin.rb +25 -0
- data/plugins/guests/ubuntu/cap/change_host_name.rb +23 -0
- data/plugins/guests/ubuntu/guest.rb +32 -0
- data/plugins/guests/ubuntu/plugin.rb +20 -0
- data/plugins/hosts/arch/host.rb +68 -0
- data/plugins/hosts/arch/plugin.rb +15 -0
- data/plugins/hosts/bsd/host.rb +102 -0
- data/plugins/hosts/bsd/plugin.rb +15 -0
- data/plugins/hosts/fedora/host.rb +51 -0
- data/plugins/hosts/fedora/plugin.rb +15 -0
- data/plugins/hosts/freebsd/host.rb +43 -0
- data/plugins/hosts/freebsd/plugin.rb +15 -0
- data/plugins/hosts/gentoo/host.rb +24 -0
- data/plugins/hosts/gentoo/plugin.rb +15 -0
- data/plugins/hosts/linux/host.rb +95 -0
- data/plugins/hosts/linux/plugin.rb +15 -0
- data/plugins/hosts/opensuse/host.rb +34 -0
- data/plugins/hosts/opensuse/plugin.rb +15 -0
- data/plugins/hosts/windows/host.rb +17 -0
- data/plugins/hosts/windows/plugin.rb +15 -0
- data/plugins/kernel_v1/config/nfs.rb +20 -0
- data/plugins/kernel_v1/config/package.rb +17 -0
- data/plugins/kernel_v1/config/ssh.rb +46 -0
- data/plugins/kernel_v1/config/vagrant.rb +31 -0
- data/plugins/kernel_v1/config/vm.rb +184 -0
- data/plugins/kernel_v1/plugin.rb +44 -0
- data/plugins/kernel_v2/config/nfs.rb +14 -0
- data/plugins/kernel_v2/config/package.rb +13 -0
- data/plugins/kernel_v2/config/ssh.rb +76 -0
- data/plugins/kernel_v2/config/ssh_connect.rb +40 -0
- data/plugins/kernel_v2/config/vagrant.rb +13 -0
- data/plugins/kernel_v2/config/vm.rb +416 -0
- data/plugins/kernel_v2/config/vm_provisioner.rb +55 -0
- data/plugins/kernel_v2/config/vm_subvm.rb +30 -0
- data/plugins/kernel_v2/plugin.rb +44 -0
- data/plugins/providers/virtualbox/action/boot.rb +49 -0
- data/plugins/providers/virtualbox/action/check_accessible.rb +23 -0
- data/plugins/providers/virtualbox/action/check_created.rb +21 -0
- data/plugins/providers/virtualbox/action/check_guest_additions.rb +45 -0
- data/plugins/providers/virtualbox/action/check_running.rb +21 -0
- data/plugins/providers/virtualbox/action/check_virtualbox.rb +22 -0
- data/plugins/providers/virtualbox/action/clean_machine_folder.rb +43 -0
- data/plugins/providers/virtualbox/action/clear_forwarded_ports.rb +18 -0
- data/plugins/providers/virtualbox/action/clear_network_interfaces.rb +31 -0
- data/plugins/providers/virtualbox/action/clear_shared_folders.rb +17 -0
- data/plugins/providers/virtualbox/action/created.rb +20 -0
- data/plugins/providers/virtualbox/action/customize.rb +36 -0
- data/plugins/providers/virtualbox/action/destroy.rb +19 -0
- data/plugins/providers/virtualbox/action/destroy_unused_network_interfaces.rb +16 -0
- data/plugins/providers/virtualbox/action/discard_state.rb +20 -0
- data/plugins/providers/virtualbox/action/export.rb +57 -0
- data/plugins/providers/virtualbox/action/forced_halt.rb +25 -0
- data/plugins/providers/virtualbox/action/forward_ports.rb +87 -0
- data/plugins/providers/virtualbox/action/import.rb +51 -0
- data/plugins/providers/virtualbox/action/is_paused.rb +20 -0
- data/plugins/providers/virtualbox/action/is_running.rb +20 -0
- data/plugins/providers/virtualbox/action/is_saved.rb +20 -0
- data/plugins/providers/virtualbox/action/match_mac_address.rb +21 -0
- data/plugins/providers/virtualbox/action/message_already_running.rb +16 -0
- data/plugins/providers/virtualbox/action/message_not_created.rb +16 -0
- data/plugins/providers/virtualbox/action/message_not_running.rb +16 -0
- data/plugins/providers/virtualbox/action/message_will_not_destroy.rb +17 -0
- data/plugins/providers/virtualbox/action/network.rb +410 -0
- data/plugins/providers/virtualbox/action/package.rb +20 -0
- data/plugins/providers/virtualbox/action/package_vagrantfile.rb +33 -0
- data/plugins/providers/virtualbox/action/prepare_forwarded_port_collision_params.rb +35 -0
- data/plugins/providers/virtualbox/action/prepare_nfs_settings.rb +64 -0
- data/plugins/providers/virtualbox/action/prune_nfs_exports.rb +20 -0
- data/plugins/providers/virtualbox/action/resume.rb +25 -0
- data/plugins/providers/virtualbox/action/sane_defaults.rb +91 -0
- data/plugins/providers/virtualbox/action/set_name.rb +40 -0
- data/plugins/providers/virtualbox/action/setup_package_files.rb +51 -0
- data/plugins/providers/virtualbox/action/share_folders.rb +128 -0
- data/plugins/providers/virtualbox/action/suspend.rb +20 -0
- data/plugins/providers/virtualbox/action.rb +311 -0
- data/plugins/providers/virtualbox/config.rb +86 -0
- data/plugins/providers/virtualbox/driver/base.rb +360 -0
- data/plugins/providers/virtualbox/driver/meta.rb +142 -0
- data/plugins/providers/virtualbox/driver/version_4_0.rb +485 -0
- data/plugins/providers/virtualbox/driver/version_4_1.rb +485 -0
- data/plugins/providers/virtualbox/driver/version_4_2.rb +482 -0
- data/plugins/providers/virtualbox/model/forwarded_port.rb +58 -0
- data/plugins/providers/virtualbox/plugin.rb +42 -0
- data/plugins/providers/virtualbox/provider.rb +92 -0
- data/plugins/providers/virtualbox/util/compile_forwarded_ports.rb +31 -0
- data/plugins/provisioners/ansible/config.rb +72 -0
- data/plugins/provisioners/ansible/plugin.rb +23 -0
- data/plugins/provisioners/ansible/provisioner.rb +45 -0
- data/plugins/provisioners/cfengine/cap/debian/cfengine_install.rb +19 -0
- data/plugins/provisioners/cfengine/cap/linux/cfengine_installed.rb +14 -0
- data/plugins/provisioners/cfengine/cap/linux/cfengine_needs_bootstrap.rb +34 -0
- data/plugins/provisioners/cfengine/cap/redhat/cfengine_install.rb +24 -0
- data/plugins/provisioners/cfengine/config.rb +120 -0
- data/plugins/provisioners/cfengine/plugin.rb +42 -0
- data/plugins/provisioners/cfengine/provisioner.rb +136 -0
- data/plugins/provisioners/chef/config/base.rb +85 -0
- data/plugins/provisioners/chef/config/chef_client.rb +57 -0
- data/plugins/provisioners/chef/config/chef_solo.rb +87 -0
- data/plugins/provisioners/chef/plugin.rb +33 -0
- data/plugins/provisioners/chef/provisioner/base.rb +93 -0
- data/plugins/provisioners/chef/provisioner/chef_client.rb +107 -0
- data/plugins/provisioners/chef/provisioner/chef_solo.rb +192 -0
- data/plugins/provisioners/puppet/config/puppet.rb +70 -0
- data/plugins/provisioners/puppet/config/puppet_server.rb +16 -0
- data/plugins/provisioners/puppet/plugin.rb +33 -0
- data/plugins/provisioners/puppet/provisioner/puppet.rb +117 -0
- data/plugins/provisioners/puppet/provisioner/puppet_server.rb +67 -0
- data/plugins/provisioners/shell/config.rb +56 -0
- data/plugins/provisioners/shell/plugin.rb +23 -0
- data/plugins/provisioners/shell/provisioner.rb +86 -0
- data/tasks/acceptance.rake +113 -0
- data/tasks/bundler.rake +3 -0
- data/tasks/test.rake +20 -0
- data/templates/commands/init/Vagrantfile.erb +111 -0
- data/templates/commands/ssh_config/config.erb +16 -0
- data/templates/config/messages.erb +14 -0
- data/templates/config/validation_failed.erb +7 -0
- data/templates/guests/arch/network_dhcp.erb +4 -0
- data/templates/guests/arch/network_static.erb +6 -0
- data/templates/guests/debian/network_dhcp.erb +11 -0
- data/templates/guests/debian/network_static.erb +7 -0
- data/templates/guests/fedora/network_dhcp.erb +6 -0
- data/templates/guests/fedora/network_static.erb +13 -0
- data/templates/guests/freebsd/network_dhcp.erb +3 -0
- data/templates/guests/freebsd/network_static.erb +3 -0
- data/templates/guests/gentoo/network_dhcp.erb +4 -0
- data/templates/guests/gentoo/network_static.erb +4 -0
- data/templates/guests/redhat/network_dhcp.erb +6 -0
- data/templates/guests/redhat/network_static.erb +8 -0
- data/templates/locales/en.yml +1126 -0
- data/templates/nfs/exports.erb +5 -0
- data/templates/nfs/exports_freebsd.erb +5 -0
- data/templates/nfs/exports_linux.erb +5 -0
- data/templates/package_Vagrantfile.erb +11 -0
- data/templates/provisioners/chef_client/client.erb +32 -0
- data/templates/provisioners/chef_solo/solo.erb +25 -0
- data/templates/rgloader.rb +9 -0
- data/test/acceptance/base.rb +48 -0
- data/test/acceptance/box_test.rb +99 -0
- data/test/acceptance/destroy_test.rb +37 -0
- data/test/acceptance/halt_test.rb +72 -0
- data/test/acceptance/init_test.rb +33 -0
- data/test/acceptance/networking/host_only_test.rb +37 -0
- data/test/acceptance/networking/port_forward_test.rb +125 -0
- data/test/acceptance/package_test.rb +46 -0
- data/test/acceptance/provisioning/basic_test.rb +61 -0
- data/test/acceptance/provisioning/chef_solo_test.rb +37 -0
- data/test/acceptance/provisioning/shell_test.rb +53 -0
- data/test/acceptance/resume_test.rb +17 -0
- data/test/acceptance/shared_folders_test.rb +84 -0
- data/test/acceptance/skeletons/chef_solo_basic/README.md +3 -0
- data/test/acceptance/skeletons/chef_solo_basic/cookbooks/basic/recipes/default.rb +5 -0
- data/test/acceptance/skeletons/chef_solo_json/README.md +3 -0
- data/test/acceptance/skeletons/chef_solo_json/cookbooks/basic/recipes/default.rb +6 -0
- data/test/acceptance/skeletons/provisioner_multi/README.md +3 -0
- data/test/acceptance/skeletons/provisioner_multi/cookbooks/basic/recipes/default.rb +5 -0
- data/test/acceptance/ssh_test.rb +46 -0
- data/test/acceptance/support/config.rb +42 -0
- data/test/acceptance/support/isolated_environment.rb +118 -0
- data/test/acceptance/support/matchers/have_color.rb +9 -0
- data/test/acceptance/support/matchers/match_output.rb +14 -0
- data/test/acceptance/support/matchers/succeed.rb +14 -0
- data/test/acceptance/support/network_tests.rb +29 -0
- data/test/acceptance/support/output.rb +95 -0
- data/test/acceptance/support/shared/base_context.rb +72 -0
- data/test/acceptance/support/shared/command_examples.rb +33 -0
- data/test/acceptance/support/virtualbox.rb +36 -0
- data/test/acceptance/suspend_test.rb +56 -0
- data/test/acceptance/up_basic_test.rb +33 -0
- data/test/acceptance/up_with_box_url.rb +40 -0
- data/test/acceptance/vagrant_test.rb +47 -0
- data/test/acceptance/version_test.rb +15 -0
- data/test/config/acceptance_boxes.yml +7 -0
- data/test/support/isolated_environment.rb +46 -0
- data/test/support/tempdir.rb +43 -0
- data/test/unit/base.rb +27 -0
- data/test/unit/support/dummy_provider.rb +16 -0
- data/test/unit/support/isolated_environment.rb +179 -0
- data/test/unit/support/shared/base_context.rb +104 -0
- data/test/unit/vagrant/action/builder_test.rb +242 -0
- data/test/unit/vagrant/action/builtin/call_test.rb +145 -0
- data/test/unit/vagrant/action/builtin/confirm_test.rb +36 -0
- data/test/unit/vagrant/action/builtin/env_set_test.rb +20 -0
- data/test/unit/vagrant/action/builtin/graceful_halt_test.rb +61 -0
- data/test/unit/vagrant/action/builtin/lock_test.rb +98 -0
- data/test/unit/vagrant/action/builtin/ssh_exec_test.rb +57 -0
- data/test/unit/vagrant/action/hook_test.rb +120 -0
- data/test/unit/vagrant/action/runner_test.rb +71 -0
- data/test/unit/vagrant/action/warden_test.rb +92 -0
- data/test/unit/vagrant/batch_action_test.rb +36 -0
- data/test/unit/vagrant/box_collection_test.rb +237 -0
- data/test/unit/vagrant/box_test.rb +122 -0
- data/test/unit/vagrant/cli_test.rb +27 -0
- data/test/unit/vagrant/config/loader_test.rb +184 -0
- data/test/unit/vagrant/config/v1/dummy_config_test.rb +24 -0
- data/test/unit/vagrant/config/v1/loader_test.rb +145 -0
- data/test/unit/vagrant/config/v1/root_test.rb +40 -0
- data/test/unit/vagrant/config/v2/dummy_config_test.rb +24 -0
- data/test/unit/vagrant/config/v2/loader_test.rb +151 -0
- data/test/unit/vagrant/config/v2/root_test.rb +97 -0
- data/test/unit/vagrant/config/v2/util_test.rb +21 -0
- data/test/unit/vagrant/config_test.rb +66 -0
- data/test/unit/vagrant/environment_test.rb +721 -0
- data/test/unit/vagrant/guest_test.rb +166 -0
- data/test/unit/vagrant/hosts_test.rb +37 -0
- data/test/unit/vagrant/machine_state_test.rb +26 -0
- data/test/unit/vagrant/machine_test.rb +384 -0
- data/test/unit/vagrant/plugin/v1/command_test.rb +143 -0
- data/test/unit/vagrant/plugin/v1/communicator_test.rb +9 -0
- data/test/unit/vagrant/plugin/v1/config_test.rb +50 -0
- data/test/unit/vagrant/plugin/v1/host_test.rb +5 -0
- data/test/unit/vagrant/plugin/v1/manager_test.rb +114 -0
- data/test/unit/vagrant/plugin/v1/plugin_test.rb +267 -0
- data/test/unit/vagrant/plugin/v1/provider_test.rb +18 -0
- data/test/unit/vagrant/plugin/v2/command_test.rb +238 -0
- data/test/unit/vagrant/plugin/v2/communicator_test.rb +9 -0
- data/test/unit/vagrant/plugin/v2/components_test.rb +17 -0
- data/test/unit/vagrant/plugin/v2/config_test.rb +60 -0
- data/test/unit/vagrant/plugin/v2/host_test.rb +5 -0
- data/test/unit/vagrant/plugin/v2/manager_test.rb +174 -0
- data/test/unit/vagrant/plugin/v2/plugin_test.rb +305 -0
- data/test/unit/vagrant/plugin/v2/provider_test.rb +18 -0
- data/test/unit/vagrant/registry_test.rb +128 -0
- data/test/unit/vagrant/util/ansi_escape_code_remover_test.rb +16 -0
- data/test/unit/vagrant/util/downloader_test.rb +57 -0
- data/test/unit/vagrant/util/file_checksum_test.rb +23 -0
- data/test/unit/vagrant/util/hash_with_indifferent_access_test.rb +38 -0
- data/test/unit/vagrant/util/is_port_open_test.rb +53 -0
- data/test/unit/vagrant/util/line_endings_helper_test.rb +16 -0
- data/test/unit/vagrant/util/network_ip_test.rb +17 -0
- data/test/unit/vagrant/util/retryable_test.rb +106 -0
- data/test/unit/vagrant/util/safe_chdir_test.rb +43 -0
- data/test/unit/vagrant/util/scoped_hash_override_test.rb +48 -0
- data/test/unit/vagrant/util/ssh_test.rb +30 -0
- data/test/unit/vagrant/util/string_block_editor_test.rb +106 -0
- data/test/unit/vagrant/util/which_test.rb +43 -0
- data/test/unit/vagrant_test.rb +56 -0
- data/tnargav.gemspec +69 -0
- data/vagrant.gemspec +69 -0
- metadata +730 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
require File.expand_path("../base", __FILE__)
|
|
2
|
+
|
|
3
|
+
module VagrantPlugins
|
|
4
|
+
module Chef
|
|
5
|
+
module Config
|
|
6
|
+
class ChefSolo < Base
|
|
7
|
+
attr_accessor :cookbooks_path
|
|
8
|
+
attr_accessor :roles_path
|
|
9
|
+
attr_accessor :data_bags_path
|
|
10
|
+
attr_accessor :recipe_url
|
|
11
|
+
attr_accessor :nfs
|
|
12
|
+
attr_accessor :encrypted_data_bag_secret_key_path
|
|
13
|
+
attr_accessor :encrypted_data_bag_secret
|
|
14
|
+
|
|
15
|
+
def initialize
|
|
16
|
+
super
|
|
17
|
+
|
|
18
|
+
@cookbooks_path = UNSET_VALUE
|
|
19
|
+
@data_bags_path = UNSET_VALUE
|
|
20
|
+
@recipe_url = UNSET_VALUE
|
|
21
|
+
@roles_path = UNSET_VALUE
|
|
22
|
+
@encrypted_data_bag_secret = UNSET_VALUE
|
|
23
|
+
@encrypted_data_bag_secret_key_path = UNSET_VALUE
|
|
24
|
+
@nfs = UNSET_VALUE
|
|
25
|
+
|
|
26
|
+
@__defaulted_cookbooks_path = false
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
#------------------------------------------------------------
|
|
30
|
+
# Internal methods
|
|
31
|
+
#------------------------------------------------------------
|
|
32
|
+
|
|
33
|
+
def finalize!
|
|
34
|
+
super
|
|
35
|
+
|
|
36
|
+
@recipe_url = nil if @recipe_url == UNSET_VALUE
|
|
37
|
+
|
|
38
|
+
if @cookbooks_path == UNSET_VALUE
|
|
39
|
+
@cookbooks_path = []
|
|
40
|
+
@cookbooks_path << [:host, "cookbooks"] if !@recipe_url
|
|
41
|
+
@cookbooks_path << [:vm, "cookbooks"]
|
|
42
|
+
@__defaulted_cookbooks_path = true
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
@data_bags_path = [] if @data_bags_path == UNSET_VALUE
|
|
46
|
+
@roles_path = [] if @roles_path == UNSET_VALUE
|
|
47
|
+
|
|
48
|
+
# Make sure the path is an array.
|
|
49
|
+
@cookbooks_path = prepare_folders_config(@cookbooks_path)
|
|
50
|
+
@data_bags_path = prepare_folders_config(@data_bags_path)
|
|
51
|
+
@roles_path = prepare_folders_config(@roles_path)
|
|
52
|
+
|
|
53
|
+
@encrypted_data_bag_secret = "/tmp/encrypted_data_bag_secret" if \
|
|
54
|
+
@encrypted_data_bag_secret == UNSET_VALUE
|
|
55
|
+
@encrypted_data_bag_secret_key_path = nil if \
|
|
56
|
+
@encrypted_data_bag_secret_key_path == UNSET_VALUE
|
|
57
|
+
@nfs = false if @nfs == UNSET_VALUE
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def validate(machine)
|
|
61
|
+
errors = _detected_errors
|
|
62
|
+
errors << I18n.t("vagrant.config.chef.cookbooks_path_empty") if \
|
|
63
|
+
!cookbooks_path || [cookbooks_path].flatten.empty?
|
|
64
|
+
|
|
65
|
+
{ "chef solo provisioner" => errors }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
protected
|
|
69
|
+
|
|
70
|
+
# This takes any of the configurations that take a path or
|
|
71
|
+
# array of paths and turns it into the proper format.
|
|
72
|
+
#
|
|
73
|
+
# @return [Array]
|
|
74
|
+
def prepare_folders_config(config)
|
|
75
|
+
# Make sure the path is an array
|
|
76
|
+
config = [config] if !config.is_a?(Array) || config.first.is_a?(Symbol)
|
|
77
|
+
|
|
78
|
+
# Make sure all the paths are in the proper format
|
|
79
|
+
config.map do |path|
|
|
80
|
+
path = [:host, path] if !path.is_a?(Array)
|
|
81
|
+
path
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require "vagrant"
|
|
2
|
+
|
|
3
|
+
module VagrantPlugins
|
|
4
|
+
module Chef
|
|
5
|
+
class Plugin < Vagrant.plugin("2")
|
|
6
|
+
name "chef"
|
|
7
|
+
description <<-DESC
|
|
8
|
+
Provides support for provisioning your virtual machines with
|
|
9
|
+
Chef via `chef-solo` or `chef-client`.
|
|
10
|
+
DESC
|
|
11
|
+
|
|
12
|
+
config(:chef_solo, :provisioner) do
|
|
13
|
+
require File.expand_path("../config/chef_solo", __FILE__)
|
|
14
|
+
Config::ChefSolo
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
config(:chef_client, :provisioner) do
|
|
18
|
+
require File.expand_path("../config/chef_client", __FILE__)
|
|
19
|
+
Config::ChefClient
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
provisioner(:chef_solo) do
|
|
23
|
+
require File.expand_path("../provisioner/chef_solo", __FILE__)
|
|
24
|
+
Provisioner::ChefSolo
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
provisioner(:chef_client) do
|
|
28
|
+
require File.expand_path("../provisioner/chef_client", __FILE__)
|
|
29
|
+
Provisioner::ChefClient
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
require 'tempfile'
|
|
2
|
+
|
|
3
|
+
require "vagrant/util/counter"
|
|
4
|
+
require "vagrant/util/template_renderer"
|
|
5
|
+
|
|
6
|
+
module VagrantPlugins
|
|
7
|
+
module Chef
|
|
8
|
+
module Provisioner
|
|
9
|
+
# This class is a base class where the common functionality shared between
|
|
10
|
+
# chef-solo and chef-client provisioning are stored. This is **not an actual
|
|
11
|
+
# provisioner**. Instead, {ChefSolo} or {ChefServer} should be used.
|
|
12
|
+
class Base < Vagrant.plugin("2", :provisioner)
|
|
13
|
+
class ChefError < Vagrant::Errors::VagrantError
|
|
14
|
+
error_namespace("vagrant.provisioners.chef")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
include Vagrant::Util::Counter
|
|
18
|
+
|
|
19
|
+
def initialize(machine, config)
|
|
20
|
+
super
|
|
21
|
+
|
|
22
|
+
config.provisioning_path ||= "/tmp/vagrant-chef-#{get_and_update_counter(:provisioning_path)}"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def verify_binary(binary)
|
|
26
|
+
# Checks for the existence of chef binary and error if it
|
|
27
|
+
# doesn't exist.
|
|
28
|
+
@machine.communicate.sudo(
|
|
29
|
+
"which #{binary}",
|
|
30
|
+
:error_class => ChefError,
|
|
31
|
+
:error_key => :chef_not_detected,
|
|
32
|
+
:binary => binary)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Returns the path to the Chef binary, taking into account the
|
|
36
|
+
# `binary_path` configuration option.
|
|
37
|
+
def chef_binary_path(binary)
|
|
38
|
+
return binary if !@config.binary_path
|
|
39
|
+
return File.join(@config.binary_path, binary)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def chown_provisioning_folder
|
|
43
|
+
@machine.communicate.tap do |comm|
|
|
44
|
+
comm.sudo("mkdir -p #{@config.provisioning_path}")
|
|
45
|
+
comm.sudo("chown -R #{@machine.ssh_info[:username]} #{@config.provisioning_path}")
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def setup_config(template, filename, template_vars)
|
|
50
|
+
config_file = Vagrant::Util::TemplateRenderer.render(template, {
|
|
51
|
+
:log_level => @config.log_level.to_sym,
|
|
52
|
+
:http_proxy => @config.http_proxy,
|
|
53
|
+
:http_proxy_user => @config.http_proxy_user,
|
|
54
|
+
:http_proxy_pass => @config.http_proxy_pass,
|
|
55
|
+
:https_proxy => @config.https_proxy,
|
|
56
|
+
:https_proxy_user => @config.https_proxy_user,
|
|
57
|
+
:https_proxy_pass => @config.https_proxy_pass,
|
|
58
|
+
:no_proxy => @config.no_proxy
|
|
59
|
+
}.merge(template_vars))
|
|
60
|
+
|
|
61
|
+
# Create a temporary file to store the data so we
|
|
62
|
+
# can upload it
|
|
63
|
+
temp = Tempfile.new("vagrant")
|
|
64
|
+
temp.write(config_file)
|
|
65
|
+
temp.close
|
|
66
|
+
|
|
67
|
+
remote_file = File.join(config.provisioning_path, filename)
|
|
68
|
+
@machine.communicate.tap do |comm|
|
|
69
|
+
comm.sudo("rm #{remote_file}", :error_check => false)
|
|
70
|
+
comm.upload(temp.path, remote_file)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def setup_json
|
|
75
|
+
@machine.env.ui.info I18n.t("vagrant.provisioners.chef.json")
|
|
76
|
+
|
|
77
|
+
# Get the JSON that we're going to expose to Chef
|
|
78
|
+
json = @config.json
|
|
79
|
+
json[:run_list] = @config.run_list if !@config.run_list.empty?
|
|
80
|
+
json = JSON.pretty_generate(json)
|
|
81
|
+
|
|
82
|
+
# Create a temporary file to store the data so we
|
|
83
|
+
# can upload it
|
|
84
|
+
temp = Tempfile.new("vagrant")
|
|
85
|
+
temp.write(json)
|
|
86
|
+
temp.close
|
|
87
|
+
|
|
88
|
+
@machine.communicate.upload(temp.path, File.join(@config.provisioning_path, "dna.json"))
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
require 'pathname'
|
|
2
|
+
|
|
3
|
+
require File.expand_path("../base", __FILE__)
|
|
4
|
+
|
|
5
|
+
module VagrantPlugins
|
|
6
|
+
module Chef
|
|
7
|
+
module Provisioner
|
|
8
|
+
# This class implements provisioning via chef-client, allowing provisioning
|
|
9
|
+
# with a chef server.
|
|
10
|
+
class ChefClient < Base
|
|
11
|
+
def configure(root_config)
|
|
12
|
+
raise ChefError, :server_validation_key_required if @config.validation_key_path.nil?
|
|
13
|
+
raise ChefError, :server_validation_key_doesnt_exist if !File.file?(validation_key_path)
|
|
14
|
+
raise ChefError, :server_url_required if @config.chef_server_url.nil?
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def provision
|
|
18
|
+
verify_binary(chef_binary_path("chef-client"))
|
|
19
|
+
chown_provisioning_folder
|
|
20
|
+
create_client_key_folder
|
|
21
|
+
upload_validation_key
|
|
22
|
+
upload_encrypted_data_bag_secret if @config.encrypted_data_bag_secret_key_path
|
|
23
|
+
setup_json
|
|
24
|
+
setup_server_config
|
|
25
|
+
run_chef_client
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def create_client_key_folder
|
|
29
|
+
@machine.env.ui.info I18n.t("vagrant.provisioners.chef.client_key_folder")
|
|
30
|
+
path = Pathname.new(@config.client_key_path)
|
|
31
|
+
|
|
32
|
+
@machine.communicate.sudo("mkdir -p #{path.dirname}")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def upload_validation_key
|
|
36
|
+
@machine.env.ui.info I18n.t("vagrant.provisioners.chef.upload_validation_key")
|
|
37
|
+
@machine.communicate.upload(validation_key_path, guest_validation_key_path)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def upload_encrypted_data_bag_secret
|
|
41
|
+
@machine.env.ui.info I18n.t("vagrant.provisioners.chef.upload_encrypted_data_bag_secret_key")
|
|
42
|
+
@machine.communicate.upload(encrypted_data_bag_secret_key_path,
|
|
43
|
+
@config.encrypted_data_bag_secret)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def setup_server_config
|
|
47
|
+
setup_config("provisioners/chef_client/client", "client.rb", {
|
|
48
|
+
:node_name => @config.node_name,
|
|
49
|
+
:chef_server_url => @config.chef_server_url,
|
|
50
|
+
:validation_client_name => @config.validation_client_name,
|
|
51
|
+
:validation_key => guest_validation_key_path,
|
|
52
|
+
:client_key => @config.client_key_path,
|
|
53
|
+
:file_cache_path => @config.file_cache_path,
|
|
54
|
+
:file_backup_path => @config.file_backup_path,
|
|
55
|
+
:environment => @config.environment,
|
|
56
|
+
:encrypted_data_bag_secret => @config.encrypted_data_bag_secret
|
|
57
|
+
})
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def run_chef_client
|
|
61
|
+
if @config.run_list && @config.run_list.empty?
|
|
62
|
+
@machine.ui.warn(I18n.t("vagrant.chef_run_list_empty"))
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
command_env = @config.binary_env ? "#{@config.binary_env} " : ""
|
|
66
|
+
command_args = @config.arguments ? " #{@config.arguments}" : ""
|
|
67
|
+
command = "#{command_env}#{chef_binary_path("chef-client")} -c #{@config.provisioning_path}/client.rb -j #{@config.provisioning_path}/dna.json #{command_args}"
|
|
68
|
+
|
|
69
|
+
@config.attempts.times do |attempt|
|
|
70
|
+
if attempt == 0
|
|
71
|
+
@machine.env.ui.info I18n.t("vagrant.provisioners.chef.running_client")
|
|
72
|
+
else
|
|
73
|
+
@machine.env.ui.info I18n.t("vagrant.provisioners.chef.running_client_again")
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
exit_status = @machine.communicate.sudo(command, :error_check => false) do |type, data|
|
|
77
|
+
# Output the data with the proper color based on the stream.
|
|
78
|
+
color = type == :stdout ? :green : :red
|
|
79
|
+
|
|
80
|
+
# Note: Be sure to chomp the data to avoid the newlines that the
|
|
81
|
+
# Chef outputs.
|
|
82
|
+
@machine.env.ui.info(data.chomp, :color => color, :prefix => false)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# There is no need to run Chef again if it converges
|
|
86
|
+
return if exit_status == 0
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# If we reached this point then Chef never converged! Error.
|
|
90
|
+
raise ChefError, :no_convergence
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def validation_key_path
|
|
94
|
+
File.expand_path(@config.validation_key_path, @machine.env.root_path)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def encrypted_data_bag_secret_key_path
|
|
98
|
+
File.expand_path(@config.encrypted_data_bag_secret_key_path, @machine.env.root_path)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def guest_validation_key_path
|
|
102
|
+
File.join(@config.provisioning_path, "validation.pem")
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
require "log4r"
|
|
2
|
+
|
|
3
|
+
require "vagrant/util/counter"
|
|
4
|
+
|
|
5
|
+
require File.expand_path("../base", __FILE__)
|
|
6
|
+
|
|
7
|
+
module VagrantPlugins
|
|
8
|
+
module Chef
|
|
9
|
+
module Provisioner
|
|
10
|
+
# This class implements provisioning via chef-solo.
|
|
11
|
+
class ChefSolo < Base
|
|
12
|
+
extend Vagrant::Util::Counter
|
|
13
|
+
include Vagrant::Util::Counter
|
|
14
|
+
|
|
15
|
+
attr_reader :cookbook_folders
|
|
16
|
+
attr_reader :role_folders
|
|
17
|
+
attr_reader :data_bags_folders
|
|
18
|
+
|
|
19
|
+
def initialize(machine, config)
|
|
20
|
+
super
|
|
21
|
+
@logger = Log4r::Logger.new("vagrant::provisioners::chef_solo")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def configure(root_config)
|
|
25
|
+
@cookbook_folders = expanded_folders(@config.cookbooks_path, "cookbooks")
|
|
26
|
+
@role_folders = expanded_folders(@config.roles_path, "roles")
|
|
27
|
+
@data_bags_folders = expanded_folders(@config.data_bags_path, "data_bags")
|
|
28
|
+
|
|
29
|
+
share_folders(root_config, "csc", @cookbook_folders)
|
|
30
|
+
share_folders(root_config, "csr", @role_folders)
|
|
31
|
+
share_folders(root_config, "csdb", @data_bags_folders)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def provision
|
|
35
|
+
# Verify that the proper shared folders exist.
|
|
36
|
+
check = []
|
|
37
|
+
[@cookbook_folders, @role_folders, @data_bags_folders].each do |folders|
|
|
38
|
+
folders.each do |type, local_path, remote_path|
|
|
39
|
+
# We only care about checking folders that have a local path, meaning
|
|
40
|
+
# they were shared from the local machine, rather than assumed to
|
|
41
|
+
# exist on the VM.
|
|
42
|
+
check << remote_path if local_path
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
verify_shared_folders(check)
|
|
47
|
+
|
|
48
|
+
verify_binary(chef_binary_path("chef-solo"))
|
|
49
|
+
chown_provisioning_folder
|
|
50
|
+
upload_encrypted_data_bag_secret if @config.encrypted_data_bag_secret_key_path
|
|
51
|
+
setup_json
|
|
52
|
+
setup_solo_config
|
|
53
|
+
run_chef_solo
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Converts paths to a list of properly expanded paths with types.
|
|
57
|
+
def expanded_folders(paths, appended_folder=nil)
|
|
58
|
+
# Convert the path to an array if it is a string or just a single
|
|
59
|
+
# path element which contains the folder location (:host or :vm)
|
|
60
|
+
paths = [paths] if paths.is_a?(String) || paths.first.is_a?(Symbol)
|
|
61
|
+
|
|
62
|
+
results = []
|
|
63
|
+
paths.each do |type, path|
|
|
64
|
+
# Create the local/remote path based on whether this is a host
|
|
65
|
+
# or VM path.
|
|
66
|
+
local_path = nil
|
|
67
|
+
remote_path = nil
|
|
68
|
+
if type == :host
|
|
69
|
+
# Get the expanded path that the host path points to
|
|
70
|
+
local_path = File.expand_path(path, @machine.env.root_path)
|
|
71
|
+
|
|
72
|
+
if File.exist?(local_path)
|
|
73
|
+
# Path exists on the host, setup the remote path
|
|
74
|
+
remote_path = "#{@config.provisioning_path}/chef-solo-#{get_and_update_counter(:cookbooks_path)}"
|
|
75
|
+
else
|
|
76
|
+
@machine.ui.warn(I18n.t("vagrant.provisioners.chef.cookbook_folder_not_found_warning",
|
|
77
|
+
path: local_path.to_s))
|
|
78
|
+
next
|
|
79
|
+
end
|
|
80
|
+
else
|
|
81
|
+
# Path already exists on the virtual machine. Expand it
|
|
82
|
+
# relative to where we're provisioning.
|
|
83
|
+
remote_path = File.expand_path(path, @config.provisioning_path)
|
|
84
|
+
|
|
85
|
+
# Remove drive letter if running on a windows host. This is a bit
|
|
86
|
+
# of a hack but is the most portable way I can think of at the moment
|
|
87
|
+
# to achieve this. Otherwise, Vagrant attempts to share at some crazy
|
|
88
|
+
# path like /home/vagrant/c:/foo/bar
|
|
89
|
+
remote_path = remote_path.gsub(/^[a-zA-Z]:/, "")
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# If we have specified a folder name to append then append it
|
|
93
|
+
remote_path += "/#{appended_folder}" if appended_folder
|
|
94
|
+
|
|
95
|
+
# Append the result
|
|
96
|
+
results << [type, local_path, remote_path]
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
results
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Shares the given folders with the given prefix. The folders should
|
|
103
|
+
# be of the structure resulting from the `expanded_folders` function.
|
|
104
|
+
def share_folders(root_config, prefix, folders)
|
|
105
|
+
folders.each do |type, local_path, remote_path|
|
|
106
|
+
if type == :host
|
|
107
|
+
root_config.vm.synced_folder(
|
|
108
|
+
local_path, remote_path,
|
|
109
|
+
:id => "v-#{prefix}-#{self.class.get_and_update_counter(:shared_folder)}",
|
|
110
|
+
:nfs => @config.nfs)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def upload_encrypted_data_bag_secret
|
|
116
|
+
@machine.env.ui.info I18n.t("vagrant.provisioners.chef.upload_encrypted_data_bag_secret_key")
|
|
117
|
+
@machine.communicate.upload(encrypted_data_bag_secret_key_path,
|
|
118
|
+
@config.encrypted_data_bag_secret)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def setup_solo_config
|
|
122
|
+
cookbooks_path = guest_paths(@cookbook_folders)
|
|
123
|
+
roles_path = guest_paths(@role_folders).first
|
|
124
|
+
data_bags_path = guest_paths(@data_bags_folders).first
|
|
125
|
+
|
|
126
|
+
setup_config("provisioners/chef_solo/solo", "solo.rb", {
|
|
127
|
+
:node_name => @config.node_name,
|
|
128
|
+
:provisioning_path => @config.provisioning_path,
|
|
129
|
+
:cookbooks_path => cookbooks_path,
|
|
130
|
+
:recipe_url => @config.recipe_url,
|
|
131
|
+
:roles_path => roles_path,
|
|
132
|
+
:data_bags_path => data_bags_path,
|
|
133
|
+
:encrypted_data_bag_secret => @config.encrypted_data_bag_secret,
|
|
134
|
+
})
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def run_chef_solo
|
|
138
|
+
if @config.run_list && @config.run_list.empty?
|
|
139
|
+
@machine.ui.warn(I18n.t("vagrant.chef_run_list_empty"))
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
command_env = @config.binary_env ? "#{@config.binary_env} " : ""
|
|
143
|
+
command_args = @config.arguments ? " #{@config.arguments}" : ""
|
|
144
|
+
command = "#{command_env}#{chef_binary_path("chef-solo")} -c #{@config.provisioning_path}/solo.rb -j #{@config.provisioning_path}/dna.json #{command_args}"
|
|
145
|
+
|
|
146
|
+
@config.attempts.times do |attempt|
|
|
147
|
+
if attempt == 0
|
|
148
|
+
@machine.env.ui.info I18n.t("vagrant.provisioners.chef.running_solo")
|
|
149
|
+
else
|
|
150
|
+
@machine.env.ui.info I18n.t("vagrant.provisioners.chef.running_solo_again")
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
exit_status = @machine.communicate.sudo(command, :error_check => false) do |type, data|
|
|
154
|
+
# Output the data with the proper color based on the stream.
|
|
155
|
+
color = type == :stdout ? :green : :red
|
|
156
|
+
|
|
157
|
+
# Note: Be sure to chomp the data to avoid the newlines that the
|
|
158
|
+
# Chef outputs.
|
|
159
|
+
@machine.env.ui.info(data.chomp, :color => color, :prefix => false)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# There is no need to run Chef again if it converges
|
|
163
|
+
return if exit_status == 0
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# If we reached this point then Chef never converged! Error.
|
|
167
|
+
raise ChefError, :no_convergence
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def verify_shared_folders(folders)
|
|
171
|
+
folders.each do |folder|
|
|
172
|
+
@logger.debug("Checking for shared folder: #{folder}")
|
|
173
|
+
if !@machine.communicate.test("test -d #{folder}")
|
|
174
|
+
raise ChefError, :missing_shared_folders
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def encrypted_data_bag_secret_key_path
|
|
180
|
+
File.expand_path(@config.encrypted_data_bag_secret_key_path, @machine.env.root_path)
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
protected
|
|
184
|
+
|
|
185
|
+
# Extracts only the remote paths from a list of folders
|
|
186
|
+
def guest_paths(folders)
|
|
187
|
+
folders.map { |parts| parts[2] }
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
module VagrantPlugins
|
|
2
|
+
module Puppet
|
|
3
|
+
module Config
|
|
4
|
+
class Puppet < Vagrant.plugin("2", :config)
|
|
5
|
+
attr_accessor :manifest_file
|
|
6
|
+
attr_accessor :manifests_path
|
|
7
|
+
attr_accessor :module_path
|
|
8
|
+
attr_accessor :pp_path
|
|
9
|
+
attr_accessor :options
|
|
10
|
+
attr_accessor :facter
|
|
11
|
+
|
|
12
|
+
def manifest_file; @manifest_file || "default.pp"; end
|
|
13
|
+
def manifests_path; @manifests_path || "manifests"; end
|
|
14
|
+
def pp_path; @pp_path || "/tmp/vagrant-puppet"; end
|
|
15
|
+
def options; @options ||= []; end
|
|
16
|
+
def facter; @facter ||= {}; end
|
|
17
|
+
|
|
18
|
+
# Returns the manifests path expanded relative to the root path of the
|
|
19
|
+
# environment.
|
|
20
|
+
def expanded_manifests_path(root_path)
|
|
21
|
+
Pathname.new(manifests_path).expand_path(root_path)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Returns the module paths as an array of paths expanded relative to the
|
|
25
|
+
# root path.
|
|
26
|
+
def expanded_module_paths(root_path)
|
|
27
|
+
return [] if !module_path
|
|
28
|
+
|
|
29
|
+
# Get all the paths and expand them relative to the root path, returning
|
|
30
|
+
# the array of expanded paths
|
|
31
|
+
paths = module_path
|
|
32
|
+
paths = [paths] if !paths.is_a?(Array)
|
|
33
|
+
paths.map do |path|
|
|
34
|
+
Pathname.new(path).expand_path(root_path)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def validate(machine)
|
|
39
|
+
errors = []
|
|
40
|
+
|
|
41
|
+
# Calculate the manifests and module paths based on env
|
|
42
|
+
this_expanded_manifests_path = expanded_manifests_path(machine.env.root_path)
|
|
43
|
+
this_expanded_module_paths = expanded_module_paths(machine.env.root_path)
|
|
44
|
+
|
|
45
|
+
# Manifests path/file validation
|
|
46
|
+
if !this_expanded_manifests_path.directory?
|
|
47
|
+
errors << I18n.t("vagrant.provisioners.puppet.manifests_path_missing",
|
|
48
|
+
:path => this_expanded_manifests_path)
|
|
49
|
+
else
|
|
50
|
+
expanded_manifest_file = this_expanded_manifests_path.join(manifest_file)
|
|
51
|
+
if !expanded_manifest_file.file?
|
|
52
|
+
errors << I18n.t("vagrant.provisioners.puppet.manifest_missing",
|
|
53
|
+
:manifest => expanded_manifest_file.to_s)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Module paths validation
|
|
58
|
+
this_expanded_module_paths.each do |path|
|
|
59
|
+
if !path.directory?
|
|
60
|
+
errors << I18n.t("vagrant.provisioners.puppet.module_path_missing",
|
|
61
|
+
:path => path)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
{ "puppet provisioner" => errors }
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module VagrantPlugins
|
|
2
|
+
module Puppet
|
|
3
|
+
module Config
|
|
4
|
+
class PuppetServer < Vagrant.plugin("2", :config)
|
|
5
|
+
attr_accessor :puppet_server
|
|
6
|
+
attr_accessor :puppet_node
|
|
7
|
+
attr_accessor :options
|
|
8
|
+
attr_accessor :facter
|
|
9
|
+
|
|
10
|
+
def facter; @facter ||= {}; end
|
|
11
|
+
def puppet_server; @puppet_server || "puppet"; end
|
|
12
|
+
def options; @options ||= []; end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require "vagrant"
|
|
2
|
+
|
|
3
|
+
module VagrantPlugins
|
|
4
|
+
module Puppet
|
|
5
|
+
class Plugin < Vagrant.plugin("2")
|
|
6
|
+
name "puppet"
|
|
7
|
+
description <<-DESC
|
|
8
|
+
Provides support for provisioning your virtual machines with
|
|
9
|
+
Puppet either using `puppet apply` or a Puppet server.
|
|
10
|
+
DESC
|
|
11
|
+
|
|
12
|
+
config(:puppet, :provisioner) do
|
|
13
|
+
require File.expand_path("../config/puppet", __FILE__)
|
|
14
|
+
Config::Puppet
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
config(:puppet_server, :provisioner) do
|
|
18
|
+
require File.expand_path("../config/puppet_server", __FILE__)
|
|
19
|
+
Config::PuppetServer
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
provisioner(:puppet) do
|
|
23
|
+
require File.expand_path("../provisioner/puppet", __FILE__)
|
|
24
|
+
Provisioner::Puppet
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
provisioner(:puppet_server) do
|
|
28
|
+
require File.expand_path("../provisioner/puppet_server", __FILE__)
|
|
29
|
+
Provisioner::PuppetServer
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|