Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

I was implemented, "install_chef_client" option for AmazonLinux. #85

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/vagrant-aws/action/run_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def call(env)
subnet_id = region_config.subnet_id
tags = region_config.tags
user_data = region_config.user_data
disable_sudo_requiretty = region_config.disable_sudo_requiretty

# If there is no keypair then warn the user
if !keypair
Expand All @@ -45,6 +46,17 @@ def call(env)
env[:ui].warn(I18n.t("vagrant_aws.launch_vpc_warning"))
end

# If disable_sudo_requiretty then set install-script to user_data
if disable_sudo_requiretty
if user_data
env[:ui].warn(I18n.t("vagrant_aws.user_data_overwrite_warning"))
end
user_data = <<-__DISABLE_SUDO_REQUIRE_TTY__
#!/bin/sh
sed -i -e 's/^\\(Defaults.*requiretty\\)/#\\1/' /etc/sudoers
__DISABLE_SUDO_REQUIRE_TTY__
end

# Launch!
env[:ui].info(I18n.t("vagrant_aws.launching_instance"))
env[:ui].info(" -- Type: #{instance_type}")
Expand Down
8 changes: 8 additions & 0 deletions lib/vagrant-aws/action/sync_folders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ def call(env)

ssh_info = env[:machine].ssh_info

region = env[:machine].provider_config.region
region_config = env[:machine].provider_config.get_region_config(region)
if region_config.disable_sudo_requiretty
# Wait to disable sudo-requiretty ...
env[:ui].info(I18n.t("vagrant_aws.waiting_to_disable_sudo_requiretty"))
env[:machine].communicate.execute("until sudo ls >/dev/null 2>&1; do sleep 1; done")
end

env[:machine].config.vm.synced_folders.each do |id, data|
data = scoped_hash_override(data, :aws)

Expand Down
9 changes: 9 additions & 0 deletions lib/vagrant-aws/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ class Config < Vagrant.plugin("2", :config)
# @return [String]
attr_accessor :user_data

# Set true if disable sudo-requiretty with user_data.
#
# @return [Boolean]
attr_accessor :disable_sudo_requiretty

def initialize(region_specific=false)
@access_key_id = UNSET_VALUE
@ami = UNSET_VALUE
Expand All @@ -103,6 +108,7 @@ def initialize(region_specific=false)
@tags = {}
@user_data = UNSET_VALUE
@use_iam_profile = UNSET_VALUE
@disable_sudo_requiretty = UNSET_VALUE

# Internal state (prefix with __ so they aren't automatically
# merged)
Expand Down Expand Up @@ -212,6 +218,9 @@ def finalize!
# User Data is nil by default
@user_data = nil if @user_data == UNSET_VALUE

# disable_sudo_requiretty false by default
@disable_sudo_requiretty = false if @disable_sudo_requiretty == UNSET_VALUE

# Compile our region specific configurations only within
# NON-REGION-SPECIFIC configurations.
if !@__region_specific
Expand Down
5 changes: 5 additions & 0 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ en:
will_not_destroy: |-
The instance '%{name}' will not be destroyed, since the confirmation
was declined.
user_data_overwrite_warning: |-
Warning! You have specified `user_data` and `disable_sudo_requiretty = true`.
`user_data` wiill be overwritten for setting to /etc/sudoers.
waiting_to_disable_sudo_requiretty: |-
Waiting for setting to /etc/sudoers...

config:
access_key_id_required: |-
Expand Down