gabstopper / ansible-stonesoft

Ansible libraries for automating Stonesoft FW Management
Apache License 2.0
10 stars 3 forks source link

Unable to set log_server #35

Open sebbbastien opened 5 years ago

sebbbastien commented 5 years ago

Hi David,

I'm unable to set log_server using Ansible:

In [10]: list(map(lambda _: (_.name, _.href), LogServer.objects.all()))                                                                                                                                                                        
Out[10]: 
[('log_06', 'http://pn-srv-smc01:8082/6.5/elements/log_server/9981'),
 ('log_05', 'http://pn-srv-smc01:8082/6.5/elements/log_server/9980'),
 ('log_04', 'http://pn-srv-smc01:8082/6.5/elements/log_server/9979'),
 ('log_03', 'http://pn-srv-smc01:8082/6.5/elements/log_server/9978'),
 ('log_02', 'http://pn-srv-smc01:8082/6.5/elements/log_server/9977'),
 ('log_01', 'http://pn-srv-smc01:8082/6.5/elements/log_server/9976')]

Playbook:

- name: Firewall Template
  hosts: localhost
  gather_facts: no

  tasks:
    - name: Layer 3 FW template
      engine:
        primary_mgt: 0

        name: FW110
        log_server: log_03
        auth_request: 1

        type: single_fw

        interfaces:
          - interface_id: 0
            interfaces:
              - nodes:
                  - dynamic: true
                    dynamic_index: 1
            zone_ref: External
          - interface_id: 1
            interfaces:
              - nodes:
                  - address: 1.1.1.1
                    network_value: 1.1.1.0/24
                    nodeid: 1
                    auth_request: True
                zone_ref: Internal

Error:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: smc.api.exceptions.CreateEngineFailed: Invalid JSON format: com.stonesoft.util.m.StoneException: Syntax of this URI is invalid: log_03 (from: SGSingleFWDTO["log_server_ref"]).
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Invalid JSON format: com.stonesoft.util.m.StoneException: Syntax of this URI is invalid: log_03 (from: SGSingleFWDTO[\"log_server_ref\"])."}

I'm able to fix this using smc-python, so this is not urgent.

Best regards,

gabstopper commented 5 years ago

Hi Sebastien, it looks to be an issue with serializing the Log Server, I will push a fix into ansible today and let you know when complete.

gabstopper commented 5 years ago

It looks like I inadvertently didn't include logic to add or modify the log server element. That has been resolved on latest develop branch and validated for add/modify.