Skip to content

Commit

Permalink
Update iteritems usage
Browse files Browse the repository at this point in the history
It no longer exists in Python 3. We can use `items()` which both have
and pipe to `list` in Jinja.
  • Loading branch information
swalkinshaw committed Dec 2, 2018
1 parent e7f7ebb commit 5b9b658
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
php_extensions_custom: "{{ php_extensions_custom }}"
sshd_packages_default: "{{ sshd_packages_default }}"
sshd_packages_custom: "{{ sshd_packages_custom }}"
package_vars_wrong_format: "[{% for k,v in package_vars.iteritems() if v | type_debug != 'dict' %}'{{ k }}',{% endfor %}]"
package_vars_wrong_format: "[{% for k,v in package_vars.items() | list if v | type_debug != 'dict' %}'{{ k }}',{% endfor %}]"
tags: [sshd, memcached, php]

- name: Verify dict format for apt package combined variables
Expand All @@ -61,7 +61,7 @@
memcached_packages: "{{ memcached_packages }}"
php_extensions: "{{ php_extensions }}"
sshd_packages: "{{ sshd_packages }}"
package_vars_wrong_format: "[{% for k,v in package_vars.iteritems() if v | type_debug != 'dict' %}'{{ k }}',{% endfor %}]"
package_vars_wrong_format: "[{% for k,v in package_vars.items() | list if v | type_debug != 'dict' %}'{{ k }}',{% endfor %}]"
tags: [sshd, memcached, php]

- name: Validate Ubuntu version
Expand Down
2 changes: 1 addition & 1 deletion roles/letsencrypt/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sites_using_letsencrypt: "[{% for name, site in wordpress_sites.iteritems() if site.ssl.enabled and site.ssl.provider | default('manual') == 'letsencrypt' %}'{{ name }}',{% endfor %}]"
sites_using_letsencrypt: "[{% for name, site in wordpress_sites.items() | list if site.ssl.enabled and site.ssl.provider | default('manual') == 'letsencrypt' %}'{{ name }}',{% endfor %}]"
site_uses_letsencrypt: ssl_enabled and item.value.ssl.provider | default('manual') == 'letsencrypt'
missing_hosts: "{{ site_hosts | difference((current_hosts.results | selectattr('item.key', 'equalto', item.key) | selectattr('stdout_lines', 'defined') | sum(attribute='stdout_lines', start=[]) | map('trim') | list | join(' ')).split(' ')) }}"
letsencrypt_cert_ids: "{ {% for item in (generate_cert_ids | default({'results':[{'skipped':True}]})).results if item is not skipped %}'{{ item.item.key }}':'{{ item.stdout }}', {% endfor %} }"
Expand Down
2 changes: 1 addition & 1 deletion roles/mariadb/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ mariadb_server_package: mariadb-server
mysql_binary_logging_disabled: true
mysql_root_user: root

sites_using_remote_db: "[{% for name, site in wordpress_sites.iteritems() if site.env is defined and site.env.db_host | default('localhost') != 'localhost' %}'{{ name }}',{% endfor %}]"
sites_using_remote_db: "[{% for name, site in wordpress_sites.items() | list if site.env is defined and site.env.db_host | default('localhost') != 'localhost' %}'{{ name }}',{% endfor %}]"

0 comments on commit 5b9b658

Please sign in to comment.