Bug #8933
closedMulti-line command in post-modification hooks works incorrectly
Added by Dmitry Svyatogorov about 8 years ago. Updated about 5 years ago.
Description
Hooks with dashes (m.b. other chars) are broken till now. E.g.:
Write hook (in my example it is "Download a file from the shared folder" directive for Ubuntu 14.04):
/sbin/initctl 'reload-configuration'; stop bond-check; start bond-check
Then agent logs a couple of error lines:
Sep 1 10:18:01 m630-43 rudder[114618]: CFEngine(agent) rudder Finished command related to promiser '/sbin/initctl 'reload-configuration'; stop bond-check; start bond-check' -- an error occurred, returned 127 Sep 1 10:18:01 m630-43 rudder[114618]: CFEngine(agent) rudder Q: "...in/initctl 'rel": sh: 1: stop: not found#012Q: "...in/initctl 'rel": sh: 1: start: not found
when is running as daemon.
- Note, that "rudder agent run -i" works ok.
Hooks looks like shell scripts and must to work in accordance with shell rules. Otherwise, limitations must be documented.
As for now, hooks text is scrubbing in obscure manner, and then executing selectively.
for example, in:
cat <<EOF > /path/to/file some line 1 other line etc. EOF
Spaces became broken.
Updated by Vincent MEMBRÉ about 8 years ago
From what i read, it cannot find "start" and "stop" commands, cfengine needs full path to be set when runnign commands (maybe it's ok when running manually with -i as it can inherit your current PATH )
Can you try to add the full path to start and stop ??
Updated by Dmitry Svyatogorov about 8 years ago
Thanks, Vincent. Hook works so:
Sep 1 12:33:36 m630-31 bond-check: ** BRAKE Sep 1 12:33:36 m630-31 rudder[178783]: CFEngine(agent) rudder Q: "...in/initctl 'rel": bond-check stop/waiting#012Q: "...in/initctl 'rel": bond-check start/running, process 181744 Sep 1 12:33:36 m630-31 bond-check: ** START checking (*.*.*.* *.*.*.*) on bond0 from br-bond0-ext. Master=em1, slaves=(em2 em1)
- The second part about "scrubbing" relates to multi-line constructs like
cat <<EOF > /path/to/file some line 1 other line etc. EOF
At least, spaces became broken.
Updated by Vincent MEMBRÉ about 8 years ago
- Target version changed from 3.2.7 to 3.2.8
Updated by Vincent MEMBRÉ about 8 years ago
- Target version changed from 3.2.8 to 3.2.9
Updated by Vincent MEMBRÉ about 8 years ago
- Target version changed from 3.2.9 to 3.2.10
Updated by Vincent MEMBRÉ almost 8 years ago
- Target version changed from 3.2.10 to 3.2.11
Updated by Vincent MEMBRÉ almost 8 years ago
- Target version changed from 3.2.11 to 339
Updated by Vincent MEMBRÉ almost 8 years ago
- Target version changed from 339 to 4.0.4
Updated by Benoît PECCATTE over 7 years ago
- Severity set to Major - prevents use of part of Rudder | no simple workaround
- User visibility set to Operational - other Techniques | Technique editor | Rudder settings
Updated by Vincent MEMBRÉ over 7 years ago
- Target version changed from 4.0.4 to 4.0.5
- Priority changed from 33 to 32
Updated by Vincent MEMBRÉ over 7 years ago
- Target version changed from 4.0.5 to 4.0.6
Updated by Vincent MEMBRÉ over 7 years ago
- Target version changed from 4.0.6 to 4.0.7
Updated by Vincent MEMBRÉ over 7 years ago
- Target version changed from 4.0.7 to 357
- Priority changed from 32 to 31
Updated by Alexis Mousset over 7 years ago
- Target version changed from 357 to 4.1.6
Updated by Vincent MEMBRÉ over 7 years ago
- Target version changed from 4.1.6 to 4.1.7
- Priority changed from 45 to 43
Updated by Vincent MEMBRÉ about 7 years ago
- Target version changed from 4.1.7 to 4.1.8
Updated by Vincent MEMBRÉ about 7 years ago
- Target version changed from 4.1.8 to 4.1.9
Updated by Vincent MEMBRÉ almost 7 years ago
- Target version changed from 4.1.9 to 4.1.10
Updated by Vincent MEMBRÉ almost 7 years ago
- Target version changed from 4.1.10 to 4.1.11
Updated by Vincent MEMBRÉ over 6 years ago
- Target version changed from 4.1.11 to 4.1.12
Updated by Vincent MEMBRÉ over 6 years ago
- Target version changed from 4.1.12 to 4.1.13
Updated by Vincent MEMBRÉ over 6 years ago
- Target version changed from 4.1.13 to 4.1.14
Updated by Benoît PECCATTE over 6 years ago
- Target version changed from 4.1.14 to 4.1.15
Updated by Vincent MEMBRÉ about 6 years ago
- Target version changed from 4.1.15 to 4.1.16
Updated by Vincent MEMBRÉ about 6 years ago
- Target version changed from 4.1.16 to 4.1.17
Updated by François ARMAND about 6 years ago
- Translation missing: en.field_tag_list set to community
- Priority changed from 43 to 0
Updated by François ARMAND about 6 years ago
- Subject changed from Post-modification hooks works incorrectly to Multi-line command in post-modification hooks works incorrectly
- Description updated (diff)
Updated by François ARMAND about 6 years ago
I'm wondering if the problem with the multi-line edit is not a duplicate of #8473 ?
Updated by François ARMAND about 6 years ago
- Related to Enhancement #8473: Form fields in Directive edit are eating leading spaces. added
Updated by Vincent MEMBRÉ almost 6 years ago
- Target version changed from 4.1.17 to 4.1.18
Updated by Vincent MEMBRÉ almost 6 years ago
- Target version changed from 4.1.18 to 4.1.19
Updated by Alexis Mousset almost 6 years ago
- Target version changed from 4.1.19 to 4.1.20
Updated by François ARMAND over 5 years ago
- Target version changed from 4.1.20 to 4.1.21
Updated by Vincent MEMBRÉ over 5 years ago
- Target version changed from 4.1.21 to 4.1.22
Updated by Vincent MEMBRÉ over 5 years ago
- Target version changed from 4.1.22 to 4.1.23
Updated by Vincent MEMBRÉ over 5 years ago
- Target version changed from 4.1.23 to 4.1.24
Updated by Vincent MEMBRÉ over 5 years ago
- Target version changed from 4.1.24 to 588
Updated by Félix DALLIDET over 5 years ago
- Target version changed from 588 to 5.0.13
Still relevant, the brokens spaces come from the indenting in our technique, removing spaces before the variable holding the posthook value should be enough.
However, I could not use properly the EOF syntax within the posthook, cfengine seems to already feed the command with an EOF.
So you should use:
cat <<EOF > /path/to/file some line 1 other line etc.
instead
Updated by Félix DALLIDET over 5 years ago
- Status changed from New to In progress
- Assignee set to Félix DALLIDET
Updated by Félix DALLIDET over 5 years ago
- Status changed from In progress to Pending technical review
- Assignee changed from Félix DALLIDET to Nicolas CHARLES
- Pull Request set to https://github.com/Normation/rudder-techniques/pull/1457
Updated by Félix DALLIDET over 5 years ago
- Related to Bug #15174: Rudder directives posthook can not support multilines command execution added
Updated by Félix DALLIDET over 5 years ago
- Status changed from Pending technical review to Pending release
Applied in changeset rudder-techniques|5fb10363b1b7116a579121610da3d05881ed4558.
Updated by Vincent MEMBRÉ about 5 years ago
- Status changed from Pending release to Released
This bug has been fixed in Rudder 5.0.13 which was released today.