2015-02-10 14:28:00 +00:00
|
|
|
require_relative "base"
|
2016-05-25 07:12:14 +00:00
|
|
|
require_relative "../helpers"
|
2015-02-10 14:28:00 +00:00
|
|
|
|
|
|
|
module VagrantPlugins
|
|
|
|
module Ansible
|
|
|
|
module Config
|
|
|
|
class Guest < Base
|
|
|
|
|
|
|
|
attr_accessor :provisioning_path
|
|
|
|
attr_accessor :tmp_path
|
|
|
|
attr_accessor :install
|
2016-06-08 20:59:47 +00:00
|
|
|
attr_accessor :install_mode
|
2017-01-06 13:19:44 +00:00
|
|
|
attr_accessor :pip_args
|
2015-02-10 14:28:00 +00:00
|
|
|
|
|
|
|
def initialize
|
|
|
|
super
|
|
|
|
|
|
|
|
@install = UNSET_VALUE
|
2016-06-08 20:59:47 +00:00
|
|
|
@install_mode = UNSET_VALUE
|
2017-01-06 13:19:44 +00:00
|
|
|
@pip_args = UNSET_VALUE
|
2015-02-10 14:28:00 +00:00
|
|
|
@provisioning_path = UNSET_VALUE
|
|
|
|
@tmp_path = UNSET_VALUE
|
|
|
|
end
|
|
|
|
|
|
|
|
def finalize!
|
|
|
|
super
|
|
|
|
|
|
|
|
@install = true if @install == UNSET_VALUE
|
2016-06-08 20:59:47 +00:00
|
|
|
@install_mode = :default if @install_mode == UNSET_VALUE
|
2017-01-06 13:19:44 +00:00
|
|
|
@pip_args = "" if @pip_args == UNSET_VALUE
|
2015-02-10 14:28:00 +00:00
|
|
|
@provisioning_path = "/vagrant" if provisioning_path == UNSET_VALUE
|
|
|
|
@tmp_path = "/tmp/vagrant-ansible" if tmp_path == UNSET_VALUE
|
|
|
|
end
|
|
|
|
|
|
|
|
def validate(machine)
|
|
|
|
super
|
|
|
|
|
ansible_local: Add the :pip_args_only install mode
With the introduction of `pip_args` option, you can easily extend the
`:pip` installation mode behaviour. But some interesting/advanced usages
are still not possible because of the auto-generated parts ("ansible"
package, version selection, and the `--upgrade` flag).
By adding this "pip_args_only" install mode, it will be for instance
possible to:
- install unofficial releases, like release candidates published at
https://releases.ansible.com/
- install more pip packages (e.g. via a `requirements.txt` file), with
hash validation, etc.
Note that there is no config validation that requires `pip_args` option
to be defined when the :pip_args_only mode is selected. This would be
more elegant, and user friendly to raise a configuration error, but this
can wait. At least, running with an empty `pip_args` won't lead to any
command crash, since the rather dummy "pip install" shows an helper
notice and terminates with a zero (0) exit code.
This change is thought as a complement to the changes originally
proposed in pull request GH-8170.
2017-03-23 22:10:56 +00:00
|
|
|
case @install_mode.to_s.to_sym
|
|
|
|
when :pip
|
2016-06-08 20:59:47 +00:00
|
|
|
@install_mode = :pip
|
ansible_local: Add the :pip_args_only install mode
With the introduction of `pip_args` option, you can easily extend the
`:pip` installation mode behaviour. But some interesting/advanced usages
are still not possible because of the auto-generated parts ("ansible"
package, version selection, and the `--upgrade` flag).
By adding this "pip_args_only" install mode, it will be for instance
possible to:
- install unofficial releases, like release candidates published at
https://releases.ansible.com/
- install more pip packages (e.g. via a `requirements.txt` file), with
hash validation, etc.
Note that there is no config validation that requires `pip_args` option
to be defined when the :pip_args_only mode is selected. This would be
more elegant, and user friendly to raise a configuration error, but this
can wait. At least, running with an empty `pip_args` won't lead to any
command crash, since the rather dummy "pip install" shows an helper
notice and terminates with a zero (0) exit code.
This change is thought as a complement to the changes originally
proposed in pull request GH-8170.
2017-03-23 22:10:56 +00:00
|
|
|
when :pip_args_only
|
|
|
|
@install_mode = :pip_args_only
|
2016-06-08 20:59:47 +00:00
|
|
|
else
|
|
|
|
@install_mode = :default
|
|
|
|
end
|
|
|
|
|
2015-02-10 14:28:00 +00:00
|
|
|
{ "ansible local provisioner" => @errors }
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|