Example of using using module csv_to_facts:
---
- hosts: localhost
gather_facts: no
tasks:
- name: Get facts from CSV file
csv_to_facts:
Example of using using module csv_to_facts:
---
- hosts: localhost
gather_facts: no
tasks:
- name: Get facts from CSV file
csv_to_facts:
This example illustrates that variables names can be created dynamically in an Ansible playbook.
Given we have a list of dictionaries representing DHCP Servers in our playbook. In this case, the list of DHCP servers was read from a spreadsheet and exposed as variables to the playbook.
ok: [localhost] => (item=dhcp_servers) => {
"ansible_facts": {
"dhcp_servers": [
{
"addr": "203.0.113.17",
"label": "DHCP_DC1_PRD"