How to get Puppet exec to cleanup directory on failure?

Andy Shinn

I am trying to find a way to run an exec if another exec failed (so I can cleanup the directory the first exec created).

My scenario is:

  1. The exec creates a directory but does not fully finish setting it up (fails for network error).
  2. The exec uses creates => $target_dir param so subsequent runs will not try again to setup the folder.
  3. The Puppet manifest is applied again after the failure and the exec is skipped.

I'd love to remove the directory (maybe using file type) if the previous exec was a failure. I know this is similar to http://ask.puppetlabs.com/question/14726/run-exec-only-if-another-exec-ran/ and run Exec only if another Exec ran. But I only want to notify on failure (maybe exit other than 0).

Any ideas how I can accomplish this?

Mateusz M.

What you can easily do within exec is:

Exec { 'exec_name':
    cmd     => "${some_command} || rm -rf ${directory}",
    creates => $directory,
}

where ${some_command} is your actual command.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to execute a cleanup script on exec-maven-plugin:exec failure?

From Dev

exec command unless directory exists in puppet

From Java

Puppet: how to remove a directory and everything in it

From Dev

How to check if a directory exists in puppet

From Dev

How to change template directory in puppet

From Dev

How to use return value from a Puppet exec?

From Dev

Puppet, how to use the exec return value as a trigger?

From Dev

Puppet, how to use the exec return value as a trigger?

From Dev

Get Temp Directory on Windows using Puppet

From Dev

How to get directory of exec files of any commands on terminal in C?

From Java

Fixing a systemd service 203/EXEC failure (no such file or directory)

From Dev

How to include modules from a different directory in puppet

From Dev

Why is there two types of Puppet 'Exec' and Puppet 'exec'

From Dev

Why is there two types of Puppet 'Exec' and Puppet 'exec'

From Dev

how can I run sudo commands as exec resources in puppet

From Dev

How do I run a puppet exec if a condition met?

From Dev

Puppet Exec what "<| |>" means?

From Dev

Puppet Exec with no command attribute

From Dev

Puppet exec not executed

From Dev

Puppet exec not executed

From Dev

Ansible: Perform Cleanup on Task Failure

From Dev

mvn release:prepare failure cleanup

From Dev

cleanup tmp directory with carrierwave

From Dev

How to get /etc/hosts entries in puppet?

From Dev

How to delete all files in a directory except some globs using Puppet?

From Dev

How can I refer to the current puppet module's files directory?

From Dev

How to specify R CMD exec directory?

From Dev

Fixing a systemd service 203/EXEC failure (no such file or directory) while starting nodepool-launcher on centos 7

From Dev

Automatically cleanup tmp directory in Unix

Related Related

  1. 1

    How to execute a cleanup script on exec-maven-plugin:exec failure?

  2. 2

    exec command unless directory exists in puppet

  3. 3

    Puppet: how to remove a directory and everything in it

  4. 4

    How to check if a directory exists in puppet

  5. 5

    How to change template directory in puppet

  6. 6

    How to use return value from a Puppet exec?

  7. 7

    Puppet, how to use the exec return value as a trigger?

  8. 8

    Puppet, how to use the exec return value as a trigger?

  9. 9

    Get Temp Directory on Windows using Puppet

  10. 10

    How to get directory of exec files of any commands on terminal in C?

  11. 11

    Fixing a systemd service 203/EXEC failure (no such file or directory)

  12. 12

    How to include modules from a different directory in puppet

  13. 13

    Why is there two types of Puppet 'Exec' and Puppet 'exec'

  14. 14

    Why is there two types of Puppet 'Exec' and Puppet 'exec'

  15. 15

    how can I run sudo commands as exec resources in puppet

  16. 16

    How do I run a puppet exec if a condition met?

  17. 17

    Puppet Exec what "<| |>" means?

  18. 18

    Puppet Exec with no command attribute

  19. 19

    Puppet exec not executed

  20. 20

    Puppet exec not executed

  21. 21

    Ansible: Perform Cleanup on Task Failure

  22. 22

    mvn release:prepare failure cleanup

  23. 23

    cleanup tmp directory with carrierwave

  24. 24

    How to get /etc/hosts entries in puppet?

  25. 25

    How to delete all files in a directory except some globs using Puppet?

  26. 26

    How can I refer to the current puppet module's files directory?

  27. 27

    How to specify R CMD exec directory?

  28. 28

    Fixing a systemd service 203/EXEC failure (no such file or directory) while starting nodepool-launcher on centos 7

  29. 29

    Automatically cleanup tmp directory in Unix

HotTag

Archive