Got it - makes sense now.  Thanks!

On 10/17/2023 1:51 PM, 'Philippe Kueck' via Ansible Project wrote:
You need to name the playbook:

---
- name: "your playbook name goes here"
  hosts: yourhostlist
  tasks:
    - debug:
        msg: >
          {{ansible_play_name}} should print
          "your playbook name goes here"
...

On 17.10.23 19:34, Kathy Lyons wrote:
When I print out "{{ ansible_play_name }}" I simply get "localhost."

On Tue, Oct 17, 2023 at 12:18 PM 'Philippe Kueck' via Ansible Project <[email protected] <mailto:[email protected]>> wrote:

    Hi,

    On 17.10.23 18:13, Kathy Lyons wrote:
     > We use it in many instances to only do something for a specific
     > playbook.  We have about 5 playbooks that work on different
    networks and
     > rather than maintain 5 different playbooks we use the "when
     > playbook_name == abc.yml" a lot. Is there another way to get the
     > playbook name?

    How about this?

    ---
    - name: "foobar playbook"
        hosts: localhost
        gather_facts: no
        tasks:
          - debug:
              msg: '{{ansible_play_name}}'
    ...

    - Philippe

    --     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/UcCnrJRs4iY/unsubscribe <https://groups.google.com/d/topic/ansible-project/UcCnrJRs4iY/unsubscribe>.
    To unsubscribe from this group and all its topics, send an email to
    [email protected]
<mailto:ansible-project%[email protected]>.
    To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/674aaf12-2177-46eb-a995-1dbe04113fd4%40quarantine.de <https://groups.google.com/d/msgid/ansible-project/674aaf12-2177-46eb-a995-1dbe04113fd4%40quarantine.de>.

--
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] <mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAK9%2BsMc9TdqUcWtvOFNv9Uw6p5Upcgx3qGZ5cqbT8Y%3DQnSksiA%40mail.gmail.com <https://groups.google.com/d/msgid/ansible-project/CAK9%2BsMc9TdqUcWtvOFNv9Uw6p5Upcgx3qGZ5cqbT8Y%3DQnSksiA%40mail.gmail.com?utm_medium=email&utm_source=footer>.


--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/81676733-92fb-4449-9511-49dcc809a1b8%40gmail.com.

Reply via email to