Class: VagrantPlugins::Orchestrate::Command::Init
- Inherits:
-
Object
- Object
- VagrantPlugins::Orchestrate::Command::Init
- Includes:
- Vagrant::Util
- Defined in:
- lib/vagrant-orchestrate/command/init.rb
Constant Summary collapse
- DEFAULT_SHELL_PATH =
"{{YOUR_SCRIPT_PATH}}"
- DEFAULT_WINRM_USERNAME =
"{{YOUR_WINRM_USERNAME}}"
- DEFAULT_WINRM_PASSWORD =
"{{YOUR_WINRM_PASSWORD}}"
- DEFAULT_SSH_USERNAME =
"{{YOUR_SSH_USERNAME}}"
- DEFAULT_SSH_PRIVATE_KEY_PATH =
"{{YOUR_SSH_PRIVATE_KEY_PATH}}"
- DEFAULT_PLUGINS =
["vagrant-orchestrate", "vagrant-managed-servers"]
Instance Method Summary collapse
-
#execute ⇒ Object
rubocop:disable MethodLength.
Instance Method Details
#execute ⇒ Object
rubocop:disable MethodLength
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/vagrant-orchestrate/command/init.rb', line 19 def execute = {} [:provisioners] = [] [:servers] = [] [:environments] = [] [:plugins] = DEFAULT_PLUGINS [:puppet_librarian_puppet] = false [:puppet_hiera] = true [:git] = true opts = OptionParser.new do |o| o. = "Usage: vagrant orchestrate init [options]" o.separator "" o.separator "Options:" o.separator "" o.on("--provision-with x,y,z", Array, "Init only certain provisioners, by type.") do |list| [:provisioners] = list end o.on("--shell", "Shorthand for --provision-with shell") do [:provisioners] << "shell" end o.on("--shell-paths x,y,z", Array, "Comma-separated list of shell scripts to run on provision. Only with --shell") do |list| [:shell_paths] = list end o.on("--shell-inline command", String, "Inline script to run. Only with --shell") do |c| [:shell_inline] = c end o.on("--puppet", "Shorthand for '--provision-with puppet'") do [:provisioners] << "puppet" end o.on("--[no-]puppet-hiera", "Include templates for hiera. Only with --puppet") do |p| [:puppet_hiera] = p end o.on("--[no-]puppet-librarian-puppet", "Include a Puppetfile and the vagrant-librarian-puppet plugin. Only with --puppet") do |p| [:puppet_librarian_puppet] = p end o.on("--ssh-username USERNAME", String, "The username for communicating over ssh") do |u| [:ssh_username] = u end o.on("--ssh-password PASSWORD", String, "The password for communicating over ssh") do |p| [:ssh_password] = p end o.on("--ssh-private-key-path PATH", String, "Paths to the private key for communinicating over ssh") do |k| [:ssh_private_key_path] = k end o.on("--winrm", "Use the winrm communicator") do [:communicator] = "winrm" [:plugins] << "vagrant-winrm-s" end o.on("--winrm-username USERNAME", String, "The username for communicating with winrm") do |u| [:winrm_username] = u end o.on("--winrm-password PASSWORD", String, "The password for communicating with winrm") do |p| [:winrm_password] = p end o.on("--plugins x,y,z", Array, "A comma separated list of vagrant plugins to be installed") do |p| [:plugins] += p end o.on("--servers x,y,z", Array, "A CSV list of FQDNs to target managed servers") do |list| [:servers] = list end o.on("--environments x,y,z", Array, "A CSV list of environments. Takes precedence over --servers") do |list| [:environments] = list end o.on("--[no-]git", "Include useful templates for working in a git repository. Default is true.") o.on("-f", "--force", "Force overwriting of files") do [:force] = true end o.on("--credentials-prompt", "Prompt for credentials when performing orchestrate operations") do [:creds_prompt] = true end cfpmsg = "The path to a yaml file containing :username and :password fields to use with vagrant orchestrate" o.on("--credentials-file-path FILEPATH", String, cfpmsg) do |file_path| [:creds_file_path] = file_path end o.on("--deployment-tracker-host host", String, "Fully qualified URL of deployment-tracker instance") do |t| [:tracker_host] = t end end argv = (opts) return unless argv [:shell_paths] ||= [:shell_inline] ? [] : [DEFAULT_SHELL_PATH] [:winrm_username] ||= DEFAULT_WINRM_USERNAME [:winrm_password] ||= DEFAULT_WINRM_PASSWORD [:communicator] ||= "ssh" [:ssh_username] ||= DEFAULT_SSH_USERNAME [:ssh_private_key_path] ||= DEFAULT_SSH_PRIVATE_KEY_PATH unless [:ssh_password] init_puppet init_environments init_vagrant_files init_git @env.ui.info(I18n.t("vagrant.commands.init.success"), prefix: false) # Success, exit status 0 0 end |