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

[Chef-solo] roles_path is ignored by chef-solo provisionner #3298

Closed
sogos opened this issue Mar 2, 2016 · 7 comments
Closed

[Chef-solo] roles_path is ignored by chef-solo provisionner #3298

sogos opened this issue Mar 2, 2016 · 7 comments
Labels
bug community-supported-plugin denotes requests for plugins that are supported by the community, not by HashiCorp engineers interpolation provisioner/chef remote-plugin/chef

Comments

@sogos
Copy link

sogos commented Mar 2, 2016

When i use this snippet

{
    "type": "chef-solo",
    "install_command": "curl -L https://www.chef.io/chef/install.sh | {{if .Sudo}}sudo {{end}}bash -s -- -v 12.6.0",
    "cookbook_paths": ["{{user `cookbook_paths`}}"],
    "environments_path": "{{user `environments_path`}}",
    "roles_path":  "{{user `chef_roles_path`}}",
    "data_bags_path": "{{user `data_bags_path`}}",
    "encrypted_data_bag_secret_path": "{{user `encrypted_data_bag_secret_path`}}",
    "chef_environment": "build",
    "run_list": ["role[webserver]"]
}

The solo.rb is not filled with roles_path and role directory is not uploaded to staging_directory

    virtualbox-iso: Creating directory: /tmp/packer-chef-solo
    virtualbox-iso: Creating directory: /tmp/packer-chef-solo/cookbooks-0
    virtualbox-iso: Creating directory: /tmp/packer-chef-solo/data_bags
    virtualbox-iso: Creating configuration file 'solo.rb'
    virtualbox-iso: Creating JSON attribute file
    virtualbox-iso: Executing Chef: sudo chef-solo --no-color -c /tmp/packer-chef-solo/solo.rb -j /tmp/packer-chef-solo/node.json
    virtualbox-iso: [2016-03-01T16:34:45+01:00] INFO: Forking chef instance to converge...
    virtualbox-iso: [2016-03-01T16:34:45+01:00] INFO: *** Chef 12.6.0 ***
    virtualbox-iso: [2016-03-01T16:34:45+01:00] INFO: Chef-client pid: 1312
    virtualbox-iso: [2016-03-01T16:34:47+01:00] INFO: Setting the run_list to ["role[ugo-vm]"] from CLI options
    virtualbox-iso: [2016-03-01T16:34:47+01:00] ERROR: Role webserver (included by 'top level') is in the runlist but does not exist. Skipping expand.

I use "packer_0.9.0_darwin_amd64"

Thanks

@sogos
Copy link
Author

sogos commented Mar 2, 2016

If I put a value directly in config for roles_path and not in command line variable like:

  "{{user `chef_roles_path`}}"

the directory is inspected before the run and roles are well uploaded

So the bug is : we can't provide roles_path as User var from command line

Thanks

@cbednarski
Copy link
Contributor

Thanks for clarifying the failure case here. You might be able to hack around this problem by customizing the execute_command. Another approach is to generate that part of the template using python, ruby, or sed before you run the build.

@sogos
Copy link
Author

sogos commented Mar 2, 2016

Thanks, it's a good idea for the moment

I can add that "environments_path" also don't work when User var

@SwampDragons SwampDragons added the community-supported-plugin denotes requests for plugins that are supported by the community, not by HashiCorp engineers label Dec 13, 2018
@fasmat
Copy link

fasmat commented May 6, 2019

Hi @sogos, hi @cbednarski,

I've been running into the same problem recently. I'm using packer version 1.0.4, but it also seems to fail in 1.4.0. Here is my template file:

{
    "variables": {
        "export_path": "{{env `DOCKER_IMAGE_PATH`}}",
        "chefdk_version": "{{env `CHEFDK_VERSION`}}",
        "chef_path": "{{env `CHEF_PATH`}}"
    },
    "builders": [
        {
            "name": "docker-container",
            "type": "docker",
            "image": "ubuntu:bionic",
            "export_path": "{{user `export_path`}}"
        }
    ],
    "provisioners": [
        {
            "type": "shell",
            "inline": [
                "apt-get update",
                "DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends curl sudo ca-certificates dnsutils"
            ]
        },
        {
            "type": "chef-solo",
            "install_command": "curl -L https://omnitruck.chef.io/install.sh | sudo bash -s -- -P chefdk -c stable -v {{user `chefdk_version`}}",
            "cookbook_paths": [
                "/home/vagrant/repo/tools/chef/berks-cookbooks",
                "/home/vagrant/repo/tools/chef/cookbooks"
            ],
            "roles_path": "/home/vagrant/repo/tools/chef/roles",
            "run_list": [
                "role[common]"
            ]
        }
    ]
}

The roles directory contains a file called common.json, but it seems like this file is not uploaded to the container before chef is being executed.

@nywilken
Copy link
Contributor

Hello folks, thanks for opening up this issue. Apologies that we've not had the chance to dive further into this issue. If you've managed to resolve your problem we encourage you to leave comment for others who may experience this issue in the future.

With that said, this is one of our community maintained plugins, which we have recently flagged as unmaintained. If you are interested in contributing or taking ownership of this plugin, please reach out to us at packer@hashicorp.com.

@ghost
Copy link

ghost commented Apr 20, 2021

This issue has been automatically migrated to hashicorp/packer-plugin-chef#16 because it looks like an issue with that plugin. If you believe this is not an issue with the plugin, please reply to hashicorp/packer-plugin-chef#16.

@ghost ghost closed this as completed Apr 20, 2021
@ghost
Copy link

ghost commented May 21, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators May 21, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug community-supported-plugin denotes requests for plugins that are supported by the community, not by HashiCorp engineers interpolation provisioner/chef remote-plugin/chef
Projects
None yet
Development

No branches or pull requests

5 participants