No such file or directory when using zip command





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I want to create a zip to package my function by using ansible, this is my playbook:



---
- name: build lambda functions
hosts: localhost
- name: Buid Zip Package
command: zip -r functions/build/build-function.zip .
args:
chdir: functions/function-package/


the function I want to package has its code inside functions/function-package/
I get this error:



> TASK [Buid Zip Package]
> ******************************************************** fatal: [localhost]: FAILED! => {"changed": false, "cmd": "zip -r
> functions/build/build-function.zip", "failed": true, "msg": "[Errno 2]
> No such file or directory", "rc": 2}


The paths are very correct, I don't know what else to check!
the playbook is in a file in the same level as the directory /functions



this is the strtucture of the files:



-- playbook.yml
-- /functions
-- /build
-- /function-package
-- script.py
-- lib


the zip is to be put inside /build










share|improve this question

























  • is there a reason why you do not use the archive module?

    – thopaw
    Jan 3 at 10:55













  • It's not working. I use ansible 2.3 and when I use archive module I get this error: ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

    – Souad
    Jan 3 at 10:59











  • can you give the part of the play using the archive module?

    – thopaw
    Jan 3 at 11:04


















0















I want to create a zip to package my function by using ansible, this is my playbook:



---
- name: build lambda functions
hosts: localhost
- name: Buid Zip Package
command: zip -r functions/build/build-function.zip .
args:
chdir: functions/function-package/


the function I want to package has its code inside functions/function-package/
I get this error:



> TASK [Buid Zip Package]
> ******************************************************** fatal: [localhost]: FAILED! => {"changed": false, "cmd": "zip -r
> functions/build/build-function.zip", "failed": true, "msg": "[Errno 2]
> No such file or directory", "rc": 2}


The paths are very correct, I don't know what else to check!
the playbook is in a file in the same level as the directory /functions



this is the strtucture of the files:



-- playbook.yml
-- /functions
-- /build
-- /function-package
-- script.py
-- lib


the zip is to be put inside /build










share|improve this question

























  • is there a reason why you do not use the archive module?

    – thopaw
    Jan 3 at 10:55













  • It's not working. I use ansible 2.3 and when I use archive module I get this error: ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

    – Souad
    Jan 3 at 10:59











  • can you give the part of the play using the archive module?

    – thopaw
    Jan 3 at 11:04














0












0








0








I want to create a zip to package my function by using ansible, this is my playbook:



---
- name: build lambda functions
hosts: localhost
- name: Buid Zip Package
command: zip -r functions/build/build-function.zip .
args:
chdir: functions/function-package/


the function I want to package has its code inside functions/function-package/
I get this error:



> TASK [Buid Zip Package]
> ******************************************************** fatal: [localhost]: FAILED! => {"changed": false, "cmd": "zip -r
> functions/build/build-function.zip", "failed": true, "msg": "[Errno 2]
> No such file or directory", "rc": 2}


The paths are very correct, I don't know what else to check!
the playbook is in a file in the same level as the directory /functions



this is the strtucture of the files:



-- playbook.yml
-- /functions
-- /build
-- /function-package
-- script.py
-- lib


the zip is to be put inside /build










share|improve this question
















I want to create a zip to package my function by using ansible, this is my playbook:



---
- name: build lambda functions
hosts: localhost
- name: Buid Zip Package
command: zip -r functions/build/build-function.zip .
args:
chdir: functions/function-package/


the function I want to package has its code inside functions/function-package/
I get this error:



> TASK [Buid Zip Package]
> ******************************************************** fatal: [localhost]: FAILED! => {"changed": false, "cmd": "zip -r
> functions/build/build-function.zip", "failed": true, "msg": "[Errno 2]
> No such file or directory", "rc": 2}


The paths are very correct, I don't know what else to check!
the playbook is in a file in the same level as the directory /functions



this is the strtucture of the files:



-- playbook.yml
-- /functions
-- /build
-- /function-package
-- script.py
-- lib


the zip is to be put inside /build







ansible zip






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 13:15







Souad

















asked Jan 3 at 10:51









SouadSouad

1,88653875




1,88653875













  • is there a reason why you do not use the archive module?

    – thopaw
    Jan 3 at 10:55













  • It's not working. I use ansible 2.3 and when I use archive module I get this error: ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

    – Souad
    Jan 3 at 10:59











  • can you give the part of the play using the archive module?

    – thopaw
    Jan 3 at 11:04



















  • is there a reason why you do not use the archive module?

    – thopaw
    Jan 3 at 10:55













  • It's not working. I use ansible 2.3 and when I use archive module I get this error: ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

    – Souad
    Jan 3 at 10:59











  • can you give the part of the play using the archive module?

    – thopaw
    Jan 3 at 11:04

















is there a reason why you do not use the archive module?

– thopaw
Jan 3 at 10:55







is there a reason why you do not use the archive module?

– thopaw
Jan 3 at 10:55















It's not working. I use ansible 2.3 and when I use archive module I get this error: ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

– Souad
Jan 3 at 10:59





It's not working. I use ansible 2.3 and when I use archive module I get this error: ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

– Souad
Jan 3 at 10:59













can you give the part of the play using the archive module?

– thopaw
Jan 3 at 11:04





can you give the part of the play using the archive module?

– thopaw
Jan 3 at 11:04












1 Answer
1






active

oldest

votes


















0














If you're using chdir: functions/function-package on your task, then you're running the zip command inside the functions/function-package directory. That means that the path functions/build/build-function.zip is probably no longer valid, since you're inside a child of the functions/ directory.



Based on the information in your question, the appropriate path is probably ../build/, like this:



- name: build lambda functions
hosts: localhost
- name: Buid Zip Package
command: zip -r ../build/build-function.zip .
args:
chdir: functions/function-package/


Update



If I replicate your directory layout:



$ find *
functions
functions/function-package
functions/function-package/script.py
functions/build
playbook.yml


And run this playbook:



---
- hosts: localhost
gather_facts: false
tasks:
- name: Build Zip Package
command: zip -r ../build/build-function.zip .
args:
chdir: functions/function-package


It works just fine:



$ ansible-playbook playbook.yml
PLAY [localhost] ******************************************************************************

TASK [Build Zip Package] **********************************************************************
changed: [localhost]

PLAY RECAP ************************************************************************************
localhost : ok=1 changed=1 unreachable=0 failed=0


And the .zip file exists as expected:



$ ls -l ./functions/build/build-function.zip
-rw-rw-r--. 1 lars lars 209 Jan 3 08:19 ./functions/build/build-function.zip





share|improve this answer


























  • unfortunately this ../build/ didn't work

    – Souad
    Jan 3 at 13:01













  • Hopefully you understand the idea behind this answer and can apply it to your particular situation.

    – larsks
    Jan 3 at 13:09











  • I did, but I don't know what else to try. It didn't work...

    – Souad
    Jan 3 at 13:11











  • Perhaps you could update your question to show the layout of files?

    – larsks
    Jan 3 at 13:12











  • done, please check the updated question

    – Souad
    Jan 3 at 13:15












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54020860%2fno-such-file-or-directory-when-using-zip-command%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














If you're using chdir: functions/function-package on your task, then you're running the zip command inside the functions/function-package directory. That means that the path functions/build/build-function.zip is probably no longer valid, since you're inside a child of the functions/ directory.



Based on the information in your question, the appropriate path is probably ../build/, like this:



- name: build lambda functions
hosts: localhost
- name: Buid Zip Package
command: zip -r ../build/build-function.zip .
args:
chdir: functions/function-package/


Update



If I replicate your directory layout:



$ find *
functions
functions/function-package
functions/function-package/script.py
functions/build
playbook.yml


And run this playbook:



---
- hosts: localhost
gather_facts: false
tasks:
- name: Build Zip Package
command: zip -r ../build/build-function.zip .
args:
chdir: functions/function-package


It works just fine:



$ ansible-playbook playbook.yml
PLAY [localhost] ******************************************************************************

TASK [Build Zip Package] **********************************************************************
changed: [localhost]

PLAY RECAP ************************************************************************************
localhost : ok=1 changed=1 unreachable=0 failed=0


And the .zip file exists as expected:



$ ls -l ./functions/build/build-function.zip
-rw-rw-r--. 1 lars lars 209 Jan 3 08:19 ./functions/build/build-function.zip





share|improve this answer


























  • unfortunately this ../build/ didn't work

    – Souad
    Jan 3 at 13:01













  • Hopefully you understand the idea behind this answer and can apply it to your particular situation.

    – larsks
    Jan 3 at 13:09











  • I did, but I don't know what else to try. It didn't work...

    – Souad
    Jan 3 at 13:11











  • Perhaps you could update your question to show the layout of files?

    – larsks
    Jan 3 at 13:12











  • done, please check the updated question

    – Souad
    Jan 3 at 13:15
















0














If you're using chdir: functions/function-package on your task, then you're running the zip command inside the functions/function-package directory. That means that the path functions/build/build-function.zip is probably no longer valid, since you're inside a child of the functions/ directory.



Based on the information in your question, the appropriate path is probably ../build/, like this:



- name: build lambda functions
hosts: localhost
- name: Buid Zip Package
command: zip -r ../build/build-function.zip .
args:
chdir: functions/function-package/


Update



If I replicate your directory layout:



$ find *
functions
functions/function-package
functions/function-package/script.py
functions/build
playbook.yml


And run this playbook:



---
- hosts: localhost
gather_facts: false
tasks:
- name: Build Zip Package
command: zip -r ../build/build-function.zip .
args:
chdir: functions/function-package


It works just fine:



$ ansible-playbook playbook.yml
PLAY [localhost] ******************************************************************************

TASK [Build Zip Package] **********************************************************************
changed: [localhost]

PLAY RECAP ************************************************************************************
localhost : ok=1 changed=1 unreachable=0 failed=0


And the .zip file exists as expected:



$ ls -l ./functions/build/build-function.zip
-rw-rw-r--. 1 lars lars 209 Jan 3 08:19 ./functions/build/build-function.zip





share|improve this answer


























  • unfortunately this ../build/ didn't work

    – Souad
    Jan 3 at 13:01













  • Hopefully you understand the idea behind this answer and can apply it to your particular situation.

    – larsks
    Jan 3 at 13:09











  • I did, but I don't know what else to try. It didn't work...

    – Souad
    Jan 3 at 13:11











  • Perhaps you could update your question to show the layout of files?

    – larsks
    Jan 3 at 13:12











  • done, please check the updated question

    – Souad
    Jan 3 at 13:15














0












0








0







If you're using chdir: functions/function-package on your task, then you're running the zip command inside the functions/function-package directory. That means that the path functions/build/build-function.zip is probably no longer valid, since you're inside a child of the functions/ directory.



Based on the information in your question, the appropriate path is probably ../build/, like this:



- name: build lambda functions
hosts: localhost
- name: Buid Zip Package
command: zip -r ../build/build-function.zip .
args:
chdir: functions/function-package/


Update



If I replicate your directory layout:



$ find *
functions
functions/function-package
functions/function-package/script.py
functions/build
playbook.yml


And run this playbook:



---
- hosts: localhost
gather_facts: false
tasks:
- name: Build Zip Package
command: zip -r ../build/build-function.zip .
args:
chdir: functions/function-package


It works just fine:



$ ansible-playbook playbook.yml
PLAY [localhost] ******************************************************************************

TASK [Build Zip Package] **********************************************************************
changed: [localhost]

PLAY RECAP ************************************************************************************
localhost : ok=1 changed=1 unreachable=0 failed=0


And the .zip file exists as expected:



$ ls -l ./functions/build/build-function.zip
-rw-rw-r--. 1 lars lars 209 Jan 3 08:19 ./functions/build/build-function.zip





share|improve this answer















If you're using chdir: functions/function-package on your task, then you're running the zip command inside the functions/function-package directory. That means that the path functions/build/build-function.zip is probably no longer valid, since you're inside a child of the functions/ directory.



Based on the information in your question, the appropriate path is probably ../build/, like this:



- name: build lambda functions
hosts: localhost
- name: Buid Zip Package
command: zip -r ../build/build-function.zip .
args:
chdir: functions/function-package/


Update



If I replicate your directory layout:



$ find *
functions
functions/function-package
functions/function-package/script.py
functions/build
playbook.yml


And run this playbook:



---
- hosts: localhost
gather_facts: false
tasks:
- name: Build Zip Package
command: zip -r ../build/build-function.zip .
args:
chdir: functions/function-package


It works just fine:



$ ansible-playbook playbook.yml
PLAY [localhost] ******************************************************************************

TASK [Build Zip Package] **********************************************************************
changed: [localhost]

PLAY RECAP ************************************************************************************
localhost : ok=1 changed=1 unreachable=0 failed=0


And the .zip file exists as expected:



$ ls -l ./functions/build/build-function.zip
-rw-rw-r--. 1 lars lars 209 Jan 3 08:19 ./functions/build/build-function.zip






share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 3 at 13:20

























answered Jan 3 at 12:13









larskslarsks

122k20204209




122k20204209













  • unfortunately this ../build/ didn't work

    – Souad
    Jan 3 at 13:01













  • Hopefully you understand the idea behind this answer and can apply it to your particular situation.

    – larsks
    Jan 3 at 13:09











  • I did, but I don't know what else to try. It didn't work...

    – Souad
    Jan 3 at 13:11











  • Perhaps you could update your question to show the layout of files?

    – larsks
    Jan 3 at 13:12











  • done, please check the updated question

    – Souad
    Jan 3 at 13:15



















  • unfortunately this ../build/ didn't work

    – Souad
    Jan 3 at 13:01













  • Hopefully you understand the idea behind this answer and can apply it to your particular situation.

    – larsks
    Jan 3 at 13:09











  • I did, but I don't know what else to try. It didn't work...

    – Souad
    Jan 3 at 13:11











  • Perhaps you could update your question to show the layout of files?

    – larsks
    Jan 3 at 13:12











  • done, please check the updated question

    – Souad
    Jan 3 at 13:15

















unfortunately this ../build/ didn't work

– Souad
Jan 3 at 13:01







unfortunately this ../build/ didn't work

– Souad
Jan 3 at 13:01















Hopefully you understand the idea behind this answer and can apply it to your particular situation.

– larsks
Jan 3 at 13:09





Hopefully you understand the idea behind this answer and can apply it to your particular situation.

– larsks
Jan 3 at 13:09













I did, but I don't know what else to try. It didn't work...

– Souad
Jan 3 at 13:11





I did, but I don't know what else to try. It didn't work...

– Souad
Jan 3 at 13:11













Perhaps you could update your question to show the layout of files?

– larsks
Jan 3 at 13:12





Perhaps you could update your question to show the layout of files?

– larsks
Jan 3 at 13:12













done, please check the updated question

– Souad
Jan 3 at 13:15





done, please check the updated question

– Souad
Jan 3 at 13:15




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54020860%2fno-such-file-or-directory-when-using-zip-command%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith