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

machine_action_provision hook and Vagrant::Action::Builtin::Provision action after Triggers run before provisioning #13468

Open
hdub-tech opened this issue Jun 27, 2024 · 0 comments

Comments

@hdub-tech
Copy link

TLDR: machine_action_provision after hook and Vagrant::Action::Builtin::Provision after action triggers run before provisioning (but provisioner_run hook works as intended).

Note: I apologize if this is actually two issues... I did some code diving and I think it might be the same issue. I suspect a missing lock or the provisioning process being spawned incorrectly. I'd be more than interested in helping get the PR up for it, but I need someone who is familiar with the code base to confirm the issue and the location.


Debug output


Expected behavior

vagrant up should execute triggers/provisioning in the following order:

  1. Before action trigger for Vagrant::Action::Builtin::Provision
  2. Provisioners
  3. After action trigger for Vagrant::Action::Builtin::Provision

vagrant provision should execute triggers/provisioning in the following order:

  1. Before hook trigger for machine_actiton_provision
  2. Before action trigger for Vagrant::Action::Builtin::Provision
  3. Provisioners
  4. After action trigger for Vagrant::Action::Builtin::Provision
  5. After hook trigger for machine_actiton_provision

Actual behavior

vagrant up executes before AND after triggers before provisioning:

  1. Before action trigger for Vagrant::Action::Builtin::Provision
  2. After action trigger for Vagrant::Action::Builtin::Provision
  3. Provisioners

vagrant provision executes before AND after triggers before provisioning:

  1. Before hook trigger for machine_actiton_provision
  2. Before action trigger for Vagrant::Action::Builtin::Provision
  3. After action trigger for Vagrant::Action::Builtin::Provision
  4. After hook trigger for machine_actiton_provision
  5. Provisioners

Reproduction information

Vagrant version

$ vagrant version
Installed Version: 2.4.1
Latest Version: 2.4.1
 
You're running an up-to-date version of Vagrant!

Host operating system

EndeavourOS (rolling, up to date)


Guest operating system

debian/bookworm64


Steps to reproduce

  1. Copy/paste the below Vagrantfile locally
  2. Execute vagrant up (Replicates: After Vagrant::Action::Builtin::Provision action trigger issue)
  3. Execute vagrant provision (Replicates: After machine_action_provision hook and Vagrant::Action::Builtin::Provision action trigger issue)

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "debian/bookworm64"
  config.vm.synced_folder ".", "/vagrant", disabled: true
  
  # Provisioners:
  config.vm.provision "PROVISIONER 1", type: :shell, inline: "echo EXECUTING PROVISIONER 1"
  config.vm.provision "PROVISIONER 2", type: :shell, inline: "echo EXECUTING PROVISIONER 2"

  # Triggers:

  # WORKS AS EXPECTED (Executes immediately after the COMMAND provision starts, but before
  # performing any provisioning actions)
  config.trigger.before :machine_action_provision, type: :hook,
    name: "HOOK TRIGGER BEFORE machine_action_provision",
    info: "INSIDE BEFORE machine_action_provision HOOK TRIGGER"

  # WORKS AS EXPECTED (Executes after machine_action_provision, and before "Calling IN action: Provision")
  config.trigger.before Vagrant::Action::Builtin::Provision, type: :action,
    name: "ACTION TRIGGER BEFORE Vagrant::Action::Builtin::Provision",
    info: "INSIDE BEFORE Vagrant::Action::Builtin::Provision TRIGGER"  

  # UNEXPECTED: Executes **immediately after** "Calling IN action: Provision", BEFORE any
  #             provisioning is done.
  # EXPECTED: Executes immediately before/after "Calling OUT action: Provision"
  config.trigger.after Vagrant::Action::Builtin::Provision, type: :action,
    name: "ACTION TRIGGER AFTER Vagrant::Action::Builtin::Provision",
    info: "INSIDE AFTER Vagrant::Action::Builtin::Provision TRIGGER"  

  # UNEXPECTED: Executes immediately after the Provision action trigger, which is shortly
  #             after STARTING Provisioning, but BEFORE any provisioning is done.
  # EXPECTED: executes after finishing provisioning.
  config.trigger.after :machine_action_provision, type: :hook,
    name: "HOOK TRIGGER AFTER machine_action_provision",
    info: "INSIDE AFTER machine_action_provision HOOK TRIGGER"

#  config.trigger.before :provisioner_run, type: :hook, name: "HOOK TRIGGER BEFORE provisioner_run", info: "Running before provisioner_run hook trigger"  # WORKS AS EXPECTED (Executes before each Provisioner)
 # config.trigger.after :provisioner_run, type: :hook, name: "HOOK TRIGGER AFTER provisioner_run", info: "Running after provisioner_run hook trigger"  # WORKS AS EXPECTED (Executes after each Provisioner)
end
@hdub-tech hdub-tech changed the title machine_action_provision hook and Vagrant::Action::Builtin::Provision action after Triggers run _before_ provisioning machine_action_provision hook and Vagrant::Action::Builtin::Provision action after Triggers run before provisioning Jun 27, 2024
hdub-tech added a commit to hdub-tech/vagrantfiles that referenced this issue Jun 27, 2024
hdub-tech added a commit to hdub-tech/vagrantfiles that referenced this issue Jun 27, 2024
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

1 participant