Search code examples
vagrantpuppet

Vagrant - SSH responded non-zero exit status


==> payment: Notice: /Stage[main]/Nginx::Service/Service[nginx]/ensure: ensure changed 'stopped' to 'running'
==> payment: Info: /Stage[main]/Nginx::Service/Service[nginx]: Unscheduling refresh on Service[nginx]
==> payment: Info: Stage[main]: Unscheduling all events on Stage[main]
==> payment: Info: Creating state file /opt/puppetlabs/puppet/cache/state/state.yaml
==> payment: Notice: Applied catalog in 219.19 seconds
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.

I can't work out what actually fails based upon the above? Nginx is running as expected.


Solution

  • Nothing failed in your situation. When Puppet successfully applies a catalog that causes changes on a system, the exit code that is returned is 2. Vagrant interprets all ssh exit codes that are not 0 as unexpected and implied failures. Puppet returned a 2 for the exit code in this instance, and Vagrant interpreted it as a failure.

    I would suggest adding a provisioning line after the Puppet execution that does echo $? with the shell. This will give Vagrant its desired 0 return code while also allowing you to see what the actual code was and verify it was 2.

    config.vm.provision 'shell', inline: 'echo $?'
    

    Replace config with the local Ruby block variable as desired.

    https://docs.puppet.com/puppet/latest/man/agent.html#OPTIONS