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;
}
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
add a comment |
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
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
add a comment |
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
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
ansible zip
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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
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
|
show 3 more comments
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
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
|
show 3 more comments
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
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
|
show 3 more comments
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
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
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
|
show 3 more comments
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
|
show 3 more comments
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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

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