Project

General

Profile

Actions

User story #2428

closed

Create a Technique that allows for arbitrary command execution, and optionnaly execute a command based on the output

Added by Nicolas CHARLES over 12 years ago. Updated about 8 years ago.

Status:
Rejected
Priority:
3
Assignee:
Jonathan CLARKE
Category:
Techniques
Target version:
UX impact:
Suggestion strength:
User visibility:
Effort required:
Name check:
Fix check:
Regression:

Description

It wuold be useful to have a Policy Template that would allow for command execution, with all the warning about the fact that executing commands are risky

And if we could use the output of the command to execute other commands, it would be even better

The use case : check if a database exists, and if not create it (with CFEngine 3.3 it will be easier)
  1. execute a command that check the existance of the database
    su - postgres -c "psql -t -c \"select count(1) from pg_catalog.pg_database where datname = 'foo'\"" 
    

If the output is 0, then it has to be created :

su - postgres -c "psql -t -c \"CREATE TABLE foo ....\"" 

(with the mandatory caution about the " and '

Actions

Also available in: Atom PDF