Ubuntu – opsworks/chef databag where to put the json file

amazon-web-serviceschefopsworkssshUbuntu

Hello I'm reading this howto:
https://github.com/imoglobe/opsworks-cookbooks/blob/master/user/README.md
but it does not mention where to put the data bag in the cookbook with the list of users in json format..
I have done some searching and answers come up for regular chef and not in AWS opsworks chef.
can anyone push me to the right direction? im sure this is a easy answer.
Thanks

Best Answer

If you're just trying to manage login users then OpsWorks has built in support for allowing IAM users to log into instances within a stack.

On to your actual question - data bag support is limited in OpsWorks. Firstly, data bags are not supported at all prior to Chef 11.10.

In Chef 10.10 you can use data bags but data can only be entered via the custom JSON in the stack settings:

You cannot create a data bag by adding it to your cookbook repository. You must use custom JSON.

...

You create a data bag by using custom JSON to add one or more attributes to the stack configuration and deployment JSON [:opsworks][:data_bags] attribute.

This is untested, but your custom should probably look something like:

{
  "opsworks": {
    "data_bags": {
      "users": {
        {
          "id": "hsolo",
          "comment": "Han Solo",
          "home": "/opt/hoth/hsolo",
          "ssh_keys": ["123...", "456..."]
        }
      }
    }
  }
}

You could probably also set the [:opsworks][:data_bags][:users] key at compile time in your Chef recipe using a JSON file from S3 (see Reading and parsing a JSON file to use in a recipe in this blog post) although I haven't tried it.

Related Topic