This commit is contained in:
Ranjan Kumar 2014-02-04 13:31:26 +05:30
Родитель c7f1efe555
Коммит 01dcbce605
5 изменённых файлов: 28 добавлений и 6 удалений

Просмотреть файл

@ -12,6 +12,7 @@ module Puppet
def start(params)
puts "Installing puppet on node #{params[:node_ipaddress]}\n"
puts
params[:agent_environment] ||= 'production'
if params[:winrm_user]
bootstrap_windows_node(params)
elsif params[:ssh_user]
@ -29,6 +30,7 @@ module Puppet
master_ip = params[:puppet_master_ip]
login = params[:winrm_user]
password = params[:password]
env = params[:agent_environment]
if params[:winrm_transport] == 'https'
winrm_port = params[:winrm_port] || 5986
endpoint_protocol = 'https'
@ -45,7 +47,7 @@ module Puppet
end
cmds << 'cscript /nologo C:\\puppet\\wget.vbs https://downloads.puppetlabs.com/windows/puppet-3.3.2.msi %TEMP%\\puppet.msi'
cmds << 'copy %TEMP%\\puppet.msi C:\\puppet\\puppet.msi'
cmds << "msiexec /qn /i c:\\puppet\\puppet.msi PUPPET_MASTER_SERVER=#{master_ip}"
cmds << "msiexec /qn /i c:\\puppet\\puppet.msi PUPPET_MASTER_SERVER=#{master_ip} PUPPET_AGENT_ENVIRONMENT=#{env}"
cmds << 'sc config puppet start= demand'
cmds << 'rmdir C:\\puppet /s /q'
winrm_remote_execute(node_ip, login, password, cmds, endpoint_protocol, winrm_port)
@ -63,7 +65,7 @@ module Puppet
ssh_opts[:port] = params[:ssh_port] || 22
ipaddress = params[:node_ipaddress]
wait_for_connection(ipaddress, ssh_opts[:port])
options = { environment: 'production', puppet_master_ip: params[:puppet_master_ip] }
options = { agent_environment: params[:agent_environment], puppet_master_ip: params[:puppet_master_ip] }
tmp_dir = File.join('/', 'tmp', random_string('puppet-tmp-location-', 10))
create_tmpdir_cmd = "bash -c 'umask 077; mkdir #{tmp_dir}'"
ssh_remote_execute(ipaddress, login, ssh_opts, create_tmpdir_cmd)

Просмотреть файл

@ -63,7 +63,7 @@ function configure_puppet() {
report = true
runinterval = 120
server = puppet
environment = <%= options[:environment] %>
environment = <%= options[:agent_environment] %>
EOFPUPPETCONF

Просмотреть файл

@ -16,8 +16,8 @@ Puppet::Face.define :azure_vm, '1.0.0' do
examples <<-'EOT'
$ puppet azure_vm bootstrap --node-ip-address=domain.cloudapp.net \
--vm-user username --puppet-master-ip 152.56.161.48 --password Abcd123
--vm-user username --puppet-master-ip 152.56.161.48 --password Abcd123 \
--agent-environment development
EOT
end
end

Просмотреть файл

@ -31,6 +31,7 @@ module Puppet
add_puppet_master_ip_option(action, false)
add_private_key_file_option(action)
add_bootstrap_winrm_transport_option(action)
add_agent_environment_options(action)
end
def add_create_options(action)
@ -336,10 +337,17 @@ module Puppet
unless ['http', 'https', nil].include?(winrm_transport)
fail ArgumentError, 'The winrm transport is not valid. Valid choices are http or https'
end
end
end
end
def add_agent_environment_options(action)
action.option '--agent-environment=' do
summary 'Pupppet agent environment. default is production'
description 'Pupppet agent environment. default is production'
end
end
end
end
end

Просмотреть файл

@ -106,6 +106,18 @@ describe Puppet::Face[:azure_vm, :current] do
end
end
describe '(agent_environment)' do
it 'should validate the agent_environment' do
@options.delete(:agent_environment)
expect { subject.bootstrap(@options) }.to_not raise_error
end
it 'should validate the agent_environment' do
@options[:agent_environment] = 'development'
expect { subject.bootstrap(@options) }.to_not raise_error
end
end
describe '(private_key_file)' do
it 'should be optional' do
@options.delete(:private_key_file)