Skip to content

Commit

Permalink
sudo_command option
Browse files Browse the repository at this point in the history
  • Loading branch information
neillturner committed May 19, 2016
1 parent e4408e6 commit ce24e66
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/kitchen-ansible/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
module Kitchen
module Ansible
VERSION = '0.42.3'
VERSION = '0.42.4'
end
end
12 changes: 8 additions & 4 deletions lib/kitchen/provisioner/ansible_playbook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def ansible_command(script)
s = https_proxy ? "https_proxy=#{https_proxy}" : nil
p = http_proxy ? "http_proxy=#{http_proxy}" : nil
n = no_proxy ? "no_proxy=#{no_proxy}" : nil
p || s || n ? " #{p} #{s} #{n} sudo -Es #{cd_ansible} #{script}" : "sudo -Es #{cd_ansible} #{script}"
p || s || n ? " #{p} #{s} #{n} #{config[:sudo_command]} -s #{cd_ansible} #{script}" : "#{config[:sudo_command]} -s #{cd_ansible} #{script}"
else
return script
end
Expand Down Expand Up @@ -536,7 +536,7 @@ def roles
def role_name
if config[:role_name]
config[:role_name]
elsif File.basename(roles) == 'roles'
elsif File.basename(roles) == 'roles'
''
else
File.basename(roles)
Expand Down Expand Up @@ -737,11 +737,15 @@ def no_proxy
config[:no_proxy]
end

def sudo_env(pm)
def sudo_env(pm,home=false)
s = https_proxy ? "https_proxy=#{https_proxy}" : nil
p = http_proxy ? "http_proxy=#{http_proxy}" : nil
n = no_proxy ? "no_proxy=#{no_proxy}" : nil
p || s || n ? "#{sudo('env')} #{p} #{s} #{n} #{pm}" : "#{sudo(pm)}"
if home
p || s || n ? "#{sudo_home('env')} #{p} #{s} #{n} #{pm}" : "#{sudo_home(pm)}"
else
p || s || n ? "#{sudo('env')} #{p} #{s} #{n} #{pm}" : "#{sudo(pm)}"
end
end

def export_http_proxy
Expand Down
1 change: 1 addition & 0 deletions provisioner_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ key | default value | Notes
----|---------------|--------
ansible_version | "latest"| desired version, affects apt installs
ansible_sudo | true | drives whether ansible-playbook is executed as root or as the current authenticated user
sudo_command | sudo -E | sudo command change to 'sudo -E -H' to be consistent with ansible
ansible_platform | naively tries to determine | OS platform of server
require_ansible_repo | true | Set if using a ansible install from yum or apt repo
ansible_apt_repo | "ppa:ansible/ansible" | apt repo. see https://launchpad.net /~ansible/+archive/ubuntu/ansible or rquillo/ansible
Expand Down

0 comments on commit ce24e66

Please sign in to comment.