Configuring Fortigate Firewall Interfaces from a CSV file using Ansible
Muhammad Awais Butt
Senior Network and Security Engineer at Emaratech CISM || CISSP || CCIE DC#51557
In continuation of my previous article where we configured two firewall sub-interfaces through Ansible; we are further going to optimize it to use a loop and fetch data from a csv file to create multiple sub-interfaces on fortigate firewall. Below is the CSV file we are going to use for this example by storing their values in key-value pairs.
Now we are going to use Ansible read_csv module and register the output in variable readintf. You can also display the content of csv file by using debug module which we are not going to use in this example.
Once read operation is completed, we are going to use the same fortios_system_interface and instead of giving static values we will fetch csv file values in relevant fields and loop this module till all values stored in readintf variable are retrieved.
Let’s run this code now and see the results.
Sr. Network Infrastructure Engineer
2 年Nice ??