<h5 dir="auto">ISSUE TYPE</h5>
<p dir="auto">Bug Report</p>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">azure_rm_deployment</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="2.3.1.0"><pre class="notranslate"><code class="notranslate">2.3.1.0
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto"><em>nope</em></p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">macOS Sierra</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">The <code class="notranslate">azure_rm_resourcegroup</code> module deletes the tags of the Resource Group it is deployed to.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<ol dir="auto">
<li>
<p dir="auto">Download the <a href="https://github.com/Azure/azure-quickstart-templates/tree/master/101-container-registry">example ARM templates</a> to the local ansible directory.</p>
</li>
<li>
<p dir="auto">Run the following playbook.</p>
</li>
</ol>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="- name: Create infra
  hosts: localhost
  gather_facts: False

  tasks:


    - name: Create resource group
      azure_rm_resourcegroup:
        name: foobar
        location: westeurope
        tags:
          team: myteam
          tier: mytier
      register: reg_rg

  #
  # after this task the tags *do* exist on the Resource Group
  #

    - name: Deploy Docker registry
      azure_rm_deployment:
        deployment_name: registry
        resource_group_name: '{{ reg_rg.state.name }}'
        location: '{{ reg_rg.state.location }}'
        template: &quot;{{ lookup('file', './azuredeploy.json') }}&quot;
        parameters: &quot;{{ lookup('file', './azuredeploy.parameters.json') }}&quot;
        wait_for_deployment_completion: False

  #
  # after this task they *don't*
  #"><pre class="notranslate">- <span class="pl-ent">name</span>: <span class="pl-s">Create infra</span>
  <span class="pl-ent">hosts</span>: <span class="pl-s">localhost</span>
  <span class="pl-ent">gather_facts</span>: <span class="pl-c1">False</span>

  <span class="pl-ent">tasks</span>:


    - <span class="pl-ent">name</span>: <span class="pl-s">Create resource group</span>
      <span class="pl-ent">azure_rm_resourcegroup</span>:
        <span class="pl-ent">name</span>: <span class="pl-s">foobar</span>
        <span class="pl-ent">location</span>: <span class="pl-s">westeurope</span>
        <span class="pl-ent">tags</span>:
          <span class="pl-ent">team</span>: <span class="pl-s">myteam</span>
          <span class="pl-ent">tier</span>: <span class="pl-s">mytier</span>
      <span class="pl-ent">register</span>: <span class="pl-s">reg_rg</span>

  <span class="pl-c"><span class="pl-c">#</span></span>
  <span class="pl-c"><span class="pl-c">#</span> after this task the tags *do* exist on the Resource Group</span>
  <span class="pl-c"><span class="pl-c">#</span></span>

    - <span class="pl-ent">name</span>: <span class="pl-s">Deploy Docker registry</span>
      <span class="pl-ent">azure_rm_deployment</span>:
        <span class="pl-ent">deployment_name</span>: <span class="pl-s">registry</span>
        <span class="pl-ent">resource_group_name</span>: <span class="pl-s"><span class="pl-pds">'</span>{{ reg_rg.state.name }}<span class="pl-pds">'</span></span>
        <span class="pl-ent">location</span>: <span class="pl-s"><span class="pl-pds">'</span>{{ reg_rg.state.location }}<span class="pl-pds">'</span></span>
        <span class="pl-ent">template</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ lookup('file', './azuredeploy.json') }}<span class="pl-pds">"</span></span>
        <span class="pl-ent">parameters</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ lookup('file', './azuredeploy.parameters.json') }}<span class="pl-pds">"</span></span>
        <span class="pl-ent">wait_for_deployment_completion</span>: <span class="pl-c1">False</span>

  <span class="pl-c"><span class="pl-c">#</span></span>
  <span class="pl-c"><span class="pl-c">#</span> after this task they *don't*</span>
  <span class="pl-c"><span class="pl-c">#</span></span></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">The <code class="notranslate">tags</code> already present on the Resource Group are persisted.</p>
<h5 dir="auto">ACTUAL RESULTS</h5>
<p dir="auto">All <code class="notranslate">tags</code> are deleted.</p>
<p dir="auto">The output of the <code class="notranslate">azure_rm_deployment</code> task shows:</p>
<p dir="auto"><code class="notranslate">azure_rm_resourcegroup</code> task</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    &quot;invocation&quot;: {
        &quot;module_args&quot;: {
            ... 
            &quot;tags&quot;: {
                &quot;team&quot;: &quot;myteam&quot;, 
                &quot;tier&quot;: &quot;mytier&quot;
            }"><pre class="notranslate">    <span class="pl-ent">"invocation"</span>: {
        <span class="pl-ent">"module_args"</span>: {
            <span class="pl-ii">... </span>
            <span class="pl-ent">"tags"</span>: {
                <span class="pl-ent">"team"</span>: <span class="pl-s"><span class="pl-pds">"</span>myteam<span class="pl-pds">"</span></span>, 
                <span class="pl-ent">"tier"</span>: <span class="pl-s"><span class="pl-pds">"</span>mytier<span class="pl-pds">"</span></span>
            }</pre></div>
<p dir="auto"><code class="notranslate">azure_rm_deployment</code> task</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    &quot;invocation&quot;: {
        &quot;module_args&quot;: {
            ...
            &quot;resource_group_name&quot;: &quot;foobar&quot;,  
            &quot;tags&quot;: null"><pre class="notranslate">    <span class="pl-ent">"invocation"</span>: {
        <span class="pl-ent">"module_args"</span>: {
            <span class="pl-ii">...</span>
            <span class="pl-ent">"resource_group_name"</span>: <span class="pl-s"><span class="pl-pds">"</span>foobar<span class="pl-pds">"</span></span>,  
            <span class="pl-ent">"tags"</span>: <span class="pl-c1">null</span></pre></div>
<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">package</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.3.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.13 (default, May 10 2017, 20:04:28) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]"><pre class="notranslate"><code class="notranslate">ansible 2.3.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.13 (default, May 10 2017, 20:04:28) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">No special configs in the scope of this bug.</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Ansible is ran from Fedora 25/26, managing hosts on Fedora 25/26 and Debian.</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">When I used Ansible 2.2 I used group_vars to have common software package lists which I then used with the module 'package' to install them on RPM and DEB based systems. That way I didn't have to duplicate any package lists for the modules 'dnf' and 'apt' and also didn't have to administrate separate lists.</p>
<p dir="auto">Now since 2.3 this has changed. It now checks these packages one-by-one when using these vars with the 'with_items' iteration function. I think <a href="https://github.com/ansible/ansible/commit/c005ae3cd95bca0267f57e26abcbe0b8e128c8fd">this</a> commit is responsible for this new behavior. This kind of makes the 'package' module unfit now to be used as a universal module for all supported package managers... Please revert this change and fix whatever problems the expansion of variables creates, because disabling a feature isn't a fix in my opinion (nor a feature).</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<p dir="auto">Create a group_var for a role and include e.g. the following.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible_dependencies_fedora:
  - python-dnf
  - libselinux-python
  - libsemanage-python
  - policycoreutils-python"><pre class="notranslate"><code class="notranslate">ansible_dependencies_fedora:
  - python-dnf
  - libselinux-python
  - libsemanage-python
  - policycoreutils-python
</code></pre></div>
<p dir="auto">Then use this variable in the appropriate role and expand it with the 'with_items' function within the 'package' module.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: install ansible dependencies
  package: name={{ item }} state=present
  with_items:
    - &quot;{{ ansible_dependencies_fedora }}&quot;
  when: ansible_distribution == &quot;Fedora&quot;
  tags:
    - setup_ansible
    - install_packages"><pre class="notranslate"><code class="notranslate">- name: install ansible dependencies
  package: name={{ item }} state=present
  with_items:
    - "{{ ansible_dependencies_fedora }}"
  when: ansible_distribution == "Fedora"
  tags:
    - setup_ansible
    - install_packages
</code></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">In Ansible 2.2 this worked fine and this is desirable because the advantage of using variable expansion with a universal module for package management is to use a single set of packages for multiple systems with different package dependency solvers.</p>
<h5 dir="auto">ACTUAL RESULTS</h5>
<p dir="auto">It iterates the items one-by-one instead of treating the expansion as one entire set of items. It's working fine when e.g. using the module 'dnf', but of course stating the explicit module for every package dependency solver results in duplication of this list. Which defeats the purpose of having a universal package module.</p>
<p dir="auto">I've reverted the change of commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/ansible/ansible/commit/c005ae3cd95bca0267f57e26abcbe0b8e128c8fd/hovercard" href="https://github.com/ansible/ansible/commit/c005ae3cd95bca0267f57e26abcbe0b8e128c8fd"><tt>c005ae3</tt></a> manually on my system. Now everything works again as expected, please make this work again as it did in Ansible 2.2!</p>