<p dir="auto">I did notice, that ansible consumes very high amount of memory, for no serious reason.</p>
<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h3 dir="auto">ANSIBLE VERSION</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.2.1.0
  config file = /home/muszynski/ansible/ansible2.cfg
  configured module search path = ['lib/modules']
"><pre class="notranslate"><code class="notranslate">ansible 2.2.1.0
  config file = /home/muszynski/ansible/ansible2.cfg
  configured module search path = ['lib/modules']

</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<h5 dir="auto">OS / ENVIRONMENT</h5>

<h5 dir="auto">SUMMARY</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="The ansible is failing with Cannot allocate memory
"><pre class="notranslate"><code class="notranslate">The ansible is failing with Cannot allocate memory

</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAY [rundeck-server] **********************************************************

TASK [setup] *******************************************************************
ok: [prd-inner-mgmt202]

TASK [include_vars] ************************************************************
 [WARNING]: While constructing a mapping from True, line 2, column 1, found a duplicate dict key (elasticsearch). Using last defined value only.

ok: [prd-inner-mgmt202] =&gt; (item=../system_version/stg_default.yml)
ok: [prd-inner-mgmt202] =&gt; (item=../system_version/stg_default_vault.yml)

TASK [include_vars] ************************************************************
skipping: [prd-inner-mgmt202] =&gt; (item=../system_version/prd_default.yml) 
skipping: [prd-inner-mgmt202] =&gt; (item=../system_version/prd_default_vault.yml) 

TASK [mid_rundeck_jobs_build : set_fact] ***************************************
ok: [prd-inner-mgmt202]

TASK [mid_rundeck_jobs_build : include] ****************************************
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202


[some other lines]

TASK [mid_rundeck_jobs_build : echo upload jobs] *******************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: OSError: [Errno 12] Cannot allocate memory
fatal: [prd-inner-mgmt202]: FAILED! =&gt; {&quot;failed&quot;: true, &quot;msg&quot;: &quot;Unexpected failure during module execution.&quot;, &quot;stdout&quot;: &quot;&quot;}

"><pre class="notranslate"><code class="notranslate">PLAY [rundeck-server] **********************************************************

TASK [setup] *******************************************************************
ok: [prd-inner-mgmt202]

TASK [include_vars] ************************************************************
 [WARNING]: While constructing a mapping from True, line 2, column 1, found a duplicate dict key (elasticsearch). Using last defined value only.

ok: [prd-inner-mgmt202] =&gt; (item=../system_version/stg_default.yml)
ok: [prd-inner-mgmt202] =&gt; (item=../system_version/stg_default_vault.yml)

TASK [include_vars] ************************************************************
skipping: [prd-inner-mgmt202] =&gt; (item=../system_version/prd_default.yml) 
skipping: [prd-inner-mgmt202] =&gt; (item=../system_version/prd_default_vault.yml) 

TASK [mid_rundeck_jobs_build : set_fact] ***************************************
ok: [prd-inner-mgmt202]

TASK [mid_rundeck_jobs_build : include] ****************************************
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202
included: /home/ansible/etc/playbooks/roles/mid_rundeck_jobs_build/tasks/render_template.yml for prd-inner-mgmt202


[some other lines]

TASK [mid_rundeck_jobs_build : echo upload jobs] *******************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: OSError: [Errno 12] Cannot allocate memory
fatal: [prd-inner-mgmt202]: FAILED! =&gt; {"failed": true, "msg": "Unexpected failure during module execution.", "stdout": ""}


</code></pre></div>
<p dir="auto"><strong>I do not like this include statement run all-in-one instead of on-by-one - is there a way to change this behaviour?</strong></p>
<p dir="auto">The memory usage during ansible run:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="dstat -fm
 used  buff  cach  free
12.4G 25.8M 1189M 1833M
12.4G 25.8M 1190M 1824M
12.5G 25.9M 1190M 1779M
12.5G 25.9M 1194M 1764M
12.5G 26.6M 1202M 1758M
12.5G 26.7M 1206M 1765M
12.5G 26.7M 1206M 1733M
12.5G 26.7M 1206M 1741M
12.5G 26.7M 1210M 1707M
12.6G 26.8M 1210M 1623M
12.5G 26.8M 1210M 1693M
12.7G 26.8M 1210M 1550M
12.8G 26.8M 1210M 1422M
12.9G 26.8M 1210M 1352M
12.9G 26.8M 1210M 1334M
13.0G 26.8M 1210M 1239M
13.0G 26.8M 1210M 1158M
13.1G 26.8M 1210M 1079M
13.1G 26.8M 1211M 1067M
13.2G 26.9M 1211M  986M
13.2G 26.9M 1211M  943M
13.3G 26.9M 1211M  879M
13.4G 26.9M 1212M  780M
13.5G 26.9M 1212M  731M
13.4G 26.9M 1211M  790M
13.6G 27.0M 1211M  627M
13.7G 27.0M 1211M  513M
13.7G 27.0M 1211M  467M
13.7G 27.0M 1211M  517M
13.8G 27.0M 1211M  397M
13.9G 27.0M 1212M  292M
14.0G 27.0M 1212M  149M
12.5G 27.9M 1131M 1834M
12.5G 27.9M 1131M 1811M
12.5G 28.0M 1131M 1791M
12.5G 28.0M 1131M 1820M
12.4G 28.0M 1131M 1850M"><pre class="notranslate"><code class="notranslate">dstat -fm
 used  buff  cach  free
12.4G 25.8M 1189M 1833M
12.4G 25.8M 1190M 1824M
12.5G 25.9M 1190M 1779M
12.5G 25.9M 1194M 1764M
12.5G 26.6M 1202M 1758M
12.5G 26.7M 1206M 1765M
12.5G 26.7M 1206M 1733M
12.5G 26.7M 1206M 1741M
12.5G 26.7M 1210M 1707M
12.6G 26.8M 1210M 1623M
12.5G 26.8M 1210M 1693M
12.7G 26.8M 1210M 1550M
12.8G 26.8M 1210M 1422M
12.9G 26.8M 1210M 1352M
12.9G 26.8M 1210M 1334M
13.0G 26.8M 1210M 1239M
13.0G 26.8M 1210M 1158M
13.1G 26.8M 1210M 1079M
13.1G 26.8M 1211M 1067M
13.2G 26.9M 1211M  986M
13.2G 26.9M 1211M  943M
13.3G 26.9M 1211M  879M
13.4G 26.9M 1212M  780M
13.5G 26.9M 1212M  731M
13.4G 26.9M 1211M  790M
13.6G 27.0M 1211M  627M
13.7G 27.0M 1211M  513M
13.7G 27.0M 1211M  467M
13.7G 27.0M 1211M  517M
13.8G 27.0M 1211M  397M
13.9G 27.0M 1212M  292M
14.0G 27.0M 1212M  149M
12.5G 27.9M 1131M 1834M
12.5G 27.9M 1131M 1811M
12.5G 28.0M 1131M 1791M
12.5G 28.0M 1131M 1820M
12.4G 28.0M 1131M 1850M
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
[rundeck_role/main.yml ]
---
- set_fact:
    project:
        rundeck_url: 'http://somehost:4440/api/11'
        token: &quot;{{ rundeck_token }}&quot;
        template: 'promo_apps'
        rd_group: &quot;{{ system_env }}&quot;
    project_name: 'PromoCloud'
  tags: ['promo_cloud', 'frontends', 'hadoop', 'backends', 'importers']

- include: promo_cloud.yml
  vars:
    tags: ['promo_cloud']


[promo_cloud.yml]
---
- include: render_template.yml
  vars:
    host_list: &quot;{{ item_instance.host_list }}&quot;
    project_template: &quot;{{ item_instance.template }}&quot;
    action: &quot;{{ item_instance.action }}&quot;
    choosen_app: &quot;{{ item_instance.app }}&quot;
    choosen_proxy_backend: &quot;{{ item_instance.backend }}&quot;
    playbook: &quot;{{ item_instance.playbook }}&quot;
      
  loop_control:
      loop_var: item_instance
  
  with_items:
      [here goes a list of 30 templates items  &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;]


[render_template.yml]
---
- debug: msg=&quot;{{ item_instance }} {{ item }}&quot;
  with_items: &quot;{{ host_list }}&quot;
    
- file:
      path: /tmp/{{ project_template }}
      state: directory
    
- set_fact:
    choosen_app_version: &quot;{{ versions[choosen_app] | default('x') }}&quot;

- name: &quot;template jobs {{ choosen_app }}&quot;
  template: 
      src: job_templates/{{ project_template }}
      dest: /tmp/{{ project_template }}/{{ project_name | default('empty') }}_{{ project.rd_group }}_{{ item }}_{{ choosen_app | default() }}_{{ action | default() }}.yml
  with_items: &quot;{{ host_list }}&quot;
      
      
- name: &quot;upload jobs&quot;
  shell: rd-jobs load -r -F yaml -f /tmp/{{ project_template }}/{{ project_name | default('empty') }}_{{ project.rd_group }}_{{ item }}_{{ choosen_app | default() }}_{{ act
on |default() }}.yml
  become: True
  changed_when: False
  with_items: &quot;{{ host_list }}&quot;
"><pre class="notranslate"><code class="notranslate">
[rundeck_role/main.yml ]
---
- set_fact:
    project:
        rundeck_url: 'http://somehost:4440/api/11'
        token: "{{ rundeck_token }}"
        template: 'promo_apps'
        rd_group: "{{ system_env }}"
    project_name: 'PromoCloud'
  tags: ['promo_cloud', 'frontends', 'hadoop', 'backends', 'importers']

- include: promo_cloud.yml
  vars:
    tags: ['promo_cloud']


[promo_cloud.yml]
---
- include: render_template.yml
  vars:
    host_list: "{{ item_instance.host_list }}"
    project_template: "{{ item_instance.template }}"
    action: "{{ item_instance.action }}"
    choosen_app: "{{ item_instance.app }}"
    choosen_proxy_backend: "{{ item_instance.backend }}"
    playbook: "{{ item_instance.playbook }}"
      
  loop_control:
      loop_var: item_instance
  
  with_items:
      [here goes a list of 30 templates items  &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;]


[render_template.yml]
---
- debug: msg="{{ item_instance }} {{ item }}"
  with_items: "{{ host_list }}"
    
- file:
      path: /tmp/{{ project_template }}
      state: directory
    
- set_fact:
    choosen_app_version: "{{ versions[choosen_app] | default('x') }}"

- name: "template jobs {{ choosen_app }}"
  template: 
      src: job_templates/{{ project_template }}
      dest: /tmp/{{ project_template }}/{{ project_name | default('empty') }}_{{ project.rd_group }}_{{ item }}_{{ choosen_app | default() }}_{{ action | default() }}.yml
  with_items: "{{ host_list }}"
      
      
- name: "upload jobs"
  shell: rd-jobs load -r -F yaml -f /tmp/{{ project_template }}/{{ project_name | default('empty') }}_{{ project.rd_group }}_{{ item }}_{{ choosen_app | default() }}_{{ act
on |default() }}.yml
  become: True
  changed_when: False
  with_items: "{{ host_list }}"

</code></pre></div>
<p dir="auto">So I know this playbook/templates usage is an extreme one, but I know the magic, so why not to use ansible at it's full power...</p>
<h5 dir="auto">Issue Type:</h5>
<p dir="auto">Bug Report</p>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">1.6.2</p>
<h5 dir="auto">Environment:</h5>
<p dir="auto">Ubuntu 12.04 LTS (running on travis ci)</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">The <code class="notranslate">locale_gen</code> module fails with <code class="notranslate">msg: /etc/locale.gen and /var/lib/locales/supported.d/local are missing. Is the package “locales” installed?</code> when that file does not exist on the system before hand even when the <code class="notranslate">locales</code> package is installed.</p>
<p dir="auto">The work around is to conditionally touch this file if it does not exist which seems a bit user unfriendly. Maybe this logic could be encapsulated in the module itself?</p>
<p dir="auto">Here's a travis build failing:<br>
<a href="https://travis-ci.org/nickjj/ansible-locale/builds/28623557" rel="nofollow">https://travis-ci.org/nickjj/ansible-locale/builds/28623557</a></p>
<p dir="auto">Here's a travis build working:<br>
<a href="https://travis-ci.org/nickjj/ansible-locale/builds/28626066" rel="nofollow">https://travis-ci.org/nickjj/ansible-locale/builds/28626066</a></p>
<p dir="auto">Without this snippet running before <code class="notranslate">locale_gen</code> then it fails:<br>
<a href="https://github.com/nickjj/ansible-locale/blob/v0.1.1/tasks/main.yml#L14=L20">https://github.com/nickjj/ansible-locale/blob/v0.1.1/tasks/main.yml#L14=L20</a></p>
<h5 dir="auto">Steps To Reproduce:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: ensure the system locale is configured
  locale_gen: name=en_US.UTF-8 state=present"><pre class="notranslate"><code class="notranslate">- name: ensure the system locale is configured
  locale_gen: name=en_US.UTF-8 state=present
</code></pre></div>
<h5 dir="auto">Expected Results:</h5>
<p dir="auto">The locale to be written out to a config file and then enabled.</p>
<h5 dir="auto">Actual Results:</h5>
<p dir="auto">It failed with the error posted in the summary.</p>