title: How to install MongoDB with Ansible?
body: <p>I'm a beginner with Ansible and I'm now trying to install MongoDB on an Ubuntu 14.04 host. According to the <a href="https://docs.mongodb.com/master/tutorial/install-mongodb-on-ubuntu/" rel="nofollow noreferrer">MongoDB installation instructions</a> the manual process is as follows:</p>
  
  <pre><code>sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
  echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
  sudo apt-get update
  sudo apt-get install -y mongodb-org
  </code></pre>
  
  <p>I guess I can run this using the Ansible shell module, but since line 2 of the 4 lines about would constantly add new lines to the <code>mongodb-org-3.6.list</code> file I guess that is not the correct way.</p>
  
  <p>Does anybody know what the logical way of doing this with Ansible is? All tips are welcome!</p>