[...] - name: Local Firewall Config hosts: localhost connection: local gather_facts: no vars: localfw: 10.0.2.90 localadmin: admin localpw: "" vdom: root lnet: 10.0.2.0/24 rnet: 10.100.0.0/17 remotefw: "{{ stackinfo.stack_outputs.FortiGatepubIp }}" localinterface: port1 psk: "" vpnname: elavpn tasks: - name: Get the token with uri uri: url: https://{{ localfw }}/logincheck method: POST validate_certs: no body: "ajax=1&username={{ localadmin }}&password={{ localpw }}" register: uriresult tags: gettoken - name: Get Token out set_fact: token: "{{ uriresult.cookies['ccsrftoken'] | regex_replace('\"', '') }}" - debug: msg="{{ token }}" - name: Phase1 old Style uri: url: https://{{ localfw }}/api/v2/cmdb/vpn.ipsec/phase1-interface validate_certs: no method: POST headers: X-CSRFTOKEN: "{{ token }}" Cookie: "{{ uriresult.set_cookie }}" body: "{{ lookup('template', 'forti-phase1.j2') }}" body_format: json register: answer tags: phase1 - name: Phase2 old style uri: url: https://{{ localfw }}/api/v2/cmdb/vpn.ipsec/phase2-interface validate_certs: no method: POST headers: X-CSRFTOKEN: "{{ token }}" Cookie: "{{ uriresult.set_cookie }}" body: "{{ lookup('template', 'forti-phase2.j2') }}" body_format: json register: answer tags: phase2 - name: Route old style [...] - name: Local Object Old Style [...] - name: Remote Object Old Stlye [...] - name: FW-Rule-In old style uri: url: https://{{ localfw }}/api/v2/cmdb/firewall/policy validate_certs: no method: POST headers: Cookie: "{{ uriresult.set_cookie }}" X-CSRFTOKEN: "{{ token }}" body: [...] body_format: json register: answer tags: rulein - name: FW-Rule-out old style uri: url: https://{{ localfw }}/api/v2/cmdb/firewall/policy validate_certs: no method: POST headers: Cookie: "{{ uriresult.set_cookie }}" X-CSRFTOKEN: "{{ token }}" body: [...] body_format: json register: answer tags: ruleout [...]