ansible / ansible-modules-extras

Ansible extra modules - these modules ship with ansible
947 stars 1.47k forks source link

patch module: src file lookup doesn't work #694

Closed egroeper closed 9 years ago

egroeper commented 9 years ago

Issue Type: “Bug Report”

Ansible Version: ansible 1.9.2

Ansible Configuration: clean rollout from PPA

Environment: Ubuntu 14.04

Summary: I get "src seafevents_db.patch doesn't exist or not readable" for an existing file in roles/x/files and a task of role x.

Steps To Reproduce: ├── roles │   └── nodes │   ├── defaults │   │   └── main.yml │   ├── files │   │   ├── seafdav.conf │   │   └── seafevents_db.patch │   ├── handlers │   │   └── main.yml │   ├── tasks │   │   ├── ceph.yml │   │   ├── clones.yml │   │   ├── dependencies.yml │   │   ├── initial_install.yml │   │   ├── main.yml │   │   ├── master.yml │   │   ├── nginx.yml │   │   └── startup.yml │   └── templates │      ├── ccnet.conf.j2 │      ├── init-seafile-server.j2 │      ├── seafevents.conf.j2 │      ├── seafile.conf.j2 │      ├── seafile.j2 │      └── seahub_settings.py.j2 └── site.yaml

In roles/nodes/tasks/master.yml: This works:

- name: copy seafdav.conf (default settings)
  copy: src=seafdav.conf dest=<<destpath>>

These don't (second one just for testing):

- name: my patch
  patch: >
    src=seafevents_db.patch
    dest="<<destpath>>"
  ignore_errors: yes  # fixed version is no problem
- name: my patch
  patch: >
    src=seafdav.conf
    dest="<<destpath>>"
  ignore_errors: yes  # fixed version is no problem

Expected Results: Patching works.

Actual Results: "src seafevents_db.patch doesn't exist or not readable". Similar error for patch with seafdav.conf (should be a different error). But copying seafdav.conf from the same .yml file works.

egroeper commented 9 years ago

The lookup doesn't seem to be the problem... It doesn't work with an absolute path either. But the copy module is fine with the same file. :-\

Faheetah commented 9 years ago

The only difference I see is the "if not os.access(p.src, R_OK):" line, but comparing to the copy module the only real difference is the os.path.expanduser which doesn't seem to make a difference. We're having this same issue (Ubuntu 15.04 using .pyenv).

zfil commented 9 years ago

I've fixed it for 1.9 in https://github.com/ansible/ansible/pull/11888, this has been released in 1.9.3. This issue should be closed ...

bcoca commented 9 years ago

closing as per above

egroeper commented 9 years ago

@zfil Thanks for fixing this.

l1x commented 7 years ago
ansible --version
ansible 2.1.2.0
fatal: [10.13.13.10]: FAILED! => {"failed": true, "msg": "The conditional check '(cerberus_downloaded.stat.exists == false) and (file_stat.stat.get_checksum != lookup('fil
e', \"{{ cerberus_home }}/{{ cerberus_version  }}/{{ artifact_file }}.sha1\"))' failed. The error was: the file_name '/opt/cerberus/0.3.0/cerberus-0.3.0.jar.sha1' does not
 exist, or is not readable\n\nThe error appears to have been in '/Users/l1x/code/benovative/platform/v2/roles/cerberus/tasks/main.yml': line 73, column 3, but may\nbe else
where in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Checksum verification sha1\n  ^ here\n"}
ssh centos@10.13.13.10 'sudo ls -alrth /opt/cerberus/0.3.0/cerberus-0.3.0.jar.sha1'
-rw-r--r-- 1 root root 40 Jan 16 13:01 /opt/cerberus/0.3.0/cerberus-0.3.0.jar.sha1

Is it possible that I have this bug in 2.1.2.0?