I want to pass some rsa public keys to ansible roles from ansible playbook, however, I find that ansible can't pass varibles when using lookup.
---
- hosts: gateway
vars:
keys:
- "{{ lookup('file', './files/rsa_pubs/sake1.pub') }}"
- "{{ lookup('file', './files/rsa_pubs/sake2.pub') }}"
tasks:
- name: Set gateway rsa public file.
import_role:
name: ssh_rsa_setting
vars:
# rsa_pub_keys:
# - "{{ lookup('file', './files/rsa_pubs/sake1.pub') }}"
# - "{{ lookup('file', './files/rsa_pubs/sake2.pub') }}"
rsa_pub_keys: keys
The commneted code failed while using varible "keys" to pass the rsa keys seems fine. I've tried to use "include_role" instead "import_role", nothing changes. I want to know why and how to properly pass the list varibles to roles.
Thanks in advance.