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

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

fortinet.fortios 2.3.6 does not work with ansible-core 2.17.2 for backups #338

Closed Akasurde closed 3 months ago

Akasurde commented 3 months ago

Summary

I tried to run ansible for fortinet using httpapi. I have configured access_token following the documentation but I got an error message said that access_token was not defined in configuration.

Changing the method from token to username/password also yield the same result

Error message seen below

File "/tmp/ansible_fortios_monitor_fact_payload_v68501bf/ansible_fortios_monitor_fact_payload.zip/ansible/module_utils/connection.py", line 199, in rpc ansible.module_utils.connection.ConnectionError: Requested entry (plugin_type: connection plugin: ansible_collections.ansible.netcommon.plugins.connection.httpapi setting: access_token ) was not defined in configuration.

Issue Type

Bug Report

Component Name

ansible [core 2.17.2] ansible.netcommon 7.0.0 ansible.utils 5.0.0 community.general 9.1.0 community.network 5.0.3 fortinet.fortios 2.3.6

Ansible Version

$ ansible --version
ansible [core 2.17.2]
python version = 3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0] (/usr/bin/python3)
jinja version = 3.1.4
libyaml = True

Configuration

CONFIG_FILE() = /home/x/.ansible.cfg
DEFAULT_STDOUT_CALLBACK(/home/x/.ansible.cfg) = yaml
HOST_KEY_CHECKING(/home/x/.ansible.cfg) = False

CONNECTION:
==========

paramiko_ssh:
____________
host_key_checking(/home/x/.ansible.cfg) = False

ssh:
___
host_key_checking(/home/x/.ansible.cfg) = False

OS / Environment

Linux ntp 5.15.0-116-generic https://github.com/ansible-collections/ansible.netcommon/issues/126-Ubuntu SMP Mon Jul 1 10:14:24 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

target device Fortinet 7.0.14

Steps to Reproduce

STEPS TO REPRODUCE Use below inventory, groupvars and playbook

Inventory.ini

[firewall:children] fortigate

[fortigate] FGT-1 fortios_access_token=access_token_from_fortigate

group_vars fortigate.yml

ansible_connection: httpapi ansible_network_os: fortinet.fortios.fortios ansible_user: ansible ansible_httpapi_validate_certs: no ansible_httpapi_use_ssl: yes ansible_httpapi_port: 443

playbook backup.yml

hosts: firewall gather_facts: no collections:

fortinet.fortios tasks:

name: backup a virtual domain. fortios_monitor_fact: vdom: 'root' access_token: "{{ fortios_access_token }}" selector: 'system_config_backup' params: scope: 'global' register: backupinfo

name: Save the backup information. copy: content: '{{ backupinfo.meta.raw }}' dest: 'backups/{{ inventory_hostname }}.config'

Expected Results

Able to backup fortigate through Ansible

Actual Results

File "/tmp/ansible_fortinet.fortios.fortios_monitor_fact_payload_osvtpsom/ansible_fortinet.fortios.fortios_monitor_fact_payload.zip/ansible_collections/fortinet/fortios/plugins/modules/fortios_monitor_fact.py", line 3228, in <module>
      File "/tmp/ansible_fortinet.fortios.fortios_monitor_fact_payload_osvtpsom/ansible_fortinet.fortios.fortios_monitor_fact_payload.zip/ansible_collections/fortinet/fortios/plugins/modules/fortios_monitor_fact.py", line 3168, in main
      File "/tmp/ansible_fortinet.fortios.fortios_monitor_fact_payload_osvtpsom/ansible_fortinet.fortios.fortios_monitor_fact_payload.zip/ansible/module_utils/connection.py", line 199, in __rpc__
    ansible.module_utils.connection.ConnectionError: Requested entry (plugin_type: connection plugin: ansible_collections.ansible.netcommon.plugins.connection.httpapi setting: access_token ) was not defined in configuration.

Code of Conduct

Akasurde commented 3 months ago

cc @filterfilter

Akasurde commented 3 months ago

This is a migrated issue, please ping @filterfilter for more information.

MaxxLiu22 commented 3 months ago

Hi @filterfilter

Sorry for the inconvenience. We do have an issue with Ansible ansible-core==2.17.2. Please upgrade to fortinet.fortios:2.3.7 and give it a try. Let me know if the issue still persists.

ansible-galaxy collection install fortinet.fortios:2.3.7

Thanks, Maxx

filterfilter commented 3 months ago

Hi @MaxxLiu22

Thank you for your response. I am able to run the playbook using fortinet.fortios:2.3.7 Thanks!