My problem is that the grep returns “No such file or directory” even though a grep locally on the system returns the key. I suspect an issue with the regex. The other issue is with the dynamic nature of the variables.
How can I extract the key from the files generated and copy them into the config file?
When using pipe and I guess also with wildcard you must use the shell module.
Register doesn't support variables in them, so here you create the literal variable "key-{{ item.name }}".
You can only register to one variable, and since you are using with_items the variable will contain a list, one for each item.
I can extract the stdout from the shell command but ultimately I’m going to want to associate the stdout of the shell command with a zone. So if I use with_items and iterate over each result all I’ve got is a number. How do I re-associate that number with it’s corresponding zone.
I don’t need to set facts - I need to set the keys in config files. I can use templates to iterate over the zones and pull the values from the results. I’ll update with my answer once I tested it.