Por que essa instância do AWS provisionada pelo Vagrant é finalizada assim que aparece?

2

Minha instância do AWS provisionada pelo Vagrant será encerrada assim que aparecer.

Aqui está meu arquivo de configuração:

  config.vm.box = "aws-dummy"
  config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"

  config.vm.synced_folder "./", "/vagrant", type: "rsync"


  config.vm.provider :aws do |aws, override|
    aws.access_key_id = "MY ID"
    aws.secret_access_key = "MY SECRET KEY GOES HERE"
    aws.keypair_name = "cb"
    aws.ami = "ami-f77fbeb3"
    aws.instance_ready_timeout = 300
    aws.instance_type = "t2.small"
    aws.tags = {
        "Name" => "VagrantUniversal",
    }

    aws.associate_public_ip = true
    aws.availability_zone = "us-west-1a"
    aws.subnet_id = "subnet-f2245XXX"

    aws.private_ip_address = "10.1.10.10"
    aws.security_groups = [ 'sg-4084dXXX' ] # 
    aws.region = "us-west-1"
    # aws.block_device_mapping = [{ 'DeviceName' => '/dev/sda1', 'Ebs.VolumeSize' => 50 }]

    override.ssh.username = "centos"
    override.ssh.private_key_path = "../keys/cb.pem"
  end

Eu tirei a parte de provisionamento para eliminar essa possibilidade. Eu também tentei comentar a pasta synced_folder

Do log:

 INFO interface: info: Machine is booted and ready for use!
 INFO interface: info: ==> default: Machine is booted and ready for use!
==> default: Machine is booted and ready for use!
 INFO warden: Calling IN action: #<Proc:0x00000100a3d5f8@/opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:94 (lambda)>
 INFO warden: Calling IN action: #<Vagrant::Action::Builtin::Call:0x000001028a1058>
 INFO runner: Preparing hooks for middleware sequence...
 INFO runner: 3 hooks defined.
 INFO runner: Running action: machine_action_up #<Vagrant::Action::Builder:0x00000100a4e290>
 INFO warden: Calling IN action: #<VagrantPlugins::AWS::Extras::Action::DNS::ProviderIsAWS:0x00000100a57368>
 INFO warden: Calling OUT action: #<VagrantPlugins::AWS::Extras::Action::DNS::ProviderIsAWS:0x00000100a57368>
 INFO runner: Preparing hooks for middleware sequence...
 INFO runner: 3 hooks defined.
 INFO runner: Running action: machine_action_up #<Vagrant::Action::Warden:0x00000100a859e8>
 INFO warden: Calling IN action: #<Proc:0x000001023ca7f0@/opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:94 (lambda)>
 INFO warden: Calling IN action: #<VagrantPlugins::AWS::Action::ConnectAWS:0x00000100a85970>
 INFO connect_aws: Connecting to AWS...
 INFO warden: Calling IN action: #<VagrantPlugins::AWS::Action::ReadSSHInfo:0x00000102968220>
 INFO warden: Calling IN action: #<VagrantPlugins::AWS::Extras::Action::DNS::ConnectAWS:0x000001029a1160>
 INFO warden: Calling IN action: #<VagrantPlugins::AWS::Extras::Action::DNS::Set:0x000001029da5f0>
ERROR warden: Error occurred: undefined method 'records' for nil:NilClass
 INFO warden: Beginning recovery process...
 INFO warden: Recovery complete.
 INFO warden: Beginning recovery process...
 INFO warden: Recovery complete.
 INFO warden: Beginning recovery process...
 INFO warden: Recovery complete.
 INFO warden: Beginning recovery process...
 INFO warden: Recovery complete.
ERROR warden: Error occurred: undefined method 'records' for nil:NilClass
 INFO warden: Beginning recovery process...
 INFO warden: Recovery complete.
ERROR warden: Error occurred: undefined method 'records' for nil:NilClass
 INFO warden: Beginning recovery process...
 INFO warden: Calling recover: #<Vagrant::Action::Builtin::Call:0x000001028a1058>
 INFO warden: Beginning recovery process...
 INFO warden: Recovery complete.
 INFO warden: Calling recover: #<Vagrant::Action::Builtin::Call:0x000001028a10a8>
 INFO warden: Beginning recovery process...
 INFO warden: Calling recover: #<VagrantPlugins::AWS::Action::RunInstance:0x00000100a17650>
 INFO machine: Calling action: read_state on provider AWS (i-41bcaa81)
 INFO runner: Preparing hooks for middleware sequence...
 INFO runner: 2 hooks defined.
 INFO runner: Running action: machine_action_read_state #<Vagrant::Action::Builder:0x00000104342c90>
 INFO warden: Calling IN action: #<Vagrant::Action::Builtin::ConfigValidate:0x000001043480a0>
 INFO warden: Calling IN action: #<VagrantPlugins::AWS::Action::ConnectAWS:0x00000104348028>
 INFO connect_aws: Connecting to AWS...
 INFO warden: Calling IN action: #<VagrantPlugins::AWS::Action::ReadState:0x000001043a9f30>
 INFO warden: Calling OUT action: #<VagrantPlugins::AWS::Action::ReadState:0x000001043a9f30>
 INFO warden: Calling OUT action: #<VagrantPlugins::AWS::Action::ConnectAWS:0x00000104348028>
 INFO warden: Calling OUT action: #<Vagrant::Action::Builtin::ConfigValidate:0x000001043480a0>
 INFO runner: Preparing hooks for middleware sequence...
 INFO runner: 3 hooks defined.
 INFO runner: Running action: machine_action_up #<Vagrant::Action::Builder:0x000001009a6068>
 INFO warden: Calling IN action: #<Vagrant::Action::Builtin::Call:0x000001009b4e60>
 INFO runner: Preparing hooks for middleware sequence...
 INFO runner: 3 hooks defined.
 INFO runner: Running action: machine_action_up #<Vagrant::Action::Builder:0x00000100a1f0a8>
 INFO warden: Calling IN action: #<Vagrant::Action::Builtin::DestroyConfirm:0x00000100a1c290>
 INFO warden: Calling OUT action: #<Vagrant::Action::Builtin::DestroyConfirm:0x00000100a1c290>
 INFO runner: Preparing hooks for middleware sequence...
 INFO runner: 3 hooks defined.
 INFO runner: Running action: machine_action_up #<Vagrant::Action::Warden:0x00000100a54dc0>
 INFO warden: Calling IN action: #<Proc:0x00000100a96d88@/opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:94 (lambda)>
 INFO warden: Calling IN action: #<Vagrant::Action::Builtin::ConfigValidate:0x00000100a54d48>
 INFO warden: Calling IN action: #<Vagrant::Action::Builtin::Call:0x00000100a54d20>
 INFO runner: Preparing hooks for middleware sequence...
 INFO runner: 3 hooks defined.
 INFO runner: Running action: machine_action_up #<Vagrant::Action::Builder:0x000001029bb920>
 INFO warden: Calling IN action: #<VagrantPlugins::AWS::Action::IsCreated:0x000001029b8180>
 INFO machine: Calling action: read_state on provider AWS (i-41bcaa81)
 INFO runner: Preparing hooks for middleware sequence...
 INFO runner: 2 hooks defined.
 INFO runner: Running action: machine_action_read_state #<Vagrant::Action::Builder:0x00000101036a40>
 INFO warden: Calling IN action: #<Vagrant::Action::Builtin::ConfigValidate:0x0000010283bd20>
 INFO warden: Calling IN action: #<VagrantPlugins::AWS::Action::ConnectAWS:0x0000010283baf0>
 INFO connect_aws: Connecting to AWS...
 INFO warden: Calling IN action: #<VagrantPlugins::AWS::Action::ReadState:0x000001022c69f8>
 INFO warden: Calling OUT action: #<VagrantPlugins::AWS::Action::ReadState:0x000001022c69f8>
 INFO warden: Calling OUT action: #<VagrantPlugins::AWS::Action::ConnectAWS:0x0000010283baf0>
 INFO warden: Calling OUT action: #<Vagrant::Action::Builtin::ConfigValidate:0x0000010283bd20>
 INFO warden: Calling OUT action: #<VagrantPlugins::AWS::Action::IsCreated:0x000001029b8180>
 INFO runner: Preparing hooks for middleware sequence...
 INFO runner: 3 hooks defined.
 INFO runner: Running action: machine_action_up #<Vagrant::Action::Warden:0x000001040a93a8>
 INFO warden: Calling IN action: #<Proc:0x0000010432b7c0@/opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:94 (lambda)>
 INFO warden: Calling IN action: #<VagrantPlugins::AWS::Action::ConnectAWS:0x000001040a9218>
 INFO connect_aws: Connecting to AWS...
 INFO warden: Calling IN action: #<VagrantPlugins::AWS::Action::ElbDeregisterInstance:0x00000104179990>
 INFO warden: Calling IN action: #<VagrantPlugins::AWS::Action::TerminateInstance:0x000001028962e8>
 INFO interface: info: Terminating the instance...
 INFO interface: info: ==> default: Terminating the instance...
==> default: Terminating the instance...
 INFO machine: New machine ID: nil
 INFO warden: Calling IN action: #<Vagrant::Action::Builtin::ProvisionerCleanup:0x000001042392b8>
 INFO warden: Calling IN action: #<Proc:0x000001042c1258@/opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:94 (lambda)>

... e aqui está a essência do log sem as informações de depuração:

==> default: Launching an instance with the following settings...
==> default:  -- Type: t2.small
==> default:  -- AMI: ami-f77fbeb3
==> default:  -- Region: us-west-1
==> default:  -- Availability Zone: us-west-1a
==> default:  -- Keypair: cb
==> default:  -- Subnet ID: subnet-f2245XXX
==> default:  -- Private IP: 10.1.10.10
==> default:  -- Security Groups: ["sg-4084dXXX"]
==> default:  -- Block Device Mapping: []
==> default:  -- Terminate On Shutdown: false
==> default:  -- Monitoring: false
==> default:  -- EBS optimized: false
==> default:  -- Assigning a public IP address in a VPC: true
==> default: Waiting for instance to become "ready"...
==> default: Waiting for SSH to become available...
==> default: Machine is booted and ready for use!
==> default: Terminating the instance...
/Users/swirsky/.vagrant.d/gems/gems/vagrant-aws-extras-0.1.0/lib/vagrant-aws-extras/action/dns.rb:61:in 'call': undefined method 'records' 
for nil:NilClass (NoMethodError)

Estou usando o Vagrant v1.7.4, vagrant-aws (0.6.0), vagrant-aws-extras (0.1.0), ruby 2.0.0p481

Se eu remover o plug-in vagrant-aws-extras , recebo esta mensagem curiosa:

mkdir -p '/vagrant'

Stdout from the command:

Stderr from the command:

sudo: sorry, you must have a tty to run sudo

The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed! mkdir -p '/vagrant'

Stdout from the command:

Stderr from the command: sudo: sorry, you must have a tty to run sudo

    
por chatterbeak 24.11.2015 / 00:05

1 resposta

0

Isso pode potencialmente ser um bug do vagrant-aws-extras plugin, pois outras pessoas também relataram esse problema, consulte: GH vagrant-aws # 442 Ou, potencialmente, é uma configuração incorreta da sua caixa de imagens.

Como não está claro qual comando você está invocando, mas se estiver invocando vagrant reload , ele está encerrando sua instância por design, já que está executando apenas um halt seguido por um up , por isso é normal. No entanto, o problema é que não está aumentando corretamente, devido ao seguinte erro:

sudo: sorry, you must have a tty to run sudo

Eu tive um problema parecido com o reload , que foi relatado no GH vagrant # 7244 .

Portanto, a solução alternativa é destruir a máquina e provisioná-la novamente. Ou, se você quiser executar o provisionamento novamente na instância em execução, basta executar vagrant provision para evitar invocar o comando shutdown.

Também é possível que o problema não seja causado pelo comando de desligamento, mas o erro acima é resultado da execução de mkdir -p '/vagrant' .

O melhor é usar a imagem que não requer tty com sudo. Caso contrário, configure sua imagem para não exigir senha, pois o Vagrant, por padrão, assume que o comando sudo não requer a digitação da senha.

Também comentando Defaults requiretty de /etc/sudoers poderia ajudar. Ou use a opção config.ssh.pty = true para obter um tty.

Veja: GH # 1482 para vagrant - Não é possível executar comandos sudo na máquina que requer tty para executar o sudo

    
por 20.04.2016 / 17:09