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:
me...@b1-systems.de
B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg /
http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537