On 22. okt. 2017 22:02, Ken Jenney wrote:
> I need to copy the generated key in one of the files and insert it into a
> new file (named.conf.local):
>
> - name: populate TSIG key config
> command: "grep Key {{ bind_base_zones_path
> }}/tsig/{{
item.name}}/K{{
item.name}}.*.private | awk '{print $2}'"
> register: 'key-{{
item.name }}'
> with_items: '{{bind_config_master_zones}}'
>
> 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?
Register doesn't support variables in them, so here you create the literal variable "key-{{
You can only register to one variable, and since you are using with_items the variable will contain a list, one for each item.