Skip to content

Instantly share code, notes, and snippets.

@polster
Created April 24, 2015 05:20
Show Gist options
  • Save polster/d0e00c02843e3ce7a840 to your computer and use it in GitHub Desktop.
Save polster/d0e00c02843e3ce7a840 to your computer and use it in GitHub Desktop.
How to set Ansible fact over condition
- name: "Retrieve user's home path if not set"
sudo: yes
sudo_user: "{{ user }}"
shell: "echo $HOME"
register: _user_homedir
when: user_home == ""
- name: Set home path to be used for configuration
set_fact:
user_homedir: "{{ _user_homedir.stdout if user_home == '' else user_home }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment