Issue with `copy` module with force=no #2847

Closed
gw0 opened this Issue May 5, 2013 · 5 comments

Projects

None yet

3 participants

@gw0
Contributor
gw0 commented May 5, 2013

It seems that either the documentation for copy for force=no is wrong or there is a regression (as can be seen from the example where a new file should be created if it doesn't exist):

$ ansible all -vvv -m copy -a 'content="foobar" dest=/tmp/foobar force=no'
<xxx> ESTABLISH CONNECTION FOR USER: root on PORT 22 TO xxx
<xxx> EXEC /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-1367790824.34-156857765693302 && chmod a+rx $HOME/.ansible/tmp/ansible-1367790824.34-156857765693302 && echo $HOME/.ansible/tmp/ansible-1367790824.34-156857765693302'
<xxx> EXEC /bin/sh -c 'rc=0; [ -r "/tmp/foobar" ] || rc=2; [ -f "/tmp/foobar" ] || rc=1; [ -d "/tmp/foobar" ] && rc=3; (/usr/bin/md5sum /tmp/foobar 2>/dev/null) || (/sbin/md5sum -q /tmp/foobar 2>/dev/null) || (/usr/bin/digest -a md5 /tmp/foobar 2>/dev/null) || (/sbin/md5 -q /tmp/foobar 2>/dev/null) || (/usr/bin/md5 -n /tmp/foobar 2>/dev/null) || (/bin/md5 -q /tmp/foobar 2>/dev/null) || (echo "${rc}  /tmp/foobar")'
xxx | success >> {
    "changed": false
}

$ ansible all -m shell -a 'ls -al /tmp/foobar'
xxx | FAILED | rc=2 >>
ls: cannot access /tmp/foobar: No such file or directory
@mpdehaan
Contributor
mpdehaan commented May 5, 2013

So can you please supply information about what version of ansible you are using?

I am not sure 'content' with force=no makes sense, that may be the underlying problem.

@bcoca
Member
bcoca commented May 5, 2013

I reproduced from the latest checkout, reading the code this 'should' work.

force=no should only 'not write' when file exists, so the example should
create a file with the content.

On Sun, May 5, 2013 at 7:10 PM, Michael DeHaan notifications@github.comwrote:

So can you please supply information about what version of ansible you are
using?

I am not sure 'content' with force=no makes sense, that may be the
underlying problem.


Reply to this email directly or view it on GitHubhttps://github.com/ansible/ansible/issues/2847#issuecomment-17461167
.

Brian Coca
Stultorum infinitus est numerus
0110000101110010011001010110111000100111011101000010000001111001011011110111010100100000011100110110110101100001011100100111010000100001
Pedo mellon a minno

@mpdehaan
Contributor
mpdehaan commented May 6, 2013

So it's only an issue with "content" and "force=no" specified, right?

(i.e. not normal force=no?)

On Sun, May 5, 2013 at 7:17 PM, Brian Coca notifications@github.com wrote:

I reproduced from the latest checkout, reading the code this 'should'
work.

force=no should only 'not write' when file exists, so the example should
create a file with the content.

On Sun, May 5, 2013 at 7:10 PM, Michael DeHaan notifications@github.comwrote:

So can you please supply information about what version of ansible you
are
using?

I am not sure 'content' with force=no makes sense, that may be the
underlying problem.


Reply to this email directly or view it on GitHub<
https://github.com/ansible/ansible/issues/2847#issuecomment-17461167>
.

Brian Coca
Stultorum infinitus est numerus
0110000101110010011001010110111000100111011101000010000001111001011011110111010100100000011100110110110101100001011100100111010000100001

Pedo mellon a minno


Reply to this email directly or view it on GitHubhttps://github.com/ansible/ansible/issues/2847#issuecomment-17461272
.

@bcoca
Member
bcoca commented May 6, 2013

Yes, corner case, but it should work unless I am reading code and docs
wrong. Need to debug, but wont have time till tonight

@mpdehaan
Contributor

This was fixed a while back, forgot to close ticket.

Tested and works for me fine on latest 1.2.

Thanks!

@mpdehaan mpdehaan closed this May 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment