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

Duplicate of ansible_ssh_private_key_file #105

Open
iveahugeship opened this issue Jun 27, 2022 · 2 comments
Open

Duplicate of ansible_ssh_private_key_file #105

iveahugeship opened this issue Jun 27, 2022 · 2 comments

Comments

@iveahugeship
Copy link

Hello!

When I am trying to pass pregenerated ssh private key to ansible this argument is duplicated with empty temp key.

For example, my configuration:

  provisioner "ansible" {
    name = "site"

    playbook_file = "./ansible/site.yml"
    extra_arguments = [
      "-e ansible_user=ansible ansible_ssh_private_key_file='${data.sshkey.install.private_key_path}'"
    ]
    ansible_env_vars = [
      "ANSIBLE_CONFIG=./ansible/ansible.cfg"
    ]
    use_proxy = false

And the final ansible command I see:

ansible-playbook -e packer_build_name="default" -e packer_builder_type=qemu -e packer_http_addr=10.0.2.2:0 --ssh-extra-args '-o IdentitiesOnly=yes' -e ansible_user=ansible ansible_ssh_private_key_file='~/.cache/packer/ssh_private_key_ansible_rsa.pem' -e ansible_ssh_private_key_file=/tmp/ansible-key1495989513 -i /tmp/packer-provisioner-ansible1581750062 ~/Projects/dedicated-ops/autoinstall/autoinstall-images/ansible/site.yml

I meet with the same behavior if I set ssh_host_key_file instead of -e ansible_ssh_private_key_file and if I set 'use_proxy = true'.

ansible version: 2.12.7
packer version: 1.8.0
@iveahugeship
Copy link
Author

I've found the decision. To use predefined ssh key you should set ssh_private_key_file in builder configuration.

But it is so obscur. For example ssh_username and ssh_password is not used by ansible plugin. May be it should use communicator settings to connect host to?

@cello86
Copy link

cello86 commented Jun 27, 2023

@iveahugeship #42 (comment)

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

3 participants