how to run command that cannot create files?

33 views
Skip to first unread message

Philipp Ewald

unread,
Nov 8, 2022, 11:55:30 AM11/8/22
to Ansible Development
I dont want to create a script placing files or removing files.... just to run one command...

any ideas?


--
Philipp Ewald
Administrator


Tom Davison

unread,
Nov 8, 2022, 12:01:21 PM11/8/22
to Philipp Ewald, Ansible Development
The ansible file module?

--
You received this message because you are subscribed to the Google Groups "Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/fee1826e-998f-537c-598e-42fb41ffc01c%40digionline.de.

Philipp Ewald

unread,
Nov 8, 2022, 12:17:46 PM11/8/22
to ansibl...@googlegroups.com
:)

try this to explain new employees :D you need to place a file there, otherwise the command will be execute again :DDDDD

for me this is a bug

but ok i will do it with extra steps.... if everyone else is happy with that solution, i'm fine with that

Am 08.11.22 um 18:01 schrieb Tom Davison:
--
Philipp Ewald
Administrator

DigiOnline GmbH, Probsteigasse 15 - 19, 50670 Köln
E-Mail: philip...@digionline.de

AG Köln HRB 27711, St.-Nr. 5215 5811 0640
Geschäftsführer: Werner Grafenhain

Informationen zum Datenschutz: www.digionline.de/ds

Matt Martz

unread,
Nov 8, 2022, 1:15:23 PM11/8/22
to Philipp Ewald, ansibl...@googlegroups.com
- shell:
    cmd: do_something && touch /etc/do_something/done
    creates: /etc/do_something_done

Easy peasy.  This was recommended before, although no one explicitly wrote it out.

Otherwise, do a task before, to actually evaluate whether you need to run the command in the first place, instead of relying on the existence of a file.



--
Matt Martz
@sivel
sivel.net

Brian Coca

unread,
Nov 8, 2022, 1:35:55 PM11/8/22
to Matt Martz, Philipp Ewald, ansibl...@googlegroups.com
Tracking files that are not the normal side effect of a command are a
poor way to track if a command was executed, the best way is to track
the expected side effect of such a command (creates/removes does this
by assuming those files are created/removed by the command's
execution). There are other side effects that you can track, but hard
to build them all into the command/shell modules (open port/service
running/package installed/etc) but there are plenty of other actions
that can query this.
--
----------
Brian Coca

Brian Coca

unread,
Nov 8, 2022, 1:37:29 PM11/8/22
to Matt Martz, Philipp Ewald, ansibl...@googlegroups.com
Also, if the built in command does not do exactly what you want, you
are free to create your own custom version, it just not make sense for
this in the core offering.

--
----------
Brian Coca

Philipp Ewald

unread,
Nov 9, 2022, 4:46:46 AM11/9/22
to Matt Martz, ansibl...@googlegroups.com
> - shell:
> cmd: do_something && touch /etc/do_something/done
> creates: /etc/do_something_done

This is the best solution. But why does i need to ask the Mailing list do get this? why ansible cant do this by itself? or why is this solution not in documentation?

> Otherwise, do a task before, to actually evaluate whether you need to run
> the command in the first place, instead of relying on the existence of a
> file.

for me its funny how complicated it is to just run a command... (known workarounds are not easy to access...)



But OK, everybody + developer are fine with that bug




Am 08.11.22 um 19:14 schrieb Matt Martz:
Reply all
Reply to author
Forward
0 new messages