Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add expect_disconnect #93

Open
gadelkareem opened this issue Feb 21, 2022 · 3 comments
Open

Add expect_disconnect #93

gadelkareem opened this issue Feb 21, 2022 · 3 comments

Comments

@gadelkareem
Copy link

Description

Which provisioning using Ansible, I often need to reboot the VM but there is no such option as expect_disconnect

Potential configuration

provisioner "ansible-local" {
    max_retries             = 5
    playbook_dir            = "ansible"
    playbook_file           = "reboot-playbook.yml"
    timeout                 = "10m0s"
    clean_staging_directory = true
  }
@BytesGuy
Copy link

+1 to this, I am trying to set up a playbook that calls the builtin reboot module, but any time I use that it fails with ==>: dial tcp 172.16.161.128:22: connect: connection refused for example and never reconnects.

@gadelkareem Do you have a workaround?

@gadelkareem
Copy link
Author

@BytesGuy yes workaround here https://github.com/gadelkareem/ubuntu20-vagrantbox/blob/main/packer/vagrant/ubuntu.pkr.hcl#L97

  provisioner "ansible-local" {
    max_retries             = 5
    playbook_dir            = "packer/vagrant/ansible"
#    galaxy_file              = "packer/vagrant/ansible/requirements.yml"
    playbook_file            = "packer/vagrant/ansible/vagrant-playbook.yml"
    timeout                 = "10m0s"
    inventory_groups        = ["base"]
    clean_staging_directory = true
  }

  provisioner "shell" {
    expect_disconnect = true
    inline            = ["sudo reboot now"]
    pause_before      = "10s"
    timeout           = "10m0s"
  }

@BytesGuy
Copy link

@gadelkareem Ah ok so basically we will have to break out of the playbook and run the reboot via Packer directly. That's going to be a bit messy to do in the middle where I need to do it but it will have to do for now 😂

Hopefully some kind of expect disconnect feature can be added to the plugin soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants