I have a terraform
provisioned AWS
structure. I have prepared chef for recipe execution but the problem is that instances don't have any node_name
attribute cause they are being provisioned by Terraform
using AutoScaling Group
and chef client
installed with user_data
script. Node name is generated by chef
and i need to execute some installs initially on every instance. I've tried to create base
role and update it to server with the needed actions. Update is successful but no installs are being started on the instance. Is there any way to run a command or assign a role to every newly arrived instance?
Thank you for the answers. Custom AMI is not an option so i had to research for a different approach. Turns out you can skip the chef-service-manager
part and call chef client
directly. Point is that you can assign JSON
file as a parameter to chef client
. The JSON
can contain runlist
and/ or role
that can be assigned to the new instance even if it is created by Autoscaling group
. Since i am already using user_data
i just added the JSON
creation in the script and assigned the needed role that already has a runlist
in the Chef Server
. Both answers helped me get there. Now on every new instance, via user_data
i create a JSON
with the role and finally i run chef client -f role_config.json
and after that i call the service creation chef-service-manager
. This is only a patch since the best option will be not to create it as a service but instead use scheduled task
and call the json
every time since if it is called for a second time for the same instance it will be disregarded in future executions. Also from what I've read in the Chef
documentation, scheduled task
will be a better option than using the service. Thanks for the answers!