Skip to content

Instantly share code, notes, and snippets.

@stevenhaddox
Last active December 29, 2015 06:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenhaddox/7628144 to your computer and use it in GitHub Desktop.
Save stevenhaddox/7628144 to your computer and use it in GitHub Desktop.
Manually force ansible to prepend sourcing a user's bash environment before executing commands
# {{root_path}}/group_vars/all.yml
---
src_bash: "source {{HOME.stdout}}/.bashrc;"
# {{root_path}}/roles/common/tasks/main.yml
---
- name: Set sysadmin user's $HOME variable
shell: chdir=~ pwd
register: HOME
ignore_errors: yes
changed_when: "HOME.rc != 0"
# include your other tasks / list them manually, I prefer to include as I'll do a lot here...
####################
# Install GNU Stow #
####################
- include: stow.yml
# {{root_path}}/roles/common/tasks/stow.yml
# Stow installation tasks
# Only took out a simple task for clarity
- shell: "{{src_bash}} stow --version"
register: stow_version
changed_when: "stow_version.rc != 0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment