Project

General

Profile

Actions

Bug #5979

closed

Document usage of line replacement in Enforce a file content technique

Added by Dennis Cabooter over 6 years ago. Updated about 6 years ago.

Status:
Released
Priority:
1
Category:
Techniques
Target version:
Severity:
User visibility:
Effort required:
Priority:

Description

Situation:

In file /etc/sysctl.conf:

node 1 has: kernel.shmmax = 1234
node 2 has: kernel.shmmax = 4321
node 3 has: kernel.shmmax = 2143

Actually the value could be anything. And I don't (want to) know what is is.

Now I want to accomplish this:

node 1 has: kernel.shmmax = 5678
node 2 has: kernel.shmmax = 5678
node 3 has: kernel.shmmax = 5678

What I need here is one simple regex that matches:

All lines in sysctl.conf, which start with "kernel.shmmax", followed by a space, followed by an = sign, followed by a space, followed by a number I don't know.

Please provide documentation on how to do this.


Related issues

Has duplicate Rudder - Bug #6431: How to line replacement in Enforce a file content RejectedNicolas CHARLES2015-03-24Actions
Actions #1

Updated by Nicolas CHARLES over 6 years ago

Hi Dennis,

To do that, you need to use the technique enforce a file content, with parameters
Path or file name: /etc/sysctl.conf
Enable the replacement of lines using a regexp: True
Regular expression kernel.shmmax = (?!5678$).*
String used as a remplacement kernel.shmmax = 5678

Note: we are eagerly backslashing backslashes, so \s get replaced by \\s, breaking the regexp, and causing your issue. Sorry about that, i'm opening a ticket for this

Actions #2

Updated by Dennis Cabooter over 6 years ago

Problem solved. Maybe i would be nice to document the way regexes are working within techniques. This (?!5678$).* I really didn't know.

Actions #3

Updated by Nicolas CHARLES about 6 years ago

  • Category set to Techniques
  • Assignee set to Nicolas CHARLES
  • Target version set to 2.10.13
Actions #4

Updated by Nicolas CHARLES about 6 years ago

  • Status changed from New to Pending technical review
  • Assignee changed from Nicolas CHARLES to Benoît PECCATTE
  • Pull Request set to https://github.com/Normation/rudder-techniques/pull/647
Actions #5

Updated by Nicolas CHARLES about 6 years ago

  • Related to deleted (Bug #6431: How to line replacement in Enforce a file content )
Actions #6

Updated by Nicolas CHARLES about 6 years ago

  • Has duplicate Bug #6431: How to line replacement in Enforce a file content added
Actions #7

Updated by Nicolas CHARLES about 6 years ago

  • Status changed from Pending technical review to Pending release
  • % Done changed from 0 to 100
Actions #9

Updated by Vincent MEMBRÉ about 6 years ago

  • Subject changed from Please document usage of line replacement in Enforce a file content technique to Document usage of line replacement in Enforce a file content technique
Actions #10

Updated by Vincent MEMBRÉ about 6 years ago

  • Status changed from Pending release to Released

This bug has been fixed in Rudder 2.10.13, 2.11.10 and 3.0.4 which were released today.

Actions

Also available in: Atom PDF