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?


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.


-- 
Kai Stian Olstad

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1dde557a-a67f-02e3-bc4b-bb8b9922c49c%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to