On 30. aug. 2016 21:36, ayush.ku...@similarweb.com 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?
You would think so, since the documentation says
"...tasks will be executed after appending the when condition from the
block and evaluating it in the task’s context."
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
If project_config is not defined this will work
with_items: "{{ project_config | default([]) }}"
but thees two will give a deprecation warning
with_items: "{{ project_config.apt | default([]) }}"
with_items: "{{ project_config['apt'] | default([]) }}"
To me this looks like a bug.
- 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
--
Kai Stian Olstad
--
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/864bc7be-cbe8-8358-292e-2e3ca7114147%40olstad.com.
For more options, visit https://groups.google.com/d/optout.