3
respostas

Erro ao executar "vagrant up"

Boa tarde,

Na aula "Rodando o puppet automaticamente", ao realizar todos os passos, executei "vagrant destroy" e posteriormente "vagrant up", porém, ocorreu o erro abaixo:

CeXs-MacBook-Air:Vagrant root# vagrant up
Bringing machine 'web' up with 'virtualbox' provider...
==> web: Importing base box 'precise64'...
==> web: Matching MAC address for NAT networking...
==> web: Setting the name of the VM: Vagrant_web_1482505633618_99497
==> web: Clearing any previously set network interfaces...
==> web: Preparing network interfaces based on configuration...
    web: Adapter 1: nat
    web: Adapter 2: hostonly
==> web: Forwarding ports...
    web: 22 (guest) => 2222 (host) (adapter 1)
==> web: Booting VM...
==> web: Waiting for machine to boot. This may take a few minutes...
    web: SSH address: 127.0.0.1:2222
    web: SSH username: vagrant
    web: SSH auth method: private key
    web:
    web: Vagrant insecure key detected. Vagrant will automatically replace
    web: this with a newly generated keypair for better security.
    web:
    web: Inserting generated public key within guest...
    web: Removing insecure key from the guest if it's present...
    web: Key inserted! Disconnecting and reconnecting using new SSH key...
==> web: Machine booted and ready!
==> web: Checking for guest additions in VM...
    web: The guest additions on this VM do not match the installed version of
    web: VirtualBox! In most cases this is fine, but in rare cases it can
    web: prevent things such as shared folders from working properly. If you see
    web: shared folder errors, please make sure the guest additions within the
    web: virtual machine match the version of VirtualBox you have installed on
    web: your host and reload your VM.
    web:
    web: Guest Additions Version: 4.2.0
    web: VirtualBox Version: 5.1
==> web: Configuring and enabling network interfaces...
==> web: Mounting shared folders...
    web: /vagrant => /Users/danielvincenzi/Udacity/Configuring Linux Web Servers/Vagrant
    web: /tmp/vagrant-puppet/manifests-a11d1078b1b1f2e3bdea27312f6ba513 => /Users/danielvincenzi/Udacity/Configuring Linux Web Servers/Vagrant/manifests
==> web: Running provisioner: puppet...
==> web: Running Puppet with web.pp...
==> web: stdin: is not a tty
==> web: Duplicate declaration: Exec[musicjungle] is already declared in file /tmp/vagrant-puppet/manifests-a11d1078b1b1f2e3bdea27312f6ba513/web.pp at line 29; cannot redeclare at /tmp/vagrant-puppet/manifests-a11d1078b1b1f2e3bdea27312f6ba513/web.pp:36 on node precise64.spo.virtua.com.br
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

The SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed. The output for this command should be in the log above. Please read the output to determine what went wrong.

Poderiam me ajudar, por gentileza ?

Obrigado !

3 respostas

Oi Daniel, posta aqui seu arquivo puppet por favor? só pra gente dar uma olhada?

Opa Wanderson,

Segue abaixo:

exec { "apt-update":
  command => "/usr/bin/apt-get update"
}
package { ["openjdk-7-jre", "tomcat7", "mysql-server"]:
    ensure => installed,
    require => Exec["apt-update"]
}

service { "tomcat7":
    ensure => running,
    enable => true,
    hasstatus => true,
    hasrestart => true,
    require => Package["tomcat7"]
}

service { "mysql":
    ensure => running,
    enable => true,
    hasstatus => true,
    hasrestart => true,
    require => Package["mysql-server"]
}

exec { "musicjungle":
    command => "mysqladmin -uroot create musicjungle",
    path => "/usr/bin",
    require => Service["mysql"]
}

exec { "musicjungle":
    command => "mysqladmin -uroot -e \"GRANT ALL PRIVILEGES ON * TO 'musicjungle'@'%' IDENTIFIED BY 'teste123';\" musicjungle",
    unless => "mysql -u root musicjungle",
    path => "/usr/bin",
    require => Service["mysql"]
}

file { "/var/lib/tomcat7/webapps/vraptor-musicjungle.war":
    source => "/vagrant/manifests/vraptor-musicjungle.war",
    owner => tomcat7,
    group => tomcat7,
    mode => 0644,
    require => Package["tomcat7"],
    notify => Service["tomcat7"]
}

file_line { "production":
    file => "/etc/default/tomcat7",
    line => "JAVA_OPTS=\"\$JAVA_OPTS -Dbr.com.caelum.vraptor.environment=production\"",
    require => Package["tomcat7"],
    notify => Service["tomcat7"]
}

define file_line($file, $line) {
    exec { "/bin/echo '${line}' >> '${file}'":
        unless => "/bin/grep -qFx '${line}' '${file}'"
    }
}

OI Danial, na mensagem de erro, está sendo acusado que você tem declarações repetidas e isso pelo que esta descrito no erro, não pode, experimente trocar uma delas.

O que está repetido é:

exec { "musicjungle":` ...

deixa um assim mesmo e coloca o outro como (por exemplo):

exec { "musicjungle-db":` ...

ai você dá um destroy e up de novo pra ver se funciona

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software