Hi Jeffrey,

On 11.03.19 20:50, Jeffrey Agnitsch wrote:
> - name: vmotion {{ inventory_hostname }}

You'll also need "" here.

- name: "vmotion {{ inventory_hostname }}"

And this will give you only the first hostname as name for the task.

This works for me:

Playbook (without the linebreak in the when: line):

---
- hosts: all
  tasks:
    - name: "foobar {{ inventory_hostname }}"
      debug:
      delegate_to: localhost
      when: inventory_hostname | regex_replace('.*([0-9]+).*', '\\1') |
int  > 1


Inventory:

host1
host2

Output:

$ ansible-playbook -i /tmp/hosts /tmp/test.yml

PLAY [all]
***************************************************************************

TASK [Gathering Facts]
***************************************************************************
ok: [host2]
ok: [host1]

TASK [foobar host1]
***************************************************************************
skipping: [host1]
ok: [host2 -> localhost] => {
    "msg": "Hello world!"
}

PLAY RECAP
***************************************************************************
host1      : ok=1    changed=0    unreachable=0    failed=0
host2      : ok=1    changed=0    unreachable=0    failed=0


Hope that helps,
Sebastian

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: [email protected]

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/2db654d8-0af7-97b0-6351-27f58c487b54%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.

Reply via email to