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

Ansible provisioner do not work with ISPW and MACVM #124

Open
sfc-gh-banowak opened this issue Jan 16, 2025 · 0 comments
Open

Ansible provisioner do not work with ISPW and MACVM #124

sfc-gh-banowak opened this issue Jan 16, 2025 · 0 comments
Labels

Comments

@sfc-gh-banowak
Copy link

sfc-gh-banowak commented Jan 16, 2025

Overview of the Issue

Ansible is unable to work with parallels-macvm

Reproduction Steps

  1. Create a simple MacOS VM inside parallels and make sure that ssh auth with password works. Sonoma was used as VM version
  2. Create a packer configuration where you are using Ansible
  3. Provide for builder ssh_username and ssh_password parameters for macvm builder.
  4. Since those two were passed no ssh key is generated.
[ssh_keypair_name](https://developer.hashicorp.com/packer/docs/communicators/ssh#ssh_keypair_name) (string) - If specified, this is the key that will be used for SSH with the machine. The key must match a key pair name loaded up into the remote. By default, this is blank, and Packer will generate a temporary keypair unless [ssh_password](https://developer.hashicorp.com/packer/docs/communicators/ssh#ssh_password) is used. [ssh_private_key_file](https://developer.hashicorp.com/packer/docs/communicators/ssh#ssh_private_key_file) or [ssh_agent_auth](https://developer.hashicorp.com/packer/docs/communicators/ssh#ssh_agent_auth) must be specified when [ssh_keypair_name](https://developer.hashicorp.com/packer/docs/communicators/ssh#ssh_keypair_name) is utilized.
  1. Try to run the Ansible provisioner without proxy.
  2. Read the msg:
    parallels-macvm.macvm_automated: Not using Proxy adapter for Ansible run:
    parallels-macvm.macvm_automated:    Using ssh keys from Packer communicator...
  1. Watch as Ansible is trying to get the SSH key, which is not generated because the password is passed.
==> parallels-macvm.macvm_automated: Executing Ansible: ansible-playbook -e packer_build_name="macvm_automated" -e packer_builder_type=parallels-macvm -e packer_http_addr=0.0.0.0:0 --ssh-extra-args '-o IdentitiesOnly=yes' -vvvv -e ansible_ssh_private_key_file=/var/folders/s4/mcd4dxfn0vz_ssgbz0xnj4xw0000gn/T/ansible-key2040784890 -i /var/folders/s4/mcd4dxfn0vz_ssgbz0xnj4xw0000gn/T/packer-provisioner-ansible1035096009 /Users/banowak/Work/jenkins-macos-ami/images/aws/ansible/main.playbook.yml
  1. Since Ansible requires using SSH keys, which are not generated (empty), observe a connection denial due to an invalid key.
    Log without user passed to ansible:
Trying private key: /var/folders/s4/mcd4dxfn0vz_ssgbz0xnj4xw0000gn/T/ansible-key2040784890\r\nLoad key \"/var/folders/s4/mcd4dxfn0vz_ssgbz0xnj4xw0000gn/T/ansible-key2040784890\": invalid format\r\ndebug2: we did not send a packet, disable method\r\ndebug1: No more authentication methods to try.\r\[email protected]: Permission denied (publickey,password,keyboard-interactive).",

Log with user passed to ansible:

/var/folders/s4/mcd4dxfn0vz_ssgbz0xnj4xw0000gn/T/ansible-key1087569498\r\nLoad key \"/var/folders/s4/mcd4dxfn0vz_ssgbz0xnj4xw0000gn/T/ansible-key1087569498\": invalid format\r\ndebug2: we did not send a packet, disable method\r\ndebug1: No more authentication methods to try.\r\[email protected]: Permission denied (publickey,password,keyboard-interactive).",

Plugin and Packer version

Packer: 1.9.4
Parallels: 20.1.3
Plugin: 1.2.2

Simplified Packer Buildfile

source "parallels-macvm" "macvm_automated" {
  boot_command     = ["<wait>"]
  boot_wait        = "10s"
  shutdown_command = "sudo shutdown -h now"
  source_path      = "../jenkins_vm/output-sonoma_old/macos-sonoma.macvm"
  ssh_password     = "ec2-user"
  ssh_username     = "ec2-user"
  vm_name          = "macvm_automated_${formatdate("DDMMYYhhmm", timestamp())}"

  prlctl_post = [
    ["status", "{{.Name}}", ]
  ]
}

build {
  sources = ["source.parallels-macvm.macvm_automated"]

  provisioner "ansible" {
    user = "ec2-user"
    playbook_file   = "./../ansible/main.playbook.yml"  
    use_proxy = false # we are using ssh key
    use_sftp = false  # this will use scp instead
    extra_arguments = [ "-vvvv" ] #  "--extra-vars", "ansible_password=ec2-user" 
    ansible_env_vars = [
      "ANSIBLE_CONFIG=./../ansible/ansible.cfg"
    ]
    # ssh_authorized_key_file = "${var.user_home}/.ssh/packer_tmp.pub"
    # ansible_proxy_key_type = "ECDSA"
  }

Operating system and Environment details

Host OS: MacOS 15.2
Hardware: Mac Pro M3

Log Fragments and crash.log files

Possible workarounds

I will try not to shut down the machine and connect to it with a null provisioner.

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

No branches or pull requests

1 participant