Ansibleのshell moduleを使用してコマンド結果のみをregisterに保存しておきたい時がある 自分の場合はログインShellがzshなのかbashなのかを調べたくてこんなタスクを書いた - name: check using shell register in file path shell: | if [ `echo $SHELL | grep -c "zsh"` -eq 1 ]; then echo ".zshrc" elif [ `echo $SHELL | grep -c "bash"` -eq 1 ]; then if [ `uname` = "Linux" ]; then echo "~/.bashrc" elif [ `uname` = "Darwin" ]; then echo "~/.bash_profile" fi fi register: shell