Search code examples
vagrantpuppettest-kitchen

Puppet, cp: cannot stat `/tmp/kitchen/hiera/*': No such file or directory


I am trying to create a puppet deployment using kitchen-puppet.

Here is what my kitchen file looks like:

---
driver:
  name: vagrant

provisioner:
  name: puppet_apply
  manifests_path: /repository/puppet_repo/manifests
  modules_path: /repository/puppet_repo/modules-mycompany
  hiera_data_path: /repository/puppet_repo/hieradata

platforms:
- name: centos-6.8
- name: centos-7.2
- name: debian-7.8
- name: ubuntu-12.04
- name: ubuntu-14.04
- name: ubuntu-16.04

suites:
  - name: default

When I attempt to use it I get the following error message:

$ bundle exec kitchen converge default-centos-68 
-----> Starting Kitchen (v1.16.0)
-----> Converging <default-centos-68>...
       Preparing files for transfer
       Preparing modules
       Nothing to do for modules
       Preparing manifests
       Preparing files
       nothing to do for files
       Preparing hiera data
       Finished Preparing files for transfer
       Installing puppet from yum on centos
       Install busser on centos
       Transferring files to <default-centos-68>
       cp: cannot stat `/tmp/kitchen/hiera/*': No such file or directory
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Converge failed on instance <default-centos-68>.  Please see .kitchen/logs/default-centos-68.log for more details
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

I have the same issue when using the guide listed on the readme for kitchen-puppet.

Whenever I attempt to run kitchen converge I continue to get the error message:

cp: cannot stat `/tmp/kitchen/hiera/*': No such file or directory

The issue could be that I am running this though bundler (version 1.14.6) and I also set my puppet version to the same one as the guide gem "puppet", "~> 4.10.4" to get around librarian-puppet issues. Here is the full output of my converge:

$ bundle exec kitchen converge
-----> Starting Kitchen (v1.16.0)
-----> Converging <default-nocm-ubuntu-1204>...
       Preparing files for transfer
       Preparing modules
       Resolving module dependencies with Librarian-Puppet 2.2.3...
       Preparing manifests
       Preparing files
       nothing to do for files
       Preparing hiera data
       Finished Preparing files for transfer
       Installing puppet, will try to determine platform os
       Install busser on nocm_ubuntu
       Transferring files to <default-nocm-ubuntu-1204>
       cp: cannot stat `/tmp/kitchen/hiera/*': No such file or directory
-----> Converging <default-centos-65>...
       Preparing files for transfer
       Preparing modules
       Resolving module dependencies with Librarian-Puppet 2.2.3...
       Preparing manifests
       Preparing files
       nothing to do for files
       Preparing hiera data
       Finished Preparing files for transfer
       Installing puppet from yum on centos
       Install busser on centos
       Transferring files to <default-centos-65>
       cp: cannot stat `/tmp/kitchen/hiera/*': No such file or directory
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 2 actions failed.
>>>>>>     Converge failed on instance <default-nocm-ubuntu-1204>.  Please see .kitchen/logs/default-nocm-ubuntu-1204.log for more details
>>>>>>     Converge failed on instance <default-centos-65>.  Please see .kitchen/logs/default-centos-65.log for more details
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

How can I debug this issue?


Solution

  • So the issue was caused by a missing hieradata file structure. This example was a big help and details a full kitchen-puppet file structure:

    https://github.com/neillturner/puppet_vagrant_repo

    In the main directory of my project I needed to create the following empty files:

    hieradata/
    ├── common.yaml
    └── roles
        └── default.yaml
    

    Then change provisioner in .kitchen.yml to specify this path:

    provisioner:
      name: puppet_apply
      manifests_path: manifests
      modules_path: modules
      hiera_data_path: hieradata
    

    Last I needed to set driver_plugin: vagrant in all my platforms.

    This is my new .kitchen.yml for the example in the guide I mentioned:

    ---
    driver:
      name: vagrant
    
    provisioner:
      name: puppet_apply
      manifests_path: manifests
      modules_path: modules
      hiera_data_path: hieradata
    
    platforms:
      - name: nocm_ubuntu-12.04
        driver_plugin: vagrant
        driver_config:
          box: nocm_ubuntu-12.04
          box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
      - name: centos-6.5
        driver_plugin: vagrant
        driver_config:
          box: nocm_centos-6.5
          box_url: http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box
    
    suites:
      - name: default
        manifest: site.pp