Does anyone know if you can run lets say 2 error handlers in the same cookbook and have both of them run, one after another? And if so how would you do that.
Handlers are entirely independent of each other and you can run as many as you want. If you are using the chef_handler cookbook, use the titular resource multiple times.
Related
I understand that the LaunchInstanceDetails method in oci.core.model has a parameter -> metadata , wherein one of the metadata key-names that can be used to provide information to Cloud-Init is -> “user_data” , which can be used to run custom scripts by Could-Init when provided in a base64-encoded format.
In my Python code to create a Windows VM,while launching the instance, I have a requirement to run 2 custom scripts:
Script to login to Windows machine via RDP – this is absolute(needs to be executed every time a new Windows VM is created without fail) – Currently , we have included this in the metadata parameter while launching the instance, as below:
instance_metadata['user_data'] = oci.util.file_content_as_launch_instance_user_data(path_init)
Bootstrap script to Install Chef during the initialization tasks - this is conditional ( this needs to run only if the user wishes to Install Chef and we internally handle it by means of a flag in the code) – Yet to be implemented as we need to identify if more than one custom script (conditional in this case) can be included.
Can someone help me understand if and how we can achieve to include multiple scripts(keeping in mind the conditional clause) in a single metadata variable or can we have multiple metadata or some other parameter in this service that could be utilised to run the Chef Installation script
I'd suggest combining these into a single script and using the conditional in a if statement to install Chef as required.
do you do how the syntax config is? I find a lot opswork 's document but still not see it concern that.
You need to modify the Nginx recipe attributes. Unicorn recipe attributes don't have what you're looking for.
{"nginx":{"proxy_read_timeout":"900", "proxy_send_timeout":"500"}}
This is entirely dependent on what cookbooks you are using which you didn't mention. Additionally 11.x is no longer supported and is likely unsafe to use.
I am learning ruby and thor.. and I am stuck here:
I have two classes in a module (both use Thor). I am able to use only one in the gem executable. When I add both like below and run it, I get Could not find command "hello".
Test::HammerOfTheGods.start(ARGV)
Test::Git.start(ARGV)
How do you intend both of the different classes to work together? Do you want all the commands from each to be available? If so, can you just use a single class? Thor isn't designed to work this way. The reason you're getting the error is because the first time you call .start, an error will be thrown if the command isn't found.
If you're worried about having a particularly long class definition, you can separate the definition of each command into separate files but using the same class.
When creating or editing a Role in the GUI I can't find a way to add a cookbook.
I have my recipes grouped in different cookbooks, but it seems when I create a role I have to add every recipe one by one. It does not make sense to me.
For instance, I have a cookbook that adds about 30 configuration files, each one with its own recipe. I would like to add that cookbook to a role, I don't know how.
It seems when I create a role I can add sub-roles and recipes, but not cookbooks. To me is like somebody asks me for my recipes for soups, and instead of giving him my book with soup recipes I start searching around for all my recipes about soup.
Any idea ?
Thanks,
Luis
That's the way chef works. You set a run list of recipes.
If you wish to do all in one pass create a recipe named all_recipesfor exemple and containing
include_recipe "you_cookbook::recipe_name1"
include_recipe "you_cookbook::recipe_name2"
include_recipe "you_cookbook::recipe_name3"
But if you intent is to manage 30 files in the same way, you may loop over them in a single recipe instead of doing one recipe per file.
Having multiple recipes in a cookbook is more to manage different cases (service or cronjob, unix system or windows system, etc).
All in all it sounds like a bad design at first. (No judgement, just a feeling with the few information you gave)
For your soup exemple, you're taking it the wrong way.
It's not that someone ask you for recipes, it's you telling a chef to cook things.
If you want him to cook everything in a cokbook, you have to tell him that's what you want, but a recipe for a particular soup may reference other 'common' recipes (like peel potatoes) etc.
I am using python-nose to run some tests. The test code is arranged into modules, where each module's fixtures install some VMs in a new configuration, and the module's tests then check the behaviour of those VMs is what is expected.
I want to install a per-module failure handler that goes off and grabs the logs from the VMs if any test in the module fails. Is there a proper way of doing that? Is there some callback you can register with python-nose which will kick off custom code when a test fails?
Thanks,
Sounds like you should write a plugin. You may be interested in defining afterTest(), handleFailure() methods on your Plugin class. Hope that helps.