fortinet.fortimanager.fmgr_dvmdb_script 模块 – 脚本表。
注意
此模块是 fortinet.fortimanager 集合 (版本 2.8.2) 的一部分。
如果您正在使用 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install fortinet.fortimanager。
要在 playbook 中使用它,请指定:fortinet.fortimanager.fmgr_dvmdb_script。
fortinet.fortimanager 1.0.0 中的新增功能
概要
- 此模块能够配置 FortiManager 设备。 
- 示例包含所有参数和值,在使用前需要根据数据源进行调整。 
参数
| 参数 | 注释 | 
|---|---|
| 无需使用用户名和密码即可访问 FortiManager 的令牌。 | |
| 请求 URL 中的参数 (adom)。 | |
| 仅当模块模式与 FortiManager API 结构差异时设置为 True,模块将继续执行而不验证参数。 选项 
 | |
| 设置的顶级参数。 | |
| 脚本结果日志的完整内容。 | |
| 描述。 | |
| 如果未设置 filter_ostype,则此值在添加/设置/更新请求中将被忽略。 | |
| 数据库中现有设备的名称或 ID。 | |
| 如果目标是 adom_database,则此值无效。 | |
| 如果目标是 adom_database,则此值无效。 选项 
 | |
| 如果未设置 filter_ostype,则此值在添加/设置/更新请求中将被忽略。 选项 
 | |
| 如果未设置 filter_ostype,则此值在添加/设置/更新请求中将被忽略。 | |
| 如果目标是 adom_database,则此值无效。 | |
| 这是一个只读属性,指示脚本创建或修改的时间。 | |
| 名称。 | |
| 脚本计划。 | |
| 指示计划的日期和时间。 onetime daily weekly monthly | |
| 星期几。 选项 
 | |
| 数据库中现有设备的名称或 ID。 | |
| 名称。 | |
| 指示是否应在设备数据库上执行计划的脚本。 选项 
 | |
| 类型。 选项 
 | |
| 目标。 选项 
 | |
| 类型。 选项 
 | |
| 启用/禁用任务日志记录。 选项 
 | |
| 使用 forticloud API 访问令牌验证 Ansible 客户端。 | |
| 底层 Json RPC 请求的覆盖方法。 选项 
 | |
| 将覆盖失败条件的 rc 代码列表。 | |
| 将覆盖成功条件的 rc 代码列表。 | |
| 创建、更新或删除对象的指令。 选项 
 | |
| 在工作区模式下运行 FortiManager 时要锁定的 adom,该值可以是全局的和其他值,包括 root。 | |
| 等待其他用户释放工作区锁的最大时间(秒)。 默认值:  | 
注释
注意
- 从 2.4.0 版本开始,所有输入参数都使用下划线命名约定 (snake_case)。请将诸如“var-name”之类的参数更改为“var_name”。旧的参数名称仍然可用,但您会收到弃用警告。您可以在 ansible.cfg 中设置 deprecation_warnings=False 来忽略此警告。 
- 此 FortiManager 模块支持在工作区锁定模式下运行,顶级参数 workspace_locking_adom 和 workspace_locking_timeout 有助于完成此工作。 
- 要创建或更新对象,请使用 state present 指令。 
- 要删除对象,请使用 state absent 指令。 
- 通常,当返回非零 rc 时,运行一个模块可能会失败。您还可以使用参数 rc_failed 和 rc_succeeded 覆盖失败或成功的条件。 
示例
- name: Apply a script to device
  hosts: fortimanagers
  gather_facts: false
  connection: httpapi
  vars:
    ansible_httpapi_use_ssl: true
    ansible_httpapi_validate_certs: false
    ansible_httpapi_port: 443
    device_adom: "root"
    script_name: "FooScript"
    device_name: "CustomHostName"
    device_vdom: "root"
  tasks:
    - name: Create a Script to later execute
      fortinet.fortimanager.fmgr_dvmdb_script:
        adom: "{{ device_adom }}"
        state: "present"
        dvmdb_script:
          name: "{{ script_name }}"
          desc: "A script created via Ansible"
          content: |
            config system global
                set remoteauthtimeout 80
            end
          type: "cli"
    - name: Run the Script
      fortinet.fortimanager.fmgr_dvmdb_script_execute:
        adom: "{{ device_adom }}"
        dvmdb_script_execute:
          adom: "{{ device_adom }}"
          script: "{{ script_name }}"
          scope:
            - name: "{{ device_name }}"
              vdom: "{{ device_vdom }}"
      register: running_task
    - name: Inspect the Task Status
      fortinet.fortimanager.fmgr_fact:
        facts:
          selector: "task_task"
          params:
            task: "{{ running_task.meta.response_data.task }}"
      register: taskinfo
      until: taskinfo.meta.response_data.percent == 100
      retries: 30
      delay: 3
      failed_when: taskinfo.meta.response_data.state == 'error'
- name: Example playbook
  hosts: fortimanagers
  connection: httpapi
  vars:
    ansible_httpapi_use_ssl: true
    ansible_httpapi_validate_certs: false
    ansible_httpapi_port: 443
  tasks:
    - name: Script table.
      fortinet.fortimanager.fmgr_dvmdb_script:
        bypass_validation: false
        adom: ansible
        state: present
        dvmdb_script:
          content: "ansiblt-test"
          name: "ansible-test"
          target: device_database
          type: cli
- name: Gathering fortimanager facts
  hosts: fortimanagers
  gather_facts: false
  connection: httpapi
  vars:
    ansible_httpapi_use_ssl: true
    ansible_httpapi_validate_certs: false
    ansible_httpapi_port: 443
  tasks:
    - name: Retrieve all the scripts in the device
      fortinet.fortimanager.fmgr_fact:
        facts:
          selector: "dvmdb_script"
          params:
            adom: "ansible"
            script: "your_value"
- name: Example playbook
  hosts: fortimanagers
  connection: httpapi
  vars:
    ansible_httpapi_use_ssl: true
    ansible_httpapi_validate_certs: false
    ansible_httpapi_port: 443
  tasks:
    - name: Enable workspace mode
      fortinet.fortimanager.fmgr_system_global:
        system_global:
          adom-status: enable
          workspace-mode: normal
    - name: Script table.
      fortinet.fortimanager.fmgr_dvmdb_script:
        bypass_validation: false
        adom: root
        state: present
        workspace_locking_adom: "root"
        dvmdb_script:
          content: "ansiblt-test"
          name: "fooscript000"
          target: device_database
          type: cli
    - name: Verify script table
      fortinet.fortimanager.fmgr_fact:
        facts:
          selector: "dvmdb_script"
          params:
            adom: "root"
            script: "fooscript000"
      register: info
      failed_when: info.meta.response_code != 0
    - name: Restore workspace mode
      fortinet.fortimanager.fmgr_system_global:
        system_global:
          adom-status: enable
          workspace-mode: disabled
返回值
常见的返回值已在此处记录,以下是此模块特有的字段
| 键 | 描述 | 
|---|---|
| 请求的结果。 返回: 始终 | |
| 请求的完整 URL。 返回: 始终 示例:  | |
| API 请求的状态。 返回: 始终 示例:  | |
| API 响应。 返回: 始终 | |
| API 响应的描述性消息。 返回: 始终 示例:  | |
| 目标系统的详细信息。 返回: 始终 | |
| 请求的状态。 返回: 始终 示例:  | |
| 如果 playbook 中使用的参数不受当前 FortiManager 版本支持,则会发出警告。 返回: 复杂类型 | 
