title: How do I create a user and set a password using ansible?
body: <p>The <a href="http://docs.ansible.com/ansible/user_module.html" rel="noreferrer">documentation</a> refers us to the github <a href="https://github.com/ansible/ansible-examples/blob/master/language_features/user_commands.yml" rel="noreferrer">example</a>, but this is a bit sparse and mysterious.</p>
  
  <p>It says this:</p>
  
  <pre><code># created with:
  # crypt.crypt('This is my Password', '$1$SomeSalt')
  password: $1$SomeSalt$UqddPX3r4kH3UL5jq5/ZI.
  </code></pre>
  
  <p>but <a href="http://docs.python.org/2/library/crypt.html" rel="noreferrer"><code>crypt.crypt</code></a> doesn't emit what the example shows.  It also uses MD5.</p>
  
  <p>I tried this:</p>
  
  <pre><code># python
  import crypt
  crypt.crypt('This is my Password', '$6$somereallyniceandbigrandomsalt$')
  &gt;&gt; '$69LxCegsnIwI'
  </code></pre>
  
  <p>but the password field of user should get something like this:</p>
  
  <pre><code>password: $6$somereallyniceandbigrandomsalt$UqddPX3r4kH3UL5jq5/ZI.
  </code></pre>
  
  <p>which includes three <em>$</em> delimiters separating the <code>6</code> (which signifies that its a SHA-512 hash), the salt, and the crypted password.</p>
  
  <p>Note that the python <a href="http://docs.python.org/2/library/crypt.html" rel="noreferrer">crypt docs</a> don't mention anything about the <em>$N</em> format.</p>
  
  <p>Questions:</p>
  
  <ol>
  <li><p>Is the salt, as supplied to <code>crypt.crypt</code>, supposed to end with a trailing <em>$</em> or is it in <em>$N$SALT</em> format?</p></li>
  <li><p>Python docs refer to DES, but how is SHA-512 or MD5 being called and where is the documention for this?</p></li>
  <li><p>Am I really supposed to take the output of <code>crypt.crypt</code> and cut off the first <em>$6</em> and make <em>$N$SALT$CRYPTED</em>? Is this what ansible needs?</p></li>
  </ol>