Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

DIagnosticar problemas com puppet

Tentei pesquisar essa mas não achei nada útil ou relevante... até antes da instrução da senha, tudo parecia estar funcionando perfeitamente. De repente, usar o puppet apply parece parar após o log Notice: /Stage[main]/Main/Package[mysql-server]/ensure: ensure changed 'purged' to 'present'.

A única instrução que encontrei que pareceu relevante, mas não me retornou nenhuma informação, foi adicionar "logoutput => on_failure" aos execs.

Existe alguma maneira de diagnosticar o motivo do travamento? Algum log, algum modo de debug, etc...?

O código atual do meu web.pp segue abaixo:

exec { "apt-update":
  command => "apt-get update",
  path => "/usr/bin",
  logoutput => on_failure
}

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"]
}

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"]
}

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

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

exec { "mysql-password":
    command => "mysql -uroot -e \"GRANT ALL PRIVILEGES ON * TO 'musicjungle'@'%' IDENTIFIED BY 'minha-senha';\" musicjungle",
    unless => "mysql -umusicjungle -pminha-senha musicjungle",
    path => "/usr/bin",
    require => Exec["musicjungle"],
    logoutput => on_failure
}
2 respostas

Tá, achei um site falando pra usar apply --verbose. O resultado foi:

vagrant@vagrant-ubuntu-trusty-64:~$ sudo puppet apply --verbose /vagrant/manifests/web.pp
Notice: Compiled catalog for vagrant-ubuntu-trusty-64.home in environment production in 0.37 seconds
Info: Applying configuration version '1515503294'
Notice: /Stage[main]/Main/Exec[apt-update]/returns: executed successfully
Error: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install tomcat7' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  authbind libcommons-collections3-java libcommons-dbcp-java
  libcommons-pool-java libecj-java libgeronimo-jta-1.1-spec-java
  libservlet3.0-java libtomcat7-java tomcat7-common
Suggested packages:
  libcommons-collections3-java-doc libcommons-dbcp-java-doc ecj ant
  libecj-java-gcj libgeronimo-jta-java-doc tomcat7-docs tomcat7-admin
  tomcat7-examples tomcat7-user libtcnative-1
The following NEW packages will be installed:
  authbind libcommons-collections3-java libcommons-dbcp-java
  libcommons-pool-java libecj-java libgeronimo-jta-1.1-spec-java
  libservlet3.0-java libtomcat7-java tomcat7 tomcat7-common
0 upgraded, 10 newly installed, 0 to remove and 2 not upgraded.
Need to get 6277 kB of archives.
After this operation, 8119 kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
  libservlet3.0-java libtomcat7-java tomcat7-common tomcat7
E: There are problems and -y was used without --force-yes

Error: /Stage[main]/Main/Package[tomcat7]/ensure: change from purged to present failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install tomcat7' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  authbind libcommons-collections3-java libcommons-dbcp-java
  libcommons-pool-java libecj-java libgeronimo-jta-1.1-spec-java
  libservlet3.0-java libtomcat7-java tomcat7-common
Suggested packages:
  libcommons-collections3-java-doc libcommons-dbcp-java-doc ecj ant
  libecj-java-gcj libgeronimo-jta-java-doc tomcat7-docs tomcat7-admin
  tomcat7-examples tomcat7-user libtcnative-1
The following NEW packages will be installed:
  authbind libcommons-collections3-java libcommons-dbcp-java
  libcommons-pool-java libecj-java libgeronimo-jta-1.1-spec-java
  libservlet3.0-java libtomcat7-java tomcat7 tomcat7-common
0 upgraded, 10 newly installed, 0 to remove and 2 not upgraded.
Need to get 6277 kB of archives.
After this operation, 8119 kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
  libservlet3.0-java libtomcat7-java tomcat7-common tomcat7
E: There are problems and -y was used without --force-yes

Notice: /Stage[main]/Main/File[/var/lib/tomcat7/webapps/vraptor-musicjungle.war]: Dependency Package[tomcat7] has failures: true
Warning: /Stage[main]/Main/File[/var/lib/tomcat7/webapps/vraptor-musicjungle.war]: Skipping because of failed dependencies
Notice: /Stage[main]/Main/Service[tomcat7]: Dependency Package[tomcat7] has failures: true
Warning: /Stage[main]/Main/Service[tomcat7]: Skipping because of failed dependencies
Notice: Finished catalog run in 44.08 seconds
vagrant@vagrant-ubuntu-trusty-64:~$

Pesquisando por "WARNING: The following packages cannot be authenticated!", encontrei a página https://askubuntu.com/questions/75565/why-am-i-getting-authentication-errors-for-packages-from-an-ubuntu-repository que fala sobre usar o sudo apt-key update, mas que não ajudou em nada pois executá-lo diz que as chaves não mudaram, e incluir ele no web.pp só muda o erro...

solução!

Informágica mostrando que aqui não se aplica a definição de loucura: tentar a mesma coisa pode levar a resultados diferentes.

Destruí mais uma vm, quando dei up, ele reclamou...

C:\Users\c070054\Desktop\musicjungle                                    
λ  vagrant up                                                           
Bringing machine 'web' up with 'virtualbox' provider...                 
==> web: Importing base box 'ubuntu/trusty64'...                        
==> web: Matching MAC address for NAT networking...                     
==> web: Setting the name of the VM: musicjungle_web_1515504948200_21939
==> web: Clearing any previously set forwarded ports...                 
==> 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                                   
The guest machine entered an invalid state while waiting for it         
to boot. Valid states are 'starting, running'. The machine is in the    
'unknown' state. Please verify everything is configured                 
properly and try again.                                                 

If the provider you're using has a GUI that comes with it,              
it is often helpful to open that and watch the machine, since the       
GUI often has more helpful error messages than Vagrant can retrieve.    
For example, if you're using VirtualBox, run `vagrant up` while the     
VirtualBox GUI is open.                                                 

The primary issue for this error is that the provider you're using      
is not properly configured. This is very rarely a Vagrant issue.

Mandei destroy de novo, abri a GUI do Virtualbox, dei up de novo... mandei aplicar o puppet de novo e...

vagrant@vagrant-ubuntu-trusty-64:~$ sudo puppet apply --verbose /vagrant/manifests/web.pp
Notice: Compiled catalog for vagrant-ubuntu-trusty-64.home in environment production in 0.30 seconds
Info: Applying configuration version '1515505186'
Notice: /Stage[main]/Main/Exec[apt-update]/returns: executed successfully
Notice: /Stage[main]/Main/Package[mysql-server]/ensure: ensure changed 'purged' to 'present'
Notice: /Stage[main]/Main/Package[openjdk-7-jre]/ensure: ensure changed 'purged' to 'present'
Notice: /Stage[main]/Main/Exec[musicjungle]/returns: executed successfully
Notice: /Stage[main]/Main/Exec[mysql-password]/returns: executed successfully
Notice: /Stage[main]/Main/Package[tomcat7]/ensure: ensure changed 'purged' to 'present'
Notice: /Stage[main]/Main/File[/var/lib/tomcat7/webapps/vraptor-musicjungle.war]/ensure: defined content as '{md5}0ec91ca0714f19d02f2219e08ad8a531'
Info: /Stage[main]/Main/File[/var/lib/tomcat7/webapps/vraptor-musicjungle.war]: Scheduling refresh of Service[tomcat7]
Notice: /Stage[main]/Main/Service[tomcat7]: Triggered 'refresh' from 1 events
Info: Creating state file /var/lib/puppet/state/state.yaml
Notice: Finished catalog run in 369.18 seconds
vagrant@vagrant-ubuntu-trusty-64:~$

Alguma ideia do porque raios não completava antes? O.o