title: How to get an arbitrary remote user's home directory in Ansible?
body: <p>I can do that with shell using combination of <code>getent</code> and <code>awk</code> like this:</p>
  
  <pre><code>getent passwd $user | awk -F: '{ print $6 }'
  </code></pre>
  
  <p>For the reference, in Puppet I can use a custom fact, like this:</p>
  
  <pre><code>require 'etc'
  
  Etc.passwd { |user|
  
     Facter.add("home_#{user.name}") do
        setcode do
           user.dir
        end
     end
  
  }
  </code></pre>
  
  <p>which makes the user's home directory available as a <code>home_&lt;user name&gt;</code> fact.</p>
  
  <p>How do I get the home directory of an <strong>arbitrary</strong> remote user?</p>