fortinet-ansible-dev / ansible-galaxy-fortios-collection

GNU General Public License v3.0
84 stars 47 forks source link

Fortinet logo|

FortiOS Ansible Collection


The collection is the FortiOS Ansible Automation project. It includes the modules that are able to configure FortiOS and FortiGate by allowing the user to configure firewall features.

Installation

This collection is distributed via ansible-galaxy, the installation steps are as follows:

  1. Install or upgrade to Ansible 2.15+
  2. Download this collection from galaxy: ansible-galaxy collection install fortinet.fortios:2.3.7

Requirements

Supported FortiOS Versions

From v2.0.0 on, FortiOS galaxy collections are unified, and cover FortiOS 6.0, 6.2, 6.4, 7.0, 7.2 versions. There is only one sequential collection at any moment. users who install these collections are expected to find the version compatibility information for each module and its parameters.

The latest version is 2.3.7, path to install: ansible-galaxy collection install fortinet.fortios:2.3.7

Prior to FortiOS collection v2.0.0, FortiOS Galaxy collections were built over three FOS major versions, i.e. v6.0, v6.2 and v6.4, thus, users are expected to install the collection according to the following table to avoid potential compatibility issues.

FOS version Galaxy Version Release date Path to Install
6.0.0 1.0.13 2020/5/26 ansible-galaxy collection install fortinet.fortios:1.0.13
6.0.0 1.1.2 2020/12/4 ansible-galaxy collection install fortinet.fortios:1.1.2
6.0.0 1.1.5 2020/12/7 ansible-galaxy collection install fortinet.fortios:1.1.5
6.0.0 1.1.8 2020/12/21 ansible-galaxy collection install fortinet.fortios:1.1.8
6.0.0 1.1.9 latest 2021/3/1 ansible-galaxy collection install fortinet.fortios:1.1.9
6.2.0 1.0.10 2020/5/6 ansible-galaxy collection install fortinet.fortios:1.0.10
6.2.0 1.1.0 2020/12/4 ansible-galaxy collection install fortinet.fortios:1.1.0
6.2.0 1.1.3 2020/12/7 ansible-galaxy collection install fortinet.fortios:1.1.3
6.2.0 1.1.6 latest 2020/12/21 ansible-galaxy collection install fortinet.fortios:1.1.6
6.4.0 1.0.11 2020/5/11 ansible-galaxy collection install fortinet.fortios:1.0.11
6.4.0 1.1.1 2020/12/4 ansible-galaxy collection install fortinet.fortios:1.1.1
6.4.0 1.1.4 2020/12/7 ansible-galaxy collection install fortinet.fortios:1.1.4
6.4.0 1.1.7 latest 2020/12/21 ansible-galaxy collection install fortinet.fortios:1.1.7

Note: Use -f option (i.e. ansible-galaxy collection install -f fortinet.fortios:x.x.x) to renew your existing local installation.

Modules

The collection provides the following modules:

Roles

Usage

The following example is used to configure global attributes in Fortinet's FortiOS and FortiGate.

Create fw_global_set.yml with the following template:

---
- hosts: fortigates
  collections:
   - fortinet.fortios
  connection: httpapi
  vars:
   vdom: "root"
   ansible_httpapi_use_ssl: yes
   ansible_httpapi_validate_certs: no
   ansible_httpapi_port: 443
  tasks:
  - name: Configure global attributes.
    fortios_system_global:
      vdom:  "{{ vdom }}"
      system_global:
        admintimeout: "23"
        hostname: "FortiGate02"

Create the hosts inventory file

[fortigates]
fortigate01 ansible_host=192.168.190.100 ansible_user="admin" ansible_password="password"

[fortigates:vars]
ansible_network_os=fortinet.fortios.fortios

Run the test:

ansible-playbook -i hosts fw_global_set.yml

This will configure the firewall's hostname and admin timeout.