SoFunction
Updated on 2025-03-10

How to replace string in file using puppet

puppet

puppet is a centralized configuration management system for Linux, Unix, and Windows platforms. It uses its own puppet description language to manage configuration files, users, cron tasks, software packages, system services, etc. puppet calls these system entities resources. The design goal of puppet is to simplify the management of these resources and properly handle the dependencies between resources.

puppet adopts a C/S star-shaped structure, and all clients interact with one or several servers. Each client cycle (default half an hour) sends a request to the server to obtain its latest configuration information and ensures that it is synchronized with the configuration information. Each puppet client connects to the server side every half hour (can be set), downloads the latest configuration file, and configures the client strictly according to the configuration file. After the configuration is completed, the puppet client can feedback a message to the server side. If an error occurs, a message will also be feedback to the server side.

document

<VirtualHost :80>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.) https://%{SERVER_NAME}/$1 [R,L]

Proposition

substitute the * with the $fqdn facter variable on the first line

Answer

include stdlib
$fqdn = $facts[‘fqdn']
file_line { ‘virtual_host':
ensure => present,
path => ‘/path/to/',
line => “<VirtualHost ${fqdn}:80>”,
match => ‘<VirtualHost *:80>',
}

Summarize

The above is the entire content of this article. I hope that the content of this article has certain reference value for your study or work. Thank you for your support. If you want to know more about it, please see the relevant links below