Skip to content

Instantly share code, notes, and snippets.

@danrough
Last active December 26, 2015 20:59
Show Gist options
  • Save danrough/7212365 to your computer and use it in GitHub Desktop.
Save danrough/7212365 to your computer and use it in GitHub Desktop.
Getting a file based on a variable in Ansible
---
############################################################
# The lookup on line 9 is currenlty failing.
# Can anyone recommend how I can achieve the following?
# Is there a better way to go about doing what I've set out to do here?
############################################################
- name: Add user {{ user }}
user: name={{user}}
- name: Add keys for user {{ user }}
authorized_key: user={{ user }} key="{{ lookup('file', user +'.txt') }}"
manage_dir=yes state=present unique=yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment