Thanks for the sleuthing. It seems like using a "is-defined" check as a conditional is pointless if we have to send everything through default anyway. I understand the change for loops (since it checks each item now), but this behavior seems really counter-intuitive for blocks. What's even the point of grouping it into a block if I have to set those default filters on each task? It's just going back to being 4 separate tasks.
On Tuesday, August 30, 2016 at 1:27:45 PM UTC-7, [email protected] wrote: > > Hey all, > > Just trying to figure out how to fix the deprecation warnings (recently > updated to 2.1.1.0 from 1.7). I used to have the 4 individual tasks in the > block below (I left the commented out when statements from the original 1.7 > tasks). I tried refactoring a couple of times, but with the current setup, > I still get "Skipping task due to undefined Error, in the future this will > be a fatal error.: 'project_config' is undefined." on all 4 tasks when > project_config is undefined. Shouldn't the block just skip the tasks? Is > there something I'm missing about how blocks are executed? Is there a > better way to rewrite this set of tasks? > > - block: > - name: Install system dependencies for project > become: True > apt: pkg={{ item }} state=installed > with_items: " {{ project_config.apt|default([]) }}" > # when: project_config is defined and 'apt' in project_config > > - name: Install pip dependencies for project from files > pip: requirements={{ full_project_root }}/project_config/{{ item }} > virtualenv_command=virtualenv > virtualenv={{ venvdir }} > virtualenv_python={{ venv_python }} > virtualenv_site_packages=no > state=present > with_items: "{{ project_config.pip_files|default([]) }}" > # when: project_config is defined and 'pip_files' in project_config > environment: "{{ pip_internal }}" > > - name: Install npm dependencies > npm: path="{{ full_project_root }}/project_config/{{ item }}" > state=latest > production={{ npm_production }} > with_items: "{{ project_config.npm_package_json_path|default([]) }}" > # when: project_config is defined and 'npm_package_json_path' in > project_config > > - name: Run Django server setup commands > django_manage: command={{ item }} > app_path={{ django_manage_path }} > virtualenv={{ venvdir }} > settings={{ app_module }}.settings.{{ env }} > with_items: "{{ project_config.django_commands|default([]) }}" > # when: project_config is defined and 'django_commands' in > project_config > when: project_config is defined > > Thanks. > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/57898800-d65d-444a-bb56-06df4646bb88%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
