Ansible error when running for multiple hosts in inventory file

13 views
Skip to first unread message

Yehuda Pinhas

unread,
Jan 6, 2020, 8:22:37 AM1/6/20
to Ansible Project
Hi guys!

Inventory POC_ENV.yml file:

all:
  children:
    POC_ENV:
      hosts:
        TEST-NXOS2
        TEST-NXOS3
  vars:
    ansible_ssh_private_key_file/home/ansible/.ssh/id_rsa
    ansible_ssh_common_args-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
    ansible_useransible


Playbook new_vlan_playbook.yml file:

---
  - name---------------   1. Applying Layer 2 Configuration   ---------------
    hostsPOC_ENV
    connectionlocal
    tasks:
    - include_vars:
        dir/etc/ansible/roles/new_vlan/vars/
    - include_role:
        namenew_vlan
        tasks_fromadd_vlan.yml

  - name---------------   3. Applying Layer 3 Configuration   ---------------
    hostsPOC_ENV
    connectionlocal
    tasks:
    - include_vars:
        dir/etc/ansible/roles/new_vlan/vars/
    - include_role:
        namenew_vlan
        tasks_fromcreate_svi.yml


# Final result = create VLAN and SVI for predefined group

When im running my code when my inventory file mentions only one of the machines TEST-NXOS2/TEST-NXOS3 the code is working perfectly.

But when adding a second host (doesn't matter if NXOS2 or 3 is added) the code fails with this error:

ansible ping proof.PNG






Working run proof on one host:

ansible ping proof.PNG



What am I missing here?
Am I supposed to tell it to run for each line in POC_ENV.yml file or is it already supposed to know it? because from what I understand ansible is supposed to run on all hosts in parallel and not itterate one by one..

Thanks in advance,
YP

Vladimir Botka

unread,
Jan 6, 2020, 11:29:10 AM1/6/20
to Yehuda Pinhas, ansible...@googlegroups.com
On Mon, 6 Jan 2020 05:22:37 -0800 (PST)
Yehuda Pinhas <yuda....@gmail.com> wrote:

> all:
> children:
> POC_ENV:
> hosts:
> TEST-NXOS2
> TEST-NXOS3

Colon ':' is missing after the hostnames. Fix the inventory

all:
children:
POC_ENV:
hosts:
TEST-NXOS2:
TEST-NXOS3:

Without the colons the lines are concatenated. This is the reason of the error

'fatal: [TEST-NXOS2 TEST-NXOS3]: FAILED! ...'

HTH,

-vlado

Yehuda Pinhas

unread,
Jan 7, 2020, 2:55:31 AM1/7/20
to Ansible Project
Hi Vladimir,
Thank you! working now.

בתאריך יום שני, 6 בינואר 2020 בשעה 18:29:10 UTC+2, מאת Vladimir Botka:
Reply all
Reply to author
Forward
0 new messages