LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-05-2019, 10:27 AM   #1
Ladowny
Member
 
Registered: Oct 2006
Distribution: Debian, OpenBSD, FreeBSD
Posts: 53

Rep: Reputation: 14
CFEngine3 enabling apache modules and configs on Debian


Hi

I am looking for the best way of automating enabling apache modules and configs. In Debian this is done with a2enmod and a2enconf commands which create a symlink in conf-enabled and mods-enabled folders.

EnableModules.cf
Code:
bundle agent enable_modules
{
  classes:
      "hasApache24" expression => fileexists("/usr/sbin/apache2ctl");
      "mod_headers_enabled" expression => islink("/etc/apache2/mods-enabled/headers.load");

  commands:
	hasApache24.!mod_headers_enabled::
      "/usr/sbin/a2enmod headers"
      comment => "enabling apache module headers";



}
and when I run it

Code:
~# cf-agent -b enable_modules -f ./EnableModules.cf
  notice: Q: "...in/a2enmod head": Enabling module headers.
Q: "...in/a2enmod head": To activate the new configuration, you need to run:
Q: "...in/a2enmod head":   systemctl restart apache2
~# l /etc/apache2/mods-enabled/headers.load
lrwxrwxrwx 1 root root 30 Jun  5 15:46 /etc/apache2/mods-enabled/headers.load -> ../mods-available/headers.load
But that requires defining a class for each module to be enabled


I'd like to have a list

EnableModules2.cf

Code:
bundle agent enable_modules2
{
  classes:
      "hasApache24" expression => fileexists("/usr/sbin/apache2ctl");

  vars:
  "apache_modules"
    handle => "Apache_Modules",
    comment => "List of addiional Apache modules",
    slist => { "headers", "rewrite", "expires", "mime", "deflate", "unique_id", "ssl", "allowmethods" };


commands:
  # adding Apache modules

    hasApache24::
      "/usr/sbin/a2enmod $(apache_modules)"
      comment => "enabling apache modules $(apache_modules)";


}

but that repairs promises on every run


Code:
~# cf-agent -K -b enable_modules2 -f ./EnableModules2.cf
  notice: Q: "...in/a2enmod head": Module headers already enabled
  notice: Q: "...in/a2enmod rewr": Module rewrite already enabled
  notice: Q: "...in/a2enmod expi": Module expires already enabled
  notice: Q: "...in/a2enmod mime": Module mime already enabled
  notice: Q: "...in/a2enmod defl": Considering dependency filter for deflate:
Q: "...in/a2enmod defl": Module filter already enabled
Q: "...in/a2enmod defl": Module deflate already enabled
  notice: Q: "...in/a2enmod uniq": Module unique_id already enabled
  notice: Q: "...in/a2enmod ssl": Considering dependency setenvif for ssl:
Q: "...in/a2enmod ssl": Module setenvif already enabled
Q: "...in/a2enmod ssl": Considering dependency mime for ssl:
Q: "...in/a2enmod ssl": Module mime already enabled
Q: "...in/a2enmod ssl": Considering dependency socache_shmcb for ssl:
Q: "...in/a2enmod ssl": Module socache_shmcb already enabled
Q: "...in/a2enmod ssl": Module ssl already enabled
  notice: Q: "...in/a2enmod allo": Module allowmethods already enabled

Is there any better way to enable apache2 modules and configs in CFEngine3? I was hoping to have something similar to installing packages, but could not find any example.

Thanks

Greg

Last edited by Ladowny; 06-05-2019 at 05:29 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
NOOB: Apache Configs (Everythiung) Daveyon Red Hat 1 02-25-2009 07:57 AM
Enabling ~/.fluxbox configs tip echowarpt Slackware 8 02-27-2007 04:32 PM
Red Hat DNS and Apache configs woolymooly Linux - Software 8 09-15-2003 01:15 AM
Re: modprobe: Note: /etc/modules.conf is more recent than lib/modules/2.4.9/modules.d Andy.M Linux - General 1 01-24-2002 01:50 AM
Re: modprobe: Note: /etc/modules.conf is more recent than lib/modules/2.4.9/modules.d Andy.M Linux - Newbie 2 01-24-2002 01:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration