>
> Alright so this is how my playbook looks like now:
-
name: Playing VLAN Configuration
hosts: localhost
# connection: local
vars:
vlan_id: 999
vlan_name: TEST_VLAN_TEST
my_hosts:
- group: 'POC_ENV'
hosts:
"{{ lookup('file','/etc/ansible/ansible_inventories/POC_ENV.yml').splitlines()
}}"
- group: 'Nexus'
hosts:
"{{ lookup('file','/etc/ansible/ansible_inventories/nexus.yml').splitlines() }}"
- group: 'switch'
hosts:
"{{ lookup('file','/etc/ansible/ansible_inventories/switch.yml').splitlines()
}}"
- group: 'avaya'
hosts:
"{{ lookup('file','/etc/ansible/ansible_inventories/avaya.yml').splitlines() }}"
- group: 'branch_switch'
hosts:
"{{
lookup('file','/etc/ansible/ansible_inventories/branch_switch.yml').splitlines()
}}"
- group: 'branch_router'
hosts:
"{{
lookup('file','/etc/ansible/ansible_inventories/branch_router.yml').splitlines()
}}"
- group: 'megalab'
hosts:
"{{ lookup('file','/etc/ansible/ansible_inventories/megalab.yml').splitlines()
}}"
- group: 'DC_Jaffa'
hosts:
"{{ lookup('file','/etc/ansible/ansible_inventories/DC_Jaffa.yml').splitlines()
}}"
- group: 'DC_PT'
hosts:
"{{ lookup('file','/etc/ansible/ansible_inventories/DC_PT.yml').splitlines() }}"
tasks:
- add_host:
name: "{{ item.1 }}"
groups: "{{ item.0.group }}"
ansible_ssh_private_key_file: /home/ansible/.ssh/id_rsa
ansible_ssh_common_args:
-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
ansible_user: ansible
loop: "{{ lookup('subelements', my_hosts, 'hosts') }}"
- hosts: POC_ENV
tasks:
- debug:
msg: "{{ msg.split('\n') }}"
vars:
msg: |
host [{{ inventory_hostname }}]
key [{{ ansible_ssh_private_key_file}}]
args [{{ ansible_ssh_common_args }}]
user [{{ ansible_user }}]
- include_role:
name: show_vlan
# Final result = run show_vlan on requested predefined group
These are the errors that i'm receiving when running the command: $
ansible-playbook myplaybook.yml
[image: Ansible add vlans errors.PNG]
Notes:
- Please note that my ansible.cfg files directs to a inventory.yml file
while I have many inventories (listed in the playbook code POC_ENV.yml,
avaya.yml, etc.
This is the settings on ansible.cfg:
inventory = /etc/ansible/inventory.yml
I'm not sure how to proceed,
Thanks in advance.
--
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/2c48b744-c297-496b-ae9d-6712f4227e21%40googlegroups.com.