Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

falha na conexão SSH

Fala galera, tudo bem?

Estou tendo dificuldade em identificar a falha, preciso de ajuda.

Resultado:

$ vagrant halt phpweb && vagrant up phpweb ==> phpweb: Attempting graceful shutdown of VM... Bringing machine 'phpweb' up with 'virtualbox' provider... ==> phpweb: Checking if box 'hashicorp/bionic64' version '1.0.282' is up to date... ==> phpweb: Clearing any previously set forwarded ports... ==> phpweb: Clearing any previously set network interfaces... ==> phpweb: Preparing network interfaces based on configuration... phpweb: Adapter 1: nat phpweb: Adapter 2: bridged ==> phpweb: Forwarding ports... phpweb: 8888 (guest) => 8080 (host) (adapter 1) phpweb: 22 (guest) => 2222 (host) (adapter 1) ==> phpweb: Booting VM... ==> phpweb: Waiting for machine to boot. This may take a few minutes... phpweb: SSH address: 127.0.0.1:2222 phpweb: SSH username: vagrant phpweb: SSH auth method: private key <------ phpweb: Warning: Connection reset. Retrying... <------- phpweb: Warning: Connection aborted. Retrying... <-------- ==> phpweb: Machine booted and ready! ==> phpweb: Checking for guest additions in VM... ==> phpweb: Configuring and enabling network interfaces... ==> phpweb: Mounting shared folders... phpweb: /vagrant => K:/Alura/Vagrant/ambiente_dev/bionic phpweb: /tmp/vagrant-puppet/manifests-750a2947f3828cd8cdf8e8e223a2e9fb => K:/Alura/Vagrant/ambiente_dev/bionic/configs/manifests ==> phpweb: Machine already provisioned. Run vagrant provision or use the --provision ==> phpweb: flag to force provisioning. Provisioners marked to run always will still run.

meu código Vagrantfile:

$script_mysql = <<-SCRIPT echo I am provisioning apt-get update && apt-get install -y mysql-server-5.7 && mysql -e "create user 'phpuser'@'%' identified by 'pass';" SCRIPT

Vagrant.configure("2") do |config|

###################### BOX ################################

config.vm.box = "hashicorp/bionic64"

###################### MYSQL ##############################

config.vm.define "mysqldb" do |mysql|

#mysql.vm.network "forwarded_port", guest: 80, host: 8080
mysql.vm.network "public_network", ip: "192.168.0.45"

###################### PROVISIONAMENTOS ###################

mysql.vm.provision "shell", inline: "cat /configs/id_bionic.pub >> .ssh/authorized_keys"
mysql.vm.provision "shell", inline: $script_mysql
mysql.vm.provision "shell", inline: "cat /configs/mysqld.cnf > /etc/mysql/mysql.conf.d/mysqld.cnf"
mysql.vm.provision "shell", inline: "service mysql restart"

####################### PASTAS SINCRONIZADAS ###############

mysql.vm.synced_folder "./configs", "/configs"
mysql.vm.synced_folder ".", "/vagrant/", disabled: true

end

######################## WEB ###############################

config.vm.define "phpweb" do |phpweb|

phpweb.vm.network "forwarded_port", guest: 8888, host: 8080
phpweb.vm.network "public_network", ip: "192.168.0.47"

phpweb.vm.provision "shell", inline: "apt-get update && apt-get install -y puppet"

config.vm.provision "puppet" do |puppet|
    puppet.manifests_path = "./configs/manifests/"
    puppet.manifest_file = "phpweb.pp"
end

end end

meu código puppet:

exec { 'apt-update': command => '/usr/bin/apt-get update' }

################ INSTALAÇÃO DO APACHE 2 ###################

package { ['php7.2', 'php7.2-mysql']:

####### REQUISITOS 'APT-UPDATE' ANTES DA INSTALAÇÃO #######

require => Exec['apt-update'],
ensure => installed,

}

exec { 'run-php7':

require => Package['php7.2'],
command => '/usr/bin/php -S 0.0.0.0:8888 -t /vagrant/src &'

}

1 resposta
solução!

Opa!

Quando as máquinas já estão up e você precisa reconfigurar, a dica é destruir e construir novamente. Se vc já tinha rodado ele antes, teste o provision. Ele vai executar só as configurações novamente.

Ali diz que você já tinha rodado uma máquina antes.

phpweb: Machine already provisioned. Run vagrant provision or use the --provision ==> phpweb: flag to force provisioning. Provisioners marked to run always will still run.

Essa é a recomendação. Só rodar o provision pra executar a configuração. E depois verifica se aplicou.