Comments (11)
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.
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.
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.
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.
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.
Hello,
there are any news about the issue?
Because I have the same error
Regards
from ansible-galaxy-fortios-collection.
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.
Can you please provide us more details about the error if the above solution does not work for you?
from ansible-galaxy-fortios-collection.
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"
- fortinet.fortios
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.
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.
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)
- Need help w/playbook to list all managed fortiap's per firewall. HOT 4
- updating policy based routing of fortigate is not working always has seq-num error HOT 2
- There must be at least 1 server certificate configured HOT 2
- Getting 404 error while trying to add IPv6 address group using fortios_firewall_addrgrp6 HOT 2
- Error in comparison/serialize HOT 4
- Question on usage - setting dhcp (v4) reservations HOT 3
- federated-upgrade 7.2.7>7.2.8 problem HOT 2
- fortios_system_global timezone not working with FortiOS 7.4.2 and higher HOT 3
- fortinet.fortios.fortios_firewall_addrgrp module question HOT 8
- fortigate firewall firmware upgrade using fortios_monitor module HOT 2
- check mode error since 2.3.5 HOT 2
- IPv4 Virtual Wire Pair Policy HOT 4
- List of check_mode supported modules HOT 3
- DLP profile rule "type" property value "fos_message" isn't obeyed HOT 5
- Wrong handling of Exceptions / TypeError: exceptions must derive from BaseException HOT 2
- Cannot delete/mark as absent static route HOT 4
- Cannot Authenticate Using Username and Password in Ansible 10 + core 2.17 HOT 9
- Authenticating on FortiGates using API doesn't work with Ansible-core 2.17 HOT 8
- KeyError: 'management_ip' in check mode HOT 2
- Feature Request module_defaults group HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible-galaxy-fortios-collection.