O'Reilly logo

CFEngine 3 Beginner's Guide by Rajneesh

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - configuring Apache virtual hosts from a list of domains in a file

  1. We need to write a promises file so that name base virtual hosts are created automatically once we provide a domain. You may copy the following code snippet to a file named Vhost_config.cf:
    body common control { bundlesequence => { "vhost_config" }; version => "1.0.0"; } bundle agent vhost_config { vars: "host_list" int => readstringarray("vhost_array", "/tmp/virtual_hosts_list", "#.*", ":", "100", "10000"); "index" slist => getindices("vhost_array"); files: "/etc/httpd/conf/httpd.conf" create => "true", edit_line => Insert_vhost("$(index)"); } bundle edit_line Insert_vhost(h) { vars: insert_lines: " <VirtualHost *:80> # Start of Virtual host configuration for $(h) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required