Meta module

102 views
Skip to first unread message

brice Folio

unread,
Jul 4, 2022, 3:57:20 PM7/4/22
to Ansible Project
Hello, 

I have playbook played in tower and at the end of a block I use meta: end_play module without any condition.
I don't know why but this task is ignored and when I enable debug it displays:
META: 
Instead of:
META: END PLAY

What can be the reason for tower or ansible to ignore meta?

Best Regards,
Folio Brice Roland

Brian Coca

unread,
Jul 5, 2022, 9:34:20 AM7/5/22
to Ansible Project
-vvv output of that task would be helpful in finding out



--
----------
Brian Coca

brice Folio

unread,
Jul 5, 2022, 9:48:58 AM7/5/22
to ansible...@googlegroups.com
Hi,

I tried it, without success.
No information in output, except for the task just before it.

Best Regards,
Folio Brice Roland
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/p8C1smdSmG8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CACVha7e7q9S-u7w_08fVw3RCJZjySsR9BD7ND6MnA3ju-D75vQ%40mail.gmail.com.

Dick Visser

unread,
Jul 5, 2022, 11:17:50 AM7/5/22
to ansible...@googlegroups.com


On 2022-07-04 (Mon) 21:57, brice Folio wrote:
> Hello,
>
> I have playbook played in tower and at the end of a block I use meta:
> end_play module without any condition.
> I don't know why but this task is ignored and when I enable debug it
> displays:
> META:
> Instead of:
> META: END PLAY

That is all capitals, and it's not an item in a list.
Can you post the actual YAML instead of some mangled human interpretation?

Dick
OpenPGP_0x266713D4E6EF488D.asc
OpenPGP_signature

Brian Coca

unread,
Jul 5, 2022, 2:01:29 PM7/5/22
to Ansible Project
so it is working, the play is ending, it is not being skipped


--
----------
Brian Coca

brice Folio

unread,
Jul 6, 2022, 5:43:09 AM7/6/22
to Ansible Project
Hi,

Here the issuing part of code:
- name: "Check aggregated interface configuration and save the differences"
    ansible.builtin.set_fact: 
       aggregated_interface_configuration_difference: "{{ lines | difference(r_aggregated_interface_configuration.stdout_lines | first) }}" 
    vars: 
      lines:
       - inherit port-profile RLB-CLIENT-TRUNK-PO-MEMBER-10G 
       - " description PZB-{{ server_serial_number }}-{{ pizza_box_name }}" 
       - " channel-group {{ port_channel_id }}" 
       - " no snmp trap link-status" 
 - name: "Check difference between the configuration of interfaces and targets configurations" 
      ansible.builtin.assert: 
      that: 
       - (po_configuration_difference | length) == 0 
       - (aggregated_interface_configuration_difference | length) == 0 
      fail_msg: "Port-channel for {{ server_serial_number }}-{{ pizza_box_name }} duo already exists with wrong configuration, cannot create new configuration" 
 - name: "Close session if port-channel and interfaces configurations are correct" 
   ansible.builtin.meta: end_play 

- name: "Validate discovered interfaces" 
  run_once: yes 
  delegate_to: localhost 
  any_errors_fatal: yes 
  vars: 
   all_switches_interfaces: "{{ hostvars | dict2items(key_name='host', value_name='hostvars') | selectattr('hostvars.interface_without_po_set', 'defined') | map(attribute='hostvars.interface_without_po_set') | list | flatten }}"
......

Here, the result:
TASK [Check aggregated interface configuration and save the differences] *******
skipping: [SWITCH56]
skipping: [SWITCH55]
skipping: [SWITCH58]
skipping: [SWITCH57]
skipping: [SWITCH65]
skipping: [SWITCH66]
ok: [SWITCH64]
ok: [SWITCH63]

TASK [Check difference between the configuration of interfaces and targets configurations] ***
skipping: [SWITCH56]
skipping: [SWITCH55]
skipping: [SWITCH57]
skipping: [SWITCH58]
skipping: [SWITCH66]
skipping: [SWITCH65]
ok: [SWITCH64] => {
    "changed": false,
    "msg": "All assertions passed"
}
ok: [SWITCH63] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Validate discovered switch interfaces from switch-side MAC addresses] ****
ok: [SWITCH56 -> localhost]

As you can see, the task Check difference between the configuration of interfaces and targets configurations is successfull so just after that the meta end play must stop the execution but the playbook continues and the next task Validate discovered switch interfaces from switch-side MAC addresses is played.

So I don't understand.

Best Regards,
Folio Brice Roland

Brian Coca

unread,
Jul 6, 2022, 8:28:49 AM7/6/22
to Ansible Project
You don't have any conditionals defined on the tasks, but from the
output you show they are inheriting some conditional (otherwise they
would not skip hosts) so the meta task is probably skipped because the
first host that triggers it has that conditional result in False (see
run_once/bypass host loop behaviors).

--
----------
Brian Coca

brice Folio

unread,
Jul 6, 2022, 10:48:24 AM7/6/22
to Ansible Project
Hi Brian !

Thanks a lot!
Indeed,as the first host that triggered it does not have the required conditions the task is skipped for all others hosts.
It seems that it does not work like others modules that check the condition for all hosts to execute or not the task for each of them.

Best Regards,
Folio Brice Roland

Brian Coca

unread,
Jul 7, 2022, 10:31:59 AM7/7/22
to Ansible Project
many actions do this, they normally have a note that states they
'bypass host loop', for example add_host, and group_by do the same
thing.



--
----------
Brian Coca

Reply all
Reply to author
Forward
0 new messages