But the dictionary isn't empty. I populate it for hosts w/ the word "batch."
When it does run against a server w/o the word batch, "Install PHP modules"
is skipped because of the when.
- name: Install PHP modules
command: sudo rpm -Uvh {{ rpm_repository }}/aria-{{ item.key }}-{{
item.value.svn_tag }}.rpm --force
with_dict: deploy_modules_php
register: php_command_result
when: "'batch' in ansible_hostname"
ignore_errors: True
On Friday, June 26, 2015 at 12:18:16 PM UTC-4, Brian Coca wrote:
>
> when runs for EACH item from with_items, so you cannot use it to avoid
> undefined with_items, but you can do this:
>
> with_dict: deploy_modules_php|default({})
>
> which will return an empty dict, which will also skip the loops
>
> On Fri, Jun 26, 2015 at 11:49 AM, Samnang Sen <[email protected]
> <javascript:>> wrote:
> > I have a task that installs PHP and Perl modules against a group of
> servers.
> > Servers w/ the word "batch" in their hostname run both Perl and PHP
> tasks
> > (remove Perl tasks for simplicity). It seems the "Set PHP status
> success"
> > task runs against machines w/ the word "batch" in them. ANy way I can
> skip
> > it?
> >
> > - name: Install PHP modules
> > command: sudo rpm -Uvh {{ rpm_repository }}/{{ item.key }}-{{
> > item.value.svn_tag }}.rpm --force
> > with_dict: deploy_modules_php
> > register: php_command_result
> > when: "'batch' in ansible_hostname"
> > ignore_errors: True
> >
> > - name: set PHP status fail
> > when: php_command_result|failed
> > set_fact:
> > color="red"
> > msg="Unable to install PHP RPMs!"
> >
> > - name: Set PHP status success
> > when: php_command_result|success
> > set_fact:
> > color="green"
> > msg="Successfully installed PHP RPMs!"
> >
> > --
> > 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] <javascript:>.
> > To post to this group, send email to [email protected]
> <javascript:>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/7d4e229d-bfa6-408f-a796-577e381a59d3%40googlegroups.com.
>
>
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> Brian Coca
>
--
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/9998a80d-b8e7-4cdc-b6b2-3ce9d8b9b6d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.