bcoca / local_backup

role that allows copying/moving remote backup_file to controller dir by config
GNU General Public License v3.0
3 stars 0 forks source link

Getting "ImportError: No module named backup" in `file` module using this module #1

Closed fthommen closed 2 years ago

fthommen commented 3 years ago

Hi, when using this module like

- hosts: all
  name:  "======  COMMON CONFIGURATIONS ======"
  roles:
    - local_backup
    - common
  tags:
    - common-only

at the first task which uses file (not even copy):

- name: "XXXXXXXXX"
  file:
    path:  "/etc/FILE"
    state: touch
    owner: root
    group: root
    mode:  0644
    # preserving times makes the command idempotent (see ansible documentation)
    modification_time: preserve
    access_time:       preserve

I get the error:

TASK [common : XXXXXXXXX] ****************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named backup
fatal: [HOST]: FAILED! => {"msg": "Unexpected failure during module execution.", "stdout": ""}

The message using -vvv is

TASK [common : XXXXXXXXX] ****************************************************************************************************************************
task path: /data/homes/ansible/ansible-config/ft/ansible-deploy/roles/common/tasks/auth-config.CentOS.yml:29
The full traceback is:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 147, in run
    res = self._execute()
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 630, in _execute
    self._handler = self._get_action_handler(connection=self._connection, templar=templar)
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 1082, in _get_action_handler
    collection_list=collections
  File "/usr/lib/python2.7/site-packages/ansible/plugins/loader.py", line 552, in get
    self._module_cache[path] = self._load_module_source(name, path)
  File "/usr/lib/python2.7/site-packages/ansible/plugins/loader.py", line 530, in _load_module_source
    module = imp.load_source(to_native(full_name), to_native(path), module_file)
  File "/data/homes/ansible/ansible-config/ft/ansible-deploy/roles/local_backup/action_plugins/normal.py", line 8, in <module>
    from ansible.module_utils.backup import local_backup
ImportError: No module named backup
fatal: [HOST]: FAILED! => {
    "msg": "Unexpected failure during module execution.", 
    "stdout": ""
}

When I comment out the copy task, the module fails with the same error message at a task using lineinfile which comes after the copy block, for which I wanted to use the local backup

We are using Ansible 2.9.17 on CentOS 7.9. There is no problem when we don't import local_backup.

Is this a usage problem or some problem with local_backup?

bcoca commented 2 years ago

there is a module_utils/backup.py in this repo that is also required