Issue 1:
I did notice, that ansible consumes very high amount of memory, for no serious reason.

ISSUE TYPE

Bug Report

ANSIBLE VERSION

ansible 2.2.1.0
config file = /home/muszynski/ansible/ansible2.cfg
configured module search path = ['lib/modules']

CONFIGURATION

OS / ENVIRONMENT

SUMMARY

The ansible is failing with Cannot allocate memory

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] => (item=../system_version/stg_default.yml)
ok: [prd-inner-mgmt202] => (item=../system_version/stg_default_vault.yml)

TASK [include_vars] ************************************************************
skipping: [prd-inner-mgmt202] => (item=../system_version/prd_default.yml)
skipping: [prd-inner-mgmt202] => (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! => {"failed": true, "msg": "Unexpected failure during module execution.", "stdout": ""}

I do not like this include statement run all-in-one instead of on-by-one - is there a way to change this behaviour?

The memory usage during ansible run:

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

[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 <<<<<<<<<<<<<<<<<<<<<<<<<<]

[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 }}"

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...

Issue 2:
Issue Type:

Bug Report

Ansible Version:

1.6.2

Environment:

Ubuntu 12.04 LTS (running on travis ci)

Summary:

The locale_gen module fails with msg: /etc/locale.gen and /var/lib/locales/supported.d/local are missing. Is the package “locales” installed? when that file does not exist on the system before hand even when the locales package is installed.

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?

Here's a travis build failing:

https://travis-ci.org/nickjj/ansible-locale/builds/28623557

Here's a travis build working:

https://travis-ci.org/nickjj/ansible-locale/builds/28626066

Without this snippet running before locale_gen then it fails:

https://github.com/nickjj/ansible-locale/blob/v0.1.1/tasks/main.yml#L14=L20

Steps To Reproduce:

- name: ensure the system locale is configured
locale_gen: name=en_US.UTF-8 state=present

Expected Results:

The locale to be written out to a config file and then enabled.

Actual Results:

It failed with the error posted in the summary.