Coder Social home page Coder Social logo

Comments (11)

JieX19 avatar JieX19 commented on August 22, 2024

@33Fraise33,

This module is the only one relies on fortiosapi, which will be deprecated in the next major release. Can you please check if fortiosapi is installed? Using command: pip list to check.
Using command: pip install fortiosapi to install it if it's not existing.

Because it's using the legacy mode you cannot using any variables starting with ansible in your hosts file, like ansible_username etc.

Here's a workaround to solve the issue.

- hosts: localhost
  collections:
    - fortinet.fortios
  vars:
    vdom: "root"
    host: "198.168.10.21"
    username: "admin"
    password: ""
  tasks:
  - name: backup global
    fortios_system_config_backup_restore:
      config: "system config backup"
      host:  "{{ host }}"
      username: "{{ username }}"
      password: "{{ password }}"
      vdom: "{{ vdom }}"
      backup: "yes"
      https: True
      ssl_verify: False
      scope: "global"
      filename: "./backup_global_test"

from ansible-galaxy-fortios-collection.

33Fraise33 avatar 33Fraise33 commented on August 22, 2024

Hello,

Yes that module is installed: fortiosapi 1.0.3.
I did not know to remove the httpapi connection option.

When is the removal of this dependency planned?

from ansible-galaxy-fortios-collection.

JieX19 avatar JieX19 commented on August 22, 2024

Hi,

Sorry to make you confused in. In the whole collection, all the modules are compatible with httpapi but this module (fortios_system_config_backup_restore), so we recommend to provide host, username and password in the playbook to trigger fortiosapi.

If you put httpapi connection in the playbook I wrote above, it's fine, it will not make any errors but it's kinda useless. Fortiosapi will be called when host, username and password are provided.
That's how the lelacy mode works.

For all the rest of modules, please use httpapi.
Example as below:

- hosts: fortigates
  connection: httpapi
  collections:
  - fortinet.fortios

Because we still have a few user using the legacy mode, we will get you updated regarding the removal of this dependency.

from ansible-galaxy-fortios-collection.

33Fraise33 avatar 33Fraise33 commented on August 22, 2024

Thanks, I got it working like you described, so I understand it currently doesn't use an inventory file.

my config if anyone needs this:

- hosts: localhost
  collections:
   - fortinet.fortios
  tasks:
  - name: backup global or a_specific_vdom settings
    fortios_system_config_backup_restore:
      config: "system config backup"
      vdom: "root"
      host: "10.200.0.2"
      username: "admin"
      password: "password_here"
      backup: "yes"
      https: True
      ssl_verify: False
      scope: "vdom"
      filename: "/tmp/backup_test"
    register: test
  - debug:
      msg: "{{ test }}"

We will probably wait until the httpapi is implemented as well before using this module in production.

from ansible-galaxy-fortios-collection.

JieX19 avatar JieX19 commented on August 22, 2024

Yes, it's a quick fix for the issue #38. We will have mortitor APIs included in the next major release and then this module will be deprecated. Thank you for your advice!

from ansible-galaxy-fortios-collection.

sergioolovrap avatar sergioolovrap commented on August 22, 2024

Hello,
there are any news about the issue?
Because I have the same error
Regards

from ansible-galaxy-fortios-collection.

JieX19 avatar JieX19 commented on August 22, 2024

@sergioolovrap,

This module is the only one relies on fortiosapi, which will be deprecated in the next major release. Can you please check if fortiosapi is installed? Using command: pip list to check.
Using command: pip install fortiosapi to install it if it's not existing.

Because it's using the legacy mode you cannot using any variables starting with ansible in your hosts file, like ansible_username etc.

In the whole collection, all the modules are compatible with httpapi but this module (fortios_system_config_backup_restore), so we recommend to provide host, username and password in the playbook to trigger fortiosapi.

If you put httpapi connection in the playbook I wrote above, it's fine, it will not make any errors but it's kinda useless. Fortiosapi will be called when host, username and password are provided.
That's how the lelacy mode works.

Here's the correct playbook to solve the issue.

- hosts: localhost
  collections:
    - fortinet.fortios
  vars:
    vdom: "root"
    host: "198.168.10.21"
    username: "admin"
    password: ""
  tasks:
  - name: backup global
    fortios_system_config_backup_restore:
      config: "system config backup"
      host:  "{{ host }}"
      username: "{{ username }}"
      password: "{{ password }}"
      vdom: "{{ vdom }}"
      backup: "yes"
      https: True
      ssl_verify: False
      scope: "global"
      filename: "./backup_global_test"

from ansible-galaxy-fortios-collection.

JieX19 avatar JieX19 commented on August 22, 2024

@sergioolovrap,

Can you please provide us more details about the error if the above solution does not work for you?

from ansible-galaxy-fortios-collection.

sergioolovrap avatar sergioolovrap commented on August 22, 2024

@sergioolovrap,

Can you please provide us more details about the error if the above solution does not work for you?

Hello,
this is my playbook:

  • hosts: EDC-FGT (there is the ip of FGT)
    collections:

    • fortinet.fortios
      connection: httpapi
      vars:
      vdom: "root"
      host: "X.X.X.X"
      username: "admin"
      password: ""
      ansible_httpapi_use_ssl: yes
      ansible_httpapi_validate_certs: no
      ansible_httpapi_port: 4434 #my management is this port
      ansible_network_os: fortios

    tasks:

    • name: backup global
      fortios_system_config_backup_restore:
      config: "system config backup"
      host: "{{ host }}"
      username: "{{ username }}"
      password: "{{ password }}"
      vdom: "{{ vdom }}"
      backup: "yes"
      https: True
      ssl_verify: False
      scope: "global"
      filename: "./backup_global_test"

Log:
(venv) [root@localhost playbook]# ansible-playbook issue_fortios.yml
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details

PLAY [EDC-FGT] ******************************************************************************************

TASK [Gathering Facts] **********************************************************************************
ok: [X.X.X.X]

TASK [backup global] ************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named fortiosapi
fatal: [X.X.X.X]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File "/root/.ansible/tmp/ansible-local-33230rgfdra4e/ansible-tmp-1602853031.2087827-33316-115616784874568/AnsiballZ_fortios_system_config_backup_restore.py", line 102, in \n _ansiballz_main()\n File "/root/.ansible/tmp/ansible-local-33230rgfdra4e/ansible-tmp-1602853031.2087827-33316-115616784874568/AnsiballZ_fortios_system_config_backup_restore.py", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/root/.ansible/tmp/ansible-local-33230rgfdra4e/ansible-tmp-1602853031.2087827-33316-115616784874568/AnsiballZ_fortios_system_config_backup_restore.py", line 40, in invoke_module\n runpy.run_module(mod_name='ansible_collections.fortinet.fortios.plugins.modules.fortios_system_config_backup_restore', init_globals=None, run_name='main', alter_sys=True)\n File "/usr/lib64/python2.7/runpy.py", line 176, in run_module\n fname, loader, pkg_name)\n File "/usr/lib64/python2.7/runpy.py", line 82, in _run_module_code\n mod_name, mod_fname, mod_loader, pkg_name)\n File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code\n exec code in run_globals\n File "/tmp/ansible_fortios_system_config_backup_restore_payload_ylrtg8/ansible_fortios_system_config_backup_restore_payload.zip/ansible_collections/fortinet/fortios/plugins/modules/fortios_system_config_backup_restore.py", line 88, in \nImportError: No module named fortiosapi\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

PLAY RECAP **********************************************************************************************
X.X.X.X : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

from ansible-galaxy-fortios-collection.

JieX19 avatar JieX19 commented on August 22, 2024

@sergioolovrap,

The error "An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named fortiosapi" means there's no fortiosapi installed in your device.

Using command pip install fortiosapi to install it. This is the legacy mode we were using before and it's the only module relying on fortiosapi and it will be deprecated in the near future.

Also, please delete all the parameters starting with ansible_, the key words only get working when using httpapi. Please follow the example playbook I provided above.

from ansible-galaxy-fortios-collection.

chillancezen avatar chillancezen commented on August 22, 2024

solution in #50 (comment).

it's recommended to use new modules with collection later than 2.0.0: https://ansible-galaxy-fortios-docs.readthedocs.io/en/latest/faq.html#how-to-backup-and-restore-fos

from ansible-galaxy-fortios-collection.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.