packer-plugin-ansible icon indicating copy to clipboard operation
packer-plugin-ansible copied to clipboard

How use_proxy argument works?

Open iveahugeship opened this issue 2 years ago • 0 comments

Hello! I use ansible provisioner with use_proxy setted to false and pass user, key or password through the extra-args. I try to learn how use_proxy argument works but can't :c

I have double stage configuration and I want to run some ansible roles on the second one, but it fails if I trying to use proxy:

build {
  name = "stage2"

  dynamic "source" {
    for_each = merge(...)
    labels = ["qemu.default"]

    content {
      name                  = source.key
      vm_name           = "${source.key}-cloud.raw"
      output_directory = "${var.outputs_prefix}/stage2"

      disk_image = true
      format         = "raw"

      iso_url      = "${var.outputs_prefix}/stage1/${source.key}-stage1.raw"
      iso_checksum = "none"

      boot_wait = "1m"

      communicator = "ssh"
      ssh_username = "root"
      ssh_password = "root"
    }
  }

  provisioner "ansible" {
    name = "test"

    playbook_file        = "./ansible/prep.yml"
    user                      = "root"
    ansible_env_vars = [
      "ANSIBLE_HOST_KEY_CHECKING=false"
    ]
  }
}

From the documentation I found out that ansible provisioner starts ssh server on another port and then ansible tries to connect to and to execute commands. But how the proxy server auth works here?

Okay, we can set ssh_host_key_file and ssh_authorized_key_file. And I've set it and got error:

Failed to connect to the host via ssh:
Warning: Permanently added '[127.0.0.1]:34739' (ED25519) to the list of known hosts.
[email protected]: Permission denied (publickey).

So I've lost. Can anyone explain me how it works?

iveahugeship avatar Jun 26 '22 16:06 iveahugeship