<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>

<p dir="auto">The <code class="notranslate">npm</code> module</p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.2.2.0
  config file = /home/drybjed/src/projects/devel/ansible.cfg
  configured module search path = ['/home/drybjed/src/projects/devel/ansible/library', '/home/drybjed/src/projects/devel/debops-playbooks/playbooks/library', '/usr/share/ansible/library']"><pre class="notranslate"><code class="notranslate">ansible 2.2.2.0
  config file = /home/drybjed/src/projects/devel/ansible.cfg
  configured module search path = ['/home/drybjed/src/projects/devel/ansible/library', '/home/drybjed/src/projects/devel/debops-playbooks/playbooks/library', '/usr/share/ansible/library']
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<p dir="auto">Default configuration</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>

<p dir="auto">Debian, Ubuntu</p>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">The invocation of the <code class="notranslate">npm</code> module always results in the <code class="notranslate">changed=True</code> status when the <code class="notranslate">production=True</code> option is enabled.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible localhost --become -m npm -a 'name=forever state=present global=True production=True'"><pre class="notranslate"><code class="notranslate">ansible localhost --become -m npm -a 'name=forever state=present global=True production=True'
</code></pre></div>

<h5 dir="auto">EXPECTED RESULTS</h5>

<p dir="auto">The requested module has been installed and hasn't been changed.</p>
<h5 dir="auto">ACTUAL RESULTS</h5>

<p dir="auto">The module reports the changed status on each invocation.</p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="localhost | SUCCESS =&gt; {
    &quot;changed&quot;: true, 
    &quot;invocation&quot;: {
        &quot;module_args&quot;: {
            &quot;executable&quot;: null, 
            &quot;global&quot;: true, 
            &quot;ignore_scripts&quot;: false, 
            &quot;name&quot;: &quot;forever&quot;, 
            &quot;path&quot;: null, 
            &quot;production&quot;: true, 
            &quot;registry&quot;: null, 
            &quot;state&quot;: &quot;present&quot;, 
            &quot;version&quot;: null
        }, 
        &quot;module_name&quot;: &quot;npm&quot;
    }
}"><pre class="notranslate"><code class="notranslate">localhost | SUCCESS =&gt; {
    "changed": true, 
    "invocation": {
        "module_args": {
            "executable": null, 
            "global": true, 
            "ignore_scripts": false, 
            "name": "forever", 
            "path": null, 
            "production": true, 
            "registry": null, 
            "state": "present", 
            "version": null
        }, 
        "module_name": "npm"
    }
}
</code></pre></div>
<p dir="auto">Similar to this issue: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="8325983" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible/issues/1616" data-hovercard-type="pull_request" data-hovercard-url="/ansible/ansible/pull/1616/hovercard" href="https://github.com/ansible/ansible/pull/1616">#1616</a></p>
<p dir="auto">When a task is skipped, it should not update the registered variable, e.g</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- hosts: all
  user: ubuntu
  sudo: True
  vars:
    var1: True
  tasks:
   - name: one
     command: /bin/echo one
     when: var1
     register: var2

   - name: two
     command: /bin/echo two
     when: not var1
     register: var2

   - name: three
     command: /bin/echo three
     when: var2.changed"><pre class="notranslate"><code class="notranslate">- hosts: all
  user: ubuntu
  sudo: True
  vars:
    var1: True
  tasks:
   - name: one
     command: /bin/echo one
     when: var1
     register: var2

   - name: two
     command: /bin/echo two
     when: not var1
     register: var2

   - name: three
     command: /bin/echo three
     when: var2.changed
</code></pre></div>
<p dir="auto">I expect task three should not be skipped.</p>
<p dir="auto">If I change task two to register other variable then task three will not be skipped -  but as it is skipped, it should not affect the running state.</p>