I have a dictionary with hostnames. To every hostname I would like to connect via SSH and to some tasks.
I tried something like this, but this does not work. Any tips and tricks how to achieve this.
main.yml
---
- hosts: all
connection: network_cli
vars:
- input: "{{ lookup('file','temp/yoda-xxx-xx.json') | from_json }}"
- ansible_network_os: nokia.sros.classic
- ansible_ssh_user: user
- ansible_password: password
tasks:
- name: Configure Main
- include_tasks: worker.yml
with_items: "{{ input.delta_config }}"
worker.yml
---
- hosts: "{{ item.device }}"
gather_facts: No
connection: network_cli
tasks:
- name: Configure
community.network.sros_config:
src: "temp/{{ item.device }}"
save: yes
match: line
JSON Input
{
"device":"yoda-xxx-xx",
"config_file":"C:\yoda-xxx-xx.cfg",
"delta_config":[
{
"device":"yoda-yy-01",
"config_file":"temp/yoda-xxx-xx_delta_for_yoda-yy-01.txt"
},
{
"device":"yoda-yy-02",
"config_file":"temp/yoda-xxx-xx_delta_for_yoda-yy-02.txt"
}
]
}