ansible-openwisp2 icon indicating copy to clipboard operation
ansible-openwisp2 copied to clipboard

[ERROR]: Task failed: Unexpected AnsibleActionFail error: Could not find or access 'ow2_static/'

Open mikysal78 opened this issue 3 weeks ago • 2 comments

Hi, I want to try the new release and I've installed a new VM on Debian Trixie. I created a new playbook following the documentation (I read that there are different variables and started from scratch). I didn't add any custom files, but the playbook gives me this error:

TASK [openwisp.openwisp2 : Copy static files] *********************************************************************************************************************************
[ERROR]: Task failed: Unexpected AnsibleActionFail error: Could not find or access 'ow2_static/'
Searched in:
	/git/openwisp-local-25.10.0/roles/openwisp.openwisp2/files/ow2_static/
	/git/openwisp-local-25.10.0/roles/openwisp.openwisp2/ow2_static/
	/git/openwisp-local-25.10.0/roles/openwisp.openwisp2/tasks/files/ow2_static/
	/git/openwisp-local-25.10.0/roles/openwisp.openwisp2/tasks/ow2_static/
	/git/openwisp-local-25.10.0/files/ow2_static/
	/git/openwisp-local-25.10.0/ow2_static/ on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option
Origin: /git/openwisp-local-25.10.0/roles/openwisp.openwisp2/tasks/django.yml:163:3

161     - openwisp2_theme
162
163 - name: Copy static files
      ^ column 3

fatal: [controller.nnxx.ninux.org]: FAILED! => {"changed": false, "msg": "Unexpected AnsibleActionFail error: Could not find or access 'ow2_static/'\nSearched in:\n\t/git/openwisp-local-25.10.0/roles/openwisp.openwisp2/files/ow2_static/\n\t/git/openwisp-local-25.10.0/roles/openwisp.openwisp2/ow2_static/\n\t/git/openwisp-local-25.10.0/roles/openwisp.openwisp2/tasks/files/ow2_static/\n\t/git/openwisp-local-25.10.0/roles/openwisp.openwisp2/tasks/ow2_static/\n\t/git/openwisp-local-25.10.0/files/ow2_static/\n\t/git/openwisp-local-25.10.0/ow2_static/ on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option"}

My playbook is:

- hosts: openwisp2
  become: "{{ become | default('yes') }}"
  roles:
    - openwisp.openwisp2
  vars:
    openwisp2_default_from_email: "[email protected]"
    openwisp2_language_code: it-it
    openwisp2_http_allowed_ip: "10.27.0.0/16"
    openwisp2_allowed_hosts:
        - controller.nnxx.ninux.org
    openwisp2_leaflet_config:
        DEFAULT_CENTER: [40.4476419, 16.4735738]
        DEFAULT_ZOOM: 6
    openwisp2_firmware_upgrader: true
    openwisp2_extra_django_settings_instructions:
      - |
        OPENWISP_CUSTOM_OPENWRT_IMAGES = (
            ('my-custom-image-squashfs-sysupgrade.bin', {
                'label': 'My Custom Image',
                'boards': ('MyCustomImage',)
            }),
        )
    openwisp2_network_topology: true
    openwisp2_database:
        engine: django.contrib.gis.db.backends.postgis
        name: "openwisp2"
        user: "openwisp2"
        host: "localhost"
        password: "Pippo"
        port: 5432
    
    # set to false when you don't want to register openwisp-radius
    # API endpoints.
    openwisp2_radius_urls: true
     # Configuration to use Let's Encrypt certificate for OpenWISP server (Nnginx)
    openwisp2_ssl_cert: "/etc/letsencrypt/live/nnxx.ninux.org/fullchain.pem"
    openwisp2_ssl_key: "/etc/letsencrypt/live/nnxx.ninux.org/privkey.pem"
    # Configuration for openwisp-radius
    openwisp2_radius: true
    openwisp2_freeradius_install: true
    freeradius_eap_orgs:
      - name: demo
        uuid: 00000000-0000-0000-0000-000000000001
        radius_secret: demo-radius-token
        auth_port: 1832
        acct_port: 1833
        inner_tunnel_auth_port: 18330
        # Update the cert_file and private_key paths to point to the
        # Let's Encrypt certificate.
        cert: /etc/letsencrypt/live/nnxx.ninux.org/fullchain.pem
        private_key: /etc/letsencrypt/live/nnxx.ninux.org/privkey.pem
        # If you choose to re-use the same certificate for both services,
        # your configuration would look like this
        # cert: /etc/letsencrypt/live/{{ inventory_hostname }}/fullchain.pem
        # private_key: /etc/letsencrypt/live/{{ inventory_hostname }}/privkey.pem
  pre_tasks:
    - name: Update APT package cache
      apt:
        update_cache: true
      changed_when: false
      retries: 5
      delay: 10
      register: result
      until: result is success
    - name: Creates temp directory ansible
      file:
        path: /var/www/.ansible/tmp
        state: directory
        owner: www-data
        group: www-data
        mode: 0777
        recurse: yes

What should I do to resolve this? Best regards, Michele

mikysal78 avatar Dec 01 '25 21:12 mikysal78

I can reproduce this issue on a clean Debian Trixie VM using a minimal playbook. The error occurs because the role always attempts to copy theow2_static/ directory, but this directory does not exist by default in the role or project structure.

Proposed Fix Options I see two possible approaches:

A) Make the task conditional Only copy static files if a variable such as openwisp2_custom_static_dir is defined, or if ow2_static/ actually exists.

B) Include an empty directory by default Ship an empty ow2_static/ directory inside the role so that the task succeeds even when users do not define custom static files.

if this can workout then assign this issue to me

Sparshagarwal29 avatar Dec 09 '25 19:12 Sparshagarwal29

Okay for B. I created an empty directory and it worked. Now I have another error...https://github.com/openwisp/ansible-openwisp2/issues/576

mikysal78 avatar Dec 09 '25 23:12 mikysal78

This is the task which is causing the failure: https://github.com/openwisp/ansible-openwisp2/blob/master/tasks/django.yml#L163

It shouldn't cause the playbook to fail because it's flagged with failed_when: false. CC: @pandafy

@Sparshagarwal29 can you check why is failed_when: false being ignored for you as well?

@mikysal78 @Sparshagarwal29 what's your ansible version?

nemesifier avatar Dec 15 '25 09:12 nemesifier

I have enabled CI builds on the stable branches to facilitate releasing bug fix releases and this came out on the 24.11 branch: https://github.com/openwisp/ansible-openwisp2/actions/runs/20238275231/job/58098815686

  TASK [openwisp.openwisp2 : Copy static files] **********************************
  [ERROR]: Task failed: Unexpected AnsibleActionFail error: Could not find or access 'ow2_static/'
  Searched in:
          /home/runner/work/ansible-openwisp2/ansible-openwisp2/files/ow2_static/
          /home/runner/work/ansible-openwisp2/ansible-openwisp2/ow2_static/
          /home/runner/work/ansible-openwisp2/ansible-openwisp2/tasks/files/ow2_static/
          /home/runner/work/ansible-openwisp2/ansible-openwisp2/tasks/ow2_static/
          /home/runner/work/ansible-openwisp2/ansible-openwisp2/molecule/resources/files/ow2_static/
          /home/runner/work/ansible-openwisp2/ansible-openwisp2/molecule/resources/ow2_static/ on the Ansible Controller.
  If you are using a module and expect the file to exist on the remote, see the remote_src option
  Origin: /home/runner/work/ansible-openwisp2/ansible-openwisp2/tasks/django.yml:163:3
  
  161     - openwisp2_theme
  162
  163 - name: Copy static files
        ^ column 3
  
  fatal: [openwisp2-debian12]: FAILED! => {"changed": false, "msg": "Unexpected AnsibleActionFail error: Could not find or access 'ow2_static/'\nSearched in:\n\t/home/runner/work/ansible-openwisp2/ansible-openwisp2/files/ow2_static/\n\t/home/runner/work/ansible-openwisp2/ansible-openwisp2/ow2_static/\n\t/home/runner/work/ansible-openwisp2/ansible-openwisp2/tasks/files/ow2_static/\n\t/home/runner/work/ansible-openwisp2/ansible-openwisp2/tasks/ow2_static/\n\t/home/runner/work/ansible-openwisp2/ansible-openwisp2/molecule/resources/files/ow2_static/\n\t/home/runner/work/ansible-openwisp2/ansible-openwisp2/molecule/resources/ow2_static/ on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option"}

However, this error is not happening on the master branch nor on the 25.10 branch. I am still not sure about the cause of this mismatch of behavior.

nemesifier avatar Dec 15 '25 15:12 nemesifier

Thanks for suggesting possible solutions @Sparshagarwal29! In the spirit of urgency, I opened a PR to fix this issue. Please work on any other open issue.

pandafy avatar Dec 16 '25 16:12 pandafy