hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.04k stars 3.32k forks source link

Running with the ansible provisioner always fails with "unable to find inventory file" #1779

Closed codesplicer closed 9 years ago

codesplicer commented 9 years ago

I've tried all previous versions of packer from 0.5.2 onwards, both with and without specifying the inventory_file paramater in the packer template, and every single time the ansible-playbook command bails out with: ERROR: Unable to find an inventory file, specify one with -i ? Running this in the amazon-chroot builder. The template used is here.

Run with -debug flag on packer-0.7.5 the output log is below, on an ubuntu 12.04 host:

amazon-chroot output will be in this color.

==> amazon-chroot: Gathering information about this EC2 instance...
==> amazon-chroot: Pausing after run of step 'StepInstanceInfo'. Press enter to continue.
==> amazon-chroot: Inspecting the source AMI...
==> amazon-chroot: Pausing after run of step 'StepSourceAMIInfo'. Press enter to continue.
==> amazon-chroot: Checking the root device on source AMI...
==> amazon-chroot: Pausing after run of step 'StepCheckRootDevice'. Press enter to continue.
==> amazon-chroot: Pausing after run of step 'StepFlock'. Press enter to continue.
==> amazon-chroot: Pausing after run of step 'StepPrepareDevice'. Press enter to continue.
==> amazon-chroot: Creating the root volume...
==> amazon-chroot: Pausing after run of step 'StepCreateVolume'. Press enter to continue.
==> amazon-chroot: Attaching the root volume to /dev/sdg

==> amazon-chroot: Pausing after run of step 'StepAttachVolume'. Press enter to continue. ==> amazon-chroot: Pausing after run of step 'StepEarlyUnflock'. Press enter to continue.
==> amazon-chroot: Mounting the root device...
==> amazon-chroot: Pausing after run of step 'StepMountDevice'. Press enter to continue.
==> amazon-chroot: Mounting additional paths within the chroot...
    amazon-chroot: Mounting: /proc
    amazon-chroot: Mounting: /sys
    amazon-chroot: Mounting: /dev
    amazon-chroot: Mounting: /dev/pts
    amazon-chroot: Mounting: /proc/sys/fs/binfmt_misc
==> amazon-chroot: Pausing after run of step 'StepMountExtra'. Press enter to continue.
==> amazon-chroot: Copying files from host to chroot...
    amazon-chroot: /etc/resolv.conf
==> amazon-chroot: Pausing after run of step 'StepCopyFiles'. Press enter to continue.
==> amazon-chroot: Provisioning with shell script: /tmp/packer-shell747224003
    amazon-chroot: Downloading/unpacking ansible
    amazon-chroot: Running setup.py egg_info for package ansible
    amazon-chroot:
    amazon-chroot: no previously-included directories found matching 'lib/ansible/modules/core/.git'
    amazon-chroot: no previously-included directories found matching 'lib/ansible/modules/extras/.git'
    amazon-chroot: Requirement already satisfied (use --upgrade to upgrade): paramiko in /usr/local/lib/python2.7/dist-packages (from ansible)
    amazon-chroot: Downloading/unpacking jinja2 (from ansible)
    amazon-chroot: Running setup.py egg_info for package jinja2
    amazon-chroot:
    amazon-chroot: warning: no files found matching '*' under directory 'custom_fixers'
    amazon-chroot: warning: no previously-included files matching '*' found under directory 'docs/_build'
    amazon-chroot: warning: no previously-included files matching '*.pyc' found under directory 'jinja2'
    amazon-chroot: warning: no previously-included files matching '*.pyc' found under directory 'docs'
    amazon-chroot: warning: no previously-included files matching '*.pyo' found under directory 'jinja2'
    amazon-chroot: warning: no previously-included files matching '*.pyo' found under directory 'docs'
    amazon-chroot: Requirement already satisfied (use --upgrade to upgrade): PyYAML in /usr/lib/python2.7/dist-packages (from ansible)
    amazon-chroot: Requirement already satisfied (use --upgrade to upgrade): distribute in /usr/lib/python2.7/dist-packages (from ansible)
    amazon-chroot: Requirement already satisfied (use --upgrade to upgrade): pycrypto>=2.6 in /usr/local/lib/python2.7/dist-packages (from ansible)
    amazon-chroot: Requirement already satisfied (use --upgrade to upgrade): ecdsa>=0.11 in /usr/local/lib/python2.7/dist-packages (from paramiko->ansible)
    amazon-chroot: Requirement already satisfied (use --upgrade to upgrade): markupsafe in /usr/local/lib/python2.7/dist-packages (from jinja2->ansible)
    amazon-chroot: Installing collected packages: ansible, jinja2
    amazon-chroot: Running setup.py install for ansible
    amazon-chroot: changing mode of build/scripts-2.7/ansible from 644 to 755
    amazon-chroot: changing mode of build/scripts-2.7/ansible-playbook from 644 to 755
    amazon-chroot: changing mode of build/scripts-2.7/ansible-pull from 644 to 755
    amazon-chroot: changing mode of build/scripts-2.7/ansible-doc from 644 to 755
    amazon-chroot: changing mode of build/scripts-2.7/ansible-galaxy from 644 to 755
    amazon-chroot: changing mode of build/scripts-2.7/ansible-vault from 644 to 755
    amazon-chroot:
    amazon-chroot: no previously-included directories found matching 'lib/ansible/modules/core/.git'
    amazon-chroot: no previously-included directories found matching 'lib/ansible/modules/extras/.git'
    amazon-chroot: changing mode of /usr/local/bin/ansible-vault to 755
    amazon-chroot: changing mode of /usr/local/bin/ansible-galaxy to 755
    amazon-chroot: changing mode of /usr/local/bin/ansible to 755
    amazon-chroot: changing mode of /usr/local/bin/ansible-pull to 755
    amazon-chroot: changing mode of /usr/local/bin/ansible-doc to 755
    amazon-chroot: changing mode of /usr/local/bin/ansible-playbook to 755
    amazon-chroot: Running setup.py install for jinja2
    amazon-chroot:
    amazon-chroot: warning: no files found matching '*' under directory 'custom_fixers'
    amazon-chroot: warning: no previously-included files matching '*' found under directory 'docs/_build'
    amazon-chroot: warning: no previously-included files matching '*.pyc' found under directory 'jinja2'
    amazon-chroot: warning: no previously-included files matching '*.pyc' found under directory 'docs'
    amazon-chroot: warning: no previously-included files matching '*.pyo' found under directory 'jinja2'
    amazon-chroot: warning: no previously-included files matching '*.pyo' found under directory 'docs'
    amazon-chroot: Successfully installed ansible jinja2
    amazon-chroot: Cleaning up...
==> amazon-chroot: Provisioning with Ansible...
    amazon-chroot: Creating Ansible staging directory...
    amazon-chroot: Creating directory: /tmp/packer-provisioner-ansible-local
    amazon-chroot: Uploading main Playbook file...
    amazon-chroot: Uploading inventory file...
    amazon-chroot: Uploading role directories...
    amazon-chroot: Creating directory: /tmp/packer-provisioner-ansible-local/roles/MYCOMPONENT
    amazon-chroot: Executing Ansible: cd /tmp/packer-provisioner-ansible-local && ansible-playbook -vvvv /tmp/packer-provisioner-ansible-local/site.yml --extra-vars "COMPONENT_NAME=MYCOMPONENT COMPONENT_VERSION=16" -c local -i /tmp/packer-provisioner-ansible-local/packer-provisioner-ansible-local170416593
    amazon-chroot: ERROR: Unable to find an inventory file, specify one with -i ?
    amazon-chroot:
    amazon-chroot:
    amazon-chroot:
==> amazon-chroot: Pausing before cleanup of step 'StepCopyFiles'. Press enter to continue.
sethvargo commented 9 years ago

Duplicate of https://github.com/mitchellh/packer/issues/1696 :smile: