Project

General

Profile

Bug #8933

Multi-line command in post-modification hooks works incorrectly

Added by Dmitry Svyatogorov about 3 years ago. Updated 2 months ago.

Status:
Released
Priority:
N/A
Category:
Techniques
Target version:
Severity:
Major - prevents use of part of Rudder | no simple workaround
User visibility:
Operational - other Techniques | Technique editor | Rudder settings
Effort required:
Priority:
0
Tags:

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.


Related issues

Related to Rudder - Bug #8473: Form fields in Directive edit are eating leading spaces.NewActions
Related to Rudder - Bug #15174: Rudder directives posthook can not support multilines command executionReleasedActions

Associated revisions

Revision 5fb10363 (diff)
Added by Félix DALLIDET 4 months ago

Fixes #8933: Multi-line command in post-modification hooks works incorrectly

History

#1

Updated by Vincent MEMBRÉ about 3 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 ??

#2

Updated by Dmitry Svyatogorov about 3 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.
#3

Updated by Vincent MEMBRÉ about 3 years ago

  • Target version changed from 3.2.7 to 3.2.8
#4

Updated by Vincent MEMBRÉ about 3 years ago

  • Target version changed from 3.2.8 to 3.2.9
#5

Updated by Vincent MEMBRÉ about 3 years ago

  • Target version changed from 3.2.9 to 3.2.10
#6

Updated by Vincent MEMBRÉ almost 3 years ago

  • Target version changed from 3.2.10 to 3.2.11
#7

Updated by Vincent MEMBRÉ over 2 years ago

  • Target version changed from 3.2.11 to 339
#8

Updated by Vincent MEMBRÉ over 2 years ago

  • Target version changed from 339 to 4.0.4
#9

Updated by Benoît PECCATTE over 2 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
#11

Updated by Benoît PECCATTE over 2 years ago

  • Priority set to 33
#12

Updated by Vincent MEMBRÉ over 2 years ago

  • Target version changed from 4.0.4 to 4.0.5
  • Priority changed from 33 to 32
#13

Updated by Vincent MEMBRÉ over 2 years ago

  • Target version changed from 4.0.5 to 4.0.6
#14

Updated by Vincent MEMBRÉ over 2 years ago

  • Target version changed from 4.0.6 to 4.0.7
#15

Updated by Vincent MEMBRÉ over 2 years ago

  • Target version changed from 4.0.7 to 357
  • Priority changed from 32 to 31
#16

Updated by Benoît PECCATTE over 2 years ago

  • Priority changed from 31 to 45
#17

Updated by Alexis MOUSSET over 2 years ago

  • Target version changed from 357 to 4.1.6
#18

Updated by Vincent MEMBRÉ over 2 years ago

  • Target version changed from 4.1.6 to 4.1.7
  • Priority changed from 45 to 43
#19

Updated by Vincent MEMBRÉ about 2 years ago

  • Target version changed from 4.1.7 to 4.1.8
#20

Updated by Vincent MEMBRÉ about 2 years ago

  • Target version changed from 4.1.8 to 4.1.9
#21

Updated by Vincent MEMBRÉ almost 2 years ago

  • Target version changed from 4.1.9 to 4.1.10
#22

Updated by Vincent MEMBRÉ over 1 year ago

  • Target version changed from 4.1.10 to 4.1.11
#23

Updated by Vincent MEMBRÉ over 1 year ago

  • Target version changed from 4.1.11 to 4.1.12
#24

Updated by Vincent MEMBRÉ over 1 year ago

  • Target version changed from 4.1.12 to 4.1.13
#25

Updated by Vincent MEMBRÉ over 1 year ago

  • Target version changed from 4.1.13 to 4.1.14
#26

Updated by Benoît PECCATTE over 1 year ago

  • Target version changed from 4.1.14 to 4.1.15
#27

Updated by Vincent MEMBRÉ about 1 year ago

  • Target version changed from 4.1.15 to 4.1.16
#28

Updated by Vincent MEMBRÉ about 1 year ago

  • Target version changed from 4.1.16 to 4.1.17
#29

Updated by François ARMAND about 1 year ago

  • Tags set to community
  • Priority changed from 43 to 0
#30

Updated by François ARMAND 12 months ago

  • Subject changed from Post-modification hooks works incorrectly to Multi-line command in post-modification hooks works incorrectly
  • Description updated (diff)
#31

Updated by François ARMAND 12 months ago

I'm wondering if the problem with the multi-line edit is not a duplicate of #8473 ?

#32

Updated by François ARMAND 12 months ago

  • Related to Bug #8473: Form fields in Directive edit are eating leading spaces. added
#33

Updated by Vincent MEMBRÉ 12 months ago

  • Target version changed from 4.1.17 to 4.1.18
#34

Updated by Vincent MEMBRÉ 10 months ago

  • Target version changed from 4.1.18 to 4.1.19
#35

Updated by Alexis MOUSSET 10 months ago

  • Target version changed from 4.1.19 to 4.1.20
#36

Updated by François ARMAND 9 months ago

  • Target version changed from 4.1.20 to 4.1.21
#37

Updated by Vincent MEMBRÉ 7 months ago

  • Target version changed from 4.1.21 to 4.1.22
#38

Updated by Vincent MEMBRÉ 6 months ago

  • Target version changed from 4.1.22 to 4.1.23
#39

Updated by Vincent MEMBRÉ 6 months ago

  • Target version changed from 4.1.23 to 4.1.24
#40

Updated by Vincent MEMBRÉ 4 months ago

  • Target version changed from 4.1.24 to 4.1.25
#41

Updated by Félix DALLIDET 4 months ago

  • Target version changed from 4.1.25 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

#42

Updated by Félix DALLIDET 4 months ago

  • Status changed from New to In progress
  • Assignee set to Félix DALLIDET
#43

Updated by Félix DALLIDET 4 months 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
#44

Updated by Félix DALLIDET 4 months ago

  • Related to Bug #15174: Rudder directives posthook can not support multilines command execution added
#45

Updated by Félix DALLIDET 4 months ago

  • Status changed from Pending technical review to Pending release
#48

Updated by Vincent MEMBRÉ 2 months ago

  • Status changed from Pending release to Released

This bug has been fixed in Rudder 5.0.13 which was released today.

Also available in: Atom PDF