question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Shell Conditions for all plugins

See original GitHub issue

I’ve seen a lot of people wanting to do things like optional tasks, or only run sets of tasks, machine specific configs, etc.

#96, #44 etc.

I think I might have some level of solution.

Here’s how an implementation might look:

# "Put this only on gaming machines"
- link:
    ~/.steam/someconfig:
      path: gaming/steam/config
      create: false
      condition: [[ -d ~/.steam ]]

Link plugin (and perhaps shell plugin) gets additional directive: condition,shellcond,shellcondition or whatever, which is a command that is executed and the return status is used as a boolean. If shell returns true (retval 0) then perform the operation, else don’t.

#96 i3 Example:

- shell:
  - sudo apt install i3
    condition: ! dpkg -s i3 # using ! as in https://stackoverflow.com/questions/367069/how-can-i-negate-the-return-value-of-a-process
- link:
  ~/.config/i3:
    path: i3
    condition: dpkg -s i3 # success if i3 is installed

#44 Shell vars Example:

- link:
  ~/.somewhere:
    path: something
    condition: [[ ! -z "$INSTALL_SOMETHING" ]]

Could be run as INSTALL_SOMETHING=1 ./install

What’s the feel for a solution somewhat like this?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
arcticicestudiocommented, Feb 2, 2018

Looks like this is related to #88.

1reaction
anishathalyecommented, Oct 17, 2018

A version of this is implemented in #169 / merged in 1b17e8e.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nagios Series: Configuration Tips and Tricks (Shell Edition)
Macro Conditionals: Nagios has a feature called event handlers that allow you to execute programs after a certain check status. Our example uses ......
Read more >
semantic-release/exec - GitHub
All the objects passed to the semantic-release plugins are available as template options. verifyConditionsCmd. Execute a shell command to verify ...
Read more >
Converting Conditional Build Steps to Jenkins Pipeline
The Conditional BuildStep plugin lets users add conditional logic to Freestyle jobs from within the Jenkins web UI. It does this by: Adding...
Read more >
Working with plugins - Ansible Documentation
Plugins are pieces of code that augment Ansible's core functionality. Ansible uses a plugin architecture to enable a rich, flexible and expandable feature...
Read more >
Managing Plugins with Oracle Cloud Agent
Each Oracle Cloud Agent plugin provides functionality related to ... disable individual plugins, as well as start and stop all plugins on an ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found