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

GNU General Public License v3.0
85 stars 49 forks source link

fortios_system_automation_action email_body doesnt do anything #283

Closed Jacob-Tate closed 7 months ago

Jacob-Tate commented 12 months ago
- name: Configuration Changed_email
  fortinet.fortios.fortios_system_automation_action:
    access_token: "{{ api_token }}"
    state: "present"
    system_automation_action:
      name: "Configuration Changed_email"
      action_type: "email"
      email_to: "{{ var_email_to }}"
      email_from: "{{ var_email_from }}"
      email_subject: "[{{ inventory_hostname_short }}] Configuration Changed"
      email_body: "zzzz"

With a configuration like this no matter what you input into the email_body nothing will change on the fortigate and it will continue saying ok.

TASK [Configuration Changed_email] *********************************************************************
ok: [<REDACTED>]
<REDACTED># conf sys automation-action 

<REDACTED> (automation-action) # edit Configuration\ Changed_email 

<REDACTED> (Configuration Ch~ail) # show
config system automation-action
    edit "Configuration Changed_email"
        set action-type email
        set email-to "<REDACTED>"
        set email-from "<REDACTED>"
        set email-subject "[<REDACTED>] Configuration Changed"
    next
end
MaxxLiu22 commented 11 months ago

Hi @Jacob-Tate ,

Thank you for raising this issue, I find there is no such an argument email_body in FOS 7.4.1, could you help me check if that exists in your environment through CLI? if so, is that possible to provide your FOS version for me to debug. However, I find message argument that would be functional as "email_body", and Ansible doesn't contain that argument, I provide the generic API as a workaround solution. Let me know if that doesn't solve your question. Sorry for the inconvenience, The development team has acknowledged this issue, waiting for a better solution.

  - name: fortios_system_automation_action
    fortios_json_generic:
      vdom: '{{ vdom }}'
      # access_token: xrxHkbhjz1nphsyyzfGnx1b
      json_generic:
        method: PUT
        path: /api/v2/cmdb/system/automation-action/action_generic2
        jsonbody: '{
          "name": "action_generic2",
          "action-type": "email",
          "email-to": [
            {
              "name": "test1@fortinet.com"
            }
          ],
          "email-from": "test2@fortinet.com",
          "email-subject": "suject",
          "message": "body"
          }

          '
    register: info
  - name: display vars
    debug: msg="{{info}}"

Thanks, Maxx

JieX19 commented 7 months ago

Hi @Jacob-Tate

Please install the latest version 2.3.6 and try this module again. The parameter email_boday is supported in the old fortiOS versions (6.2.0 - 6.2.7), please use 'fos_message' if your device fortiOS firmware version is higher than v6.2.7 . I'll close this ticket at the moment because the issue is fixed in this version already. Feel free to reopen it if you still experience the same issue.

  tasks:
  - name: Configuration Changed_email
    fortios_system_automation_action:
      state: "present"
      enable_log: True
      system_automation_action:
        name: "Ansible_1"
        action_type: "email"
        fos_message: "Ansible Test"

Thanks, Jie