Jose Luis
Jose Luis

Reputation: 3361

Ansible trying to find directory I didn't ask to find

I have a very simple task, fetch and unarchive git for installation, for some reason this is my error message in my playbook:

FAILED! => {"changed": false, "failed": true, "invocation": 
            {"module_args": 
             {"backup": null, 
              "content": null, 
              "copy": false, 
              "creates": null, 
              "delimiter": null, 
              "dest": "/root", 
              "directory_mode": null, 
              "exclude": [], "extra_opts": [], "follow": false, "force": null, 
              "group": null, "keep_newer": false, "list_files": false, 
              "mode": null, "original_basename": "v2.9.0.tar.gz", "owner": null, 
              "regexp": null, "remote_src": null, "selevel": null, "serole": null, 
              "setype": null, "seuser": null, 
              "src": "https://github.com/git/git/archive/v2.9.0.tar.gz"
             }
            }, "msg": "path /root/git-2.9.0 does not exist", 
               "path": "/root/git-2.9.0", "state": "absent"
           }

So "path /root/git-2.9.0 does not exist", um.... what?. I'm not even asking for that path, not creating anything...

Could someone please explain?

This is the task I have:

   - name: Decompress git archive
      unarchive:
        src: https://github.com/git/git/archive/v{{ git_version }}.tar.gz
        dest: "{{ workspace }}"
        copy: no

Really not rocket science. In this case git_version is 2.9.0

I tried the following aswell where workspace is /root:

- name: Get git source
  get_url: 
    url: "https://github.com/git/git/archive/v{{ git_version }}.tar.gz"
    dest: "{{ workspace }}/git-{{ git_version }}.tar.gz"
- name: Decompress git archive
  unarchive:
    src: "{{ workspace }}/git-{{ git_version }}.tar.gz"
    dest: "{{ workspace }}"
    creates: "{{ workspace }}/git-{{ git_version }}/README"
    copy: no

And this before the task:

- name: Create git directory
  file: path="{{ workspace }}/git-{{ git_version }}" state=directory

This gives me an error that .gitattribute not found.

Could someone give me some pointers?

Upvotes: 0

Views: 117

Answers (1)

glmrenard
glmrenard

Reputation: 705

I simplifed the unarchive part

- name: Decompress git archive
      shell: tar xvf {{ workspace }}/git-{{ git_version }}.tar.gz -C {{ workspace }}

and at the execution it's OK I can get to the next task On the target I now have

drwxrwxr-x 22 root root 20480 Jul 13 14:51 git-2.9.1 -rw-r--r-- 1 root root 5904522 Jul 13 14:27 git-2.9.1.tar.gz

Upvotes: 1

Related Questions