title: Is it possible to use a state for ansible?
body: <p>You might not understand what I am trying to say in the question. Before stating the problem, I would give an example to understand even more.</p>
  <p>Let's take terraform for the example.</p>
  <p>Imagine we use terraform to spin up an EC2 instance in the <code>aws</code>. So, we are currently storing the state locally. Let's say we need to add a <code>tag</code> to the <code>ec2</code> instance.</p>
  <p>So what we do is, we add the this small block to achieve that.</p>
  <pre><code>tags = {
      Name = &quot;HelloWorld&quot;
    }
  </code></pre>
  <p>Nothing complex, just simple as it is. So, as we add a tag, the terraform will look for any changes in the state and as it found a tag has been added, it runs and <strong>only add the tag</strong> without recreating the whole instance. (There can be other scenarios where it needs to recreate the instance but let's leave those for now)</p>
  <p>So, as I mentioned, <code>terraform</code> doesn't recreate the instance for adding a tag. If we want to add another tag, it will add the tag without recreating the instance. Just as simple as that.
  doesn't matter how many times we run the <code>terraform apply</code> it doesn't do any changes to existing resources unless we made any in the terraform files.</p>
  <p>So, let's now come to the real question.</p>
  <p>Let's say we want to install a <code>httpd</code> using <code>ansible</code>. So I write ansible playbook. And it will use the <code>yum</code> package and install and then start and enable the service.</p>
  <p>Okay it is simple like that.</p>
  <p>Let's say we we run the same playbook for the second time, now will try to execute the same commands from scratch without checking first whether it has executed this playbook before?</p>
  <p>I have couple of experiences where I try to install some services and when I try to execute the same playbook again, it fails.</p>
  <p>Is it possible to preserve the state in <code>ansible</code> just like we do in <code>terraform</code> so it always <strong>only execute the newer changes other than executing from the start on the second run</strong>?</p>