Skip to content
Permalink
Browse files

Remove groupby filter to avoid bug

This patch adjusts the package installation/removal tasks to get around
a bug. Jinja2 now returns namedtuples with the groupby filter and
Ansible is unable to convert that to a usable variable data type with
AST.

Jinja2 bug: pallets/jinja#654
Ansible bug: ansible/ansible#20098
Related-Bug: 1655397
Change-Id: I3ce764bfb643bda58c4b6ad282e71c312f41465e
  • Loading branch information...
major committed Jan 11, 2017
1 parent 4efc57f commit ea8a0f04b19c856d080bed9b5346fe9e799829ea
Showing with 9 additions and 24 deletions.
  1. +3 −8 tasks/rhel6stig/apt.yml
  2. +3 −8 tasks/rhel6stig/rpm.yml
  3. +3 −8 tasks/rhel7stig/packages.yml
@@ -104,15 +104,10 @@

- name: Add or remove packages based on STIG requirements
apt:
name: |
{%- set pkg_list = [] %}
{%- for package_dict in item[1] %}
{%- if pkg_list.extend(package_dict.packages) %}{% endif %}
{%- endfor %}
{{ pkg_list }}
state: "{{ item[0] }}"
name: "{{ stig_packages | selectattr('enabled') | selectattr('state', 'equalto', item) | sum(attribute='packages', start=[]) }}"
state: "{{ item }}"
with_items:
- "{{ stig_packages | selectattr('enabled') | groupby('state') }}"
- "{{ stig_packages | selectattr('enabled') | map(attribute='state') | unique | list }}"
tags:
- cat1
- auth
@@ -100,15 +100,10 @@

- name: Add or remove packages based on STIG requirements
yum:
name: |
{%- set pkg_list = [] %}
{%- for package_dict in item[1] %}
{%- if pkg_list.extend(package_dict.packages) %}{% endif %}
{%- endfor %}
{{ pkg_list }}
state: "{{ item[0] }}"
name: "{{ stig_packages | selectattr('enabled') | selectattr('state', 'equalto', item) | sum(attribute='packages', start=[]) }}"
state: "{{ item }}"
with_items:
- "{{ stig_packages | selectattr('enabled') | groupby('state') }}"
- "{{ stig_packages | selectattr('enabled') | map(attribute='state') | unique | list }}"
tags:
- cat1
- auth
@@ -15,15 +15,10 @@

- name: Add or remove packages based on STIG requirements
package:
name: |
{%- set pkg_list = [] %}
{%- for package_dict in item[1] %}
{%- if pkg_list.extend(package_dict.packages) %}{% endif %}
{%- endfor %}
{{ pkg_list }}
state: "{{ item[0] }}"
name: "{{ stig_packages_rhel7 | selectattr('enabled') | selectattr('state', 'equalto', item) | sum(attribute='packages', start=[]) }}"
state: "{{ item }}"
with_items:
- "{{ stig_packages_rhel7 | selectattr('enabled') | groupby('state') }}"
- "{{ stig_packages_rhel7 | selectattr('enabled') | map(attribute='state') | unique | list }}"
tags:
- cat1
- auth

0 comments on commit ea8a0f0

Please sign in to comment.
You can’t perform that action at this time.