Puppet: wie man einer vorhandenen Datei eine Zeile hinzufügt

1072
user1670773

Ich versuche, einer vorhandenen Datei /etc/fuse.conf eine Zeile hinzuzufügen. Ich habe es versucht

fügte einen Ordner zwei Ordner unter Modules Verzeichnis hinzu

sudo mkdir /etc/puppet/modules/test sudo mkdir /etc/puppet/modules/test/manifests 

Dann eine test.pp-Datei erstellt und folgende Zeilen hinzugefügt

sudo vim /etc/puppet/modules/test/manifests/test.pp  file { '/etc/fuse.conf': ensure => present, }-> file_line { 'Append a line to /etc/fuse.conf': path => '/etc/fuse.conf', line => 'Want to add this line as a test', } 

Danach habe ich diesen Befehl ausgeführt

puppet apply /etc/puppet/modules/test/manifests/test.pp 

Dann öffnete ich diese Datei /etc/fuse.confund es gab keine Änderung in der Datei. Die Zeile wurde nicht zur Datei hinzugefügt. Ich verstehe nicht, was mir hier fehlt. Wie kann ich das machen? Ich lerne Marionette. Dies ist also nur zu Lernzwecken.

0
Hat der Befehl "Marionette anwenden" eine Ausgabe erzeugt? Könnten Sie es in Ihre Frage aufnehmen? Vielen Dank! Mikhail T. vor 7 Jahren 0
Cross-posted: http://stackoverflow.com/q/36045455/781723, http://serverfault.com/q/764220/111679, http://superuser.com/q/1053789/93541. Bitte [dieselbe Frage nicht auf mehreren Websites posten] (http://meta.stackexchange.com/q/64068). Jede Community sollte eine ehrliche Antwort darauf haben, ohne dass jemandes Zeit verschwendet wird. D.W. vor 7 Jahren 0

1 Antwort auf die Frage

1
Gilad Sharaby

I'm not sure which version of puppet you are using, since you didn't mention it. The "file_name" class belongs to the puppetlabs-stdlib library, so you need to make sure that this module is installed -

puppet module install puppetlabs-stdlib 

also, since you are using a module path, you need to call your file init.pp (not test.pp). Since you are new to writing modules, I suggest you use the puppet module generate command -

puppet module generate module-name --skip-interview 

this will create all you'll need for a new module. don't forget to make sure that the class name is the same as the module's name. In order to run and test this module, use -

puppet apply -e "include <module-name>"