cloud-images icon indicating copy to clipboard operation
cloud-images copied to clipboard

please use other way to implement the actions in packer hyper-v builder ansible provisioner

Open fsdrw08 opened this issue 3 years ago • 2 comments

As we know, Hyper-V is for windows only, and currently ansible is not able to run natively on windows. So please consider use other way to implement the actions in hyper-v builder ansible provisioner

thanks.

https://github.com/AlmaLinux/cloud-images/blob/addbb0226565d6b5ef450f4e5809c7aed57338fb/almalinux-8-vagrant.pkr.hcl#L147

fsdrw08 avatar Sep 02 '21 01:09 fsdrw08

Actually, it works on top of WSL if you create a few bat/powershell wrappers for ansible commands and add a few hacks to a Packer template.

Our official Azure image https://azuremarketplace.microsoft.com/en-us/marketplace/apps/almalinux.almalinux has been built on Windows using Ansible as the provisioner.

I need some time to polish my configs and write Windows-releated documentation before submitting it to this repo, will close that ticket when I'm done with it.

ezamriy avatar Sep 03 '21 11:09 ezamriy

An alternative could be:

  provisioner "shell" {
    execute_command = "echo 'vagrant' | {{ .Vars }} sudo -S -E bash '{{ .Path }}'"
    scripts         = ["scripts/ansible.sh"]
  }
  provisioner "ansible-local" {
    extra_arguments = ["--extra-vars", "ansible_python_interpreter=/usr/bin/python3"]
    galaxy_file = "./ansible/roles/requirements.yml"
    playbook_dir = "./ansible"
    playbook_file = "./ansible/packer-playbook.yml"
  }

bbaassssiiee avatar Mar 24 '23 17:03 bbaassssiiee