简体   繁体   中英

Connection plugin 'packer' was not found

I am trying to provision an Azure image with Packer and Ansible.

(The same thing with AWS works perfectly)

The Packer .json file has defined Ansible provisioner:

{
      "type": "ansible",
      "playbook_file": "./gitlab/ansible/install-gitlab.yml",
      "extra_arguments": [
        "-vvvv"
      ]
}

I get this output:

    azure-arm: ansible-playbook 2.10.0.dev0
    azure-arm:   config file = None
    azure-arm:   configured module search path = [u'/Users/kdemiris/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
    azure-arm:   ansible python module location = /Library/Python/2.7/site-packages/ansible-2.10.0.dev0-py2.7.egg/ansible
    azure-arm:   executable location = /usr/local/bin/ansible-playbook
    azure-arm:   python version = 2.7.16 (default, Nov  9 2019, 05:55:08) [GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.32.4) (-macos10.15-objc-s
    azure-arm: No config file found; using defaults
    azure-arm: setting up inventory plugins
    azure-arm: host_list declined parsing /var/folders/1n/by1psykj793gpv8z6jxw2_n06ngr6v/T/packer-provisioner-ansible245962129 as it did not pass its verify_file() method
    azure-arm: script declined parsing /var/folders/1n/by1psykj793gpv8z6jxw2_n06ngr6v/T/packer-provisioner-ansible245962129 as it did not pass its verify_file() method
    azure-arm: auto declined parsing /var/folders/1n/by1psykj793gpv8z6jxw2_n06ngr6v/T/packer-provisioner-ansible245962129 as it did not pass its verify_file() method
    azure-arm: Parsed /var/folders/1n/by1psykj793gpv8z6jxw2_n06ngr6v/T/packer-provisioner-ansible245962129 inventory source with ini plugin
    azure-arm: Loading callback plugin default of type stdout, v2.0 from /Library/Python/2.7/site-packages/ansible-2.10.0.dev0-py2.7.egg/ansible/plugins/callback/default.pyc
    azure-arm:
    azure-arm: PLAYBOOK: install-gitlab.yml ***************************************************
    azure-arm: Positional arguments: /Users/kdemiris/Documents/Projects/packer/gitlab/ansible/install-gitlab.yml
    azure-arm: become_method: sudo
    azure-arm: inventory: (u'/var/folders/1n/by1psykj793gpv8z6jxw2_n06ngr6v/T/packer-provisioner-ansible245962129',)
    azure-arm: forks: 5
    azure-arm: tags: (u'all',)
    azure-arm: extra_vars: (u'packer_build_name=azure-arm packer_builder_type=azure-arm -o IdentitiesOnly=yes', u'ansible_ssh_private_key_file=/var/folders/1n/by1psykj793gpv8z6jxw2_n06ngr6v/T/ansible-key049101946')
    azure-arm: verbosity: 4
    azure-arm: connection: packer
    azure-arm: timeout: 10
    azure-arm: 2 plays in /Users/kdemiris/Documents/Projects/packer/gitlab/ansible/install-gitlab.yml
    azure-arm:
    azure-arm: PLAY [all] *********************************************************************
    azure-arm:
    azure-arm: TASK [Gathering Facts] *********************************************************
    azure-arm: task path: /Users/kdemiris/Documents/Projects/packer/gitlab/ansible/install-gitlab.yml:2
    azure-arm: fatal: [default]: FAILED! => {
    azure-arm:     "msg": "the connection plugin 'packer' was not found"
    azure-arm: }
    azure-arm:
    azure-arm: PLAY RECAP *********************************************************************
    azure-arm: default                    : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
    azure-arm:
==> azure-arm: Provisioning step had errors: Running the cleanup provisioner, if present...

Has anyone encountered something like this?

Add a directory adjacent to your playbook named connection_plugins. Add the following packer.py file to that directory.

https://raw.githubusercontent.com/hashicorp/packer/master/examples/ansible/connection-plugin/2.6.x/packer.py

Details can be found here: https://packer.io/docs/provisioners/ansible.html#winrm-communicator

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM