Code Monkey home page Code Monkey logo

Comments (2)

itoffshore avatar itoffshore commented on June 22, 2024 1

I think the ssh option -o IdentitiesOnly=yes should be removed from extraArgs in the ansible-local provisioner

(perhaps this invalid option is causing ansible to ignore the additional extraArgs)

I've tried removing it from the src & go clean && go build - & removing the existing plugin & placing the new plugin in:

~/$PACKER_CONIG_DIR/.packer.d/plugins/github.com/hashicorp/ansible

but I still see it showing up in the ansible command:

lxd.build-local: Executing Ansible: cd /tmp/packer-provisioner-ansible-local/62463d8a-fb15-88fd-755c-fa094aeaaa9e && ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 ansible-playbook /tmp/packer-provisioner-ansible-local/62463d8a-fb15-88fd-755c-fa094aeaaa9e/playbooktest.yml --extra-vars "packer_build_name=build-local packer_builder_type=lxd packer_http_addr=ERR_HTTP_ADDR_NOT_IMPLEMENTED_BY_BUILDER -o IdentitiesOnly=yes" --extra-vars "build_template=alpine-lxd" -c local -i /tmp/packer-provisioner-ansible-local/62463d8a-fb15-88fd-755c-fa094aeaaa9e/inventory.yml 

I can make a PR for this change but wanted to test the change properly first - am I missing a step ?


(NB for others: the ansible provisioner works perfectly with the ansible lxd connection plugin community.general.lxd)

from packer-plugin-ansible.

eliasp avatar eliasp commented on June 22, 2024

When it comes to the -o IdentitiesOnly=yes issue, I believe the issue is caused by the fact, that what should be actually a value of --ssh-extra-args has been crammed into the value of --extra-vars.

So the initial fix (untested) might look a little more like this (although I believe the whole extraArgs handling should be a refactored a little for better readability/maintainability):

diff --git a/provisioner/ansible-local/provisioner.go b/provisioner/ansible-local/provisioner.go
index 9619733..c6ece7d 100644
--- a/provisioner/ansible-local/provisioner.go
+++ b/provisioner/ansible-local/provisioner.go
@@ -549,7 +549,7 @@ func (p *Provisioner) invokeGalaxyCommand(args []string, ui packersdk.Ui, comm p
 func (p *Provisioner) executeAnsible(ui packersdk.Ui, comm packersdk.Communicator) error {
        inventory := filepath.ToSlash(filepath.Join(p.config.StagingDir, filepath.Base(p.config.InventoryFile)))

-       extraArgs := fmt.Sprintf(" --extra-vars \"packer_build_name=%s packer_builder_type=%s packer_http_addr=%s -o IdentitiesOnly=yes\" ",
+       extraArgs := fmt.Sprintf(" --extra-vars \"packer_build_name=%s packer_builder_type=%s packer_http_addr=%s\" --ssh-extra-args \"-o IdentitiesOnly=yes\" ",
                p.config.PackerBuildName, p.config.PackerBuilderType, p.generatedData["PackerHTTPAddr"])
        if len(p.config.ExtraArguments) > 0 {
                extraArgs = extraArgs + strings.Join(p.config.ExtraArguments, " ")

from packer-plugin-ansible.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.