I am trying to download keys from github and create aws key pairs. Currently I am using these tasks for that.
- name: download keys from github
get_url:
url: "https://github.com/{{ item }}.keys"
dest: "/tmp/{{ item }}"
with_items:
- foo
- bar
- name: create ec2 keys
ec2_key: name=foo key_material="{{ item }}" state=present
with_lines: cat /tmp/foo
- name: create ec2 keys
ec2_key: name=bar
with_lines: cat /tmp/bar
However, this is not DRY. How to achieve something like this?
- name: create ec2 keys
ec2_key: name=foo key_material="{{ line }}" state=present
with_lines: cat /tmp/{{item}}
with_items:
- foo
- bar