Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to create extra LogDir and using apache/vhosts/standard.sls and hanling apache-reload? #145

Open
Sylvain303 opened this issue Jun 10, 2016 · 0 comments

Comments

@Sylvain303
Copy link

I would like to create some extra dir for apache:sites, managed through apache.vhosts.standard state.

I would like to add log_dir creation before apache is restarted, dir are created by an external state create_dir.sls

But when running state.highstate, apache is complaining that error reloading, because a2ensite is launching apache-reload before LogDir are created.

What would be the way to add LogDir creation before vhosts?
I don't necessarily need to alter the formula, I just want to introduce my own step.

pillar top.sls

# Pillar top inclusions
base:
  '*':
    - customers
  'web*':
    - webserver # stantdard pillar config
    - auto.webconfig # sites are separated here

I added a LogDir key for that purpose (could be dirname calculated, but that's another story)

auto/webconfig.sls

apache:
  sites:
    client1-domain.fr:
      # template_file: salt://webserver/vhosts/minimal.tmpl
      ServerName: client1-domain.fr
      ServerAlias: www.client1-domain.fr
      ServerAdmin: webmaster@webmaster.com

      LogLevel: warn
      LogDir: /home/client1/logs
      ErrorLog: /home/client1/logs/error.log
      CustomLog: /home/client1/logs/access.log

      DocumentRoot: /home/client1/vhost/www

      Directory:
        default:
          Options: -Indexes +FollowSymLinks
          Order: allow,deny
          Allow: from all
          Require: all granted
          AllowOverride: None

state

top.sls

base:
  '*':
    - fail2ban
    - salt-minion
  'web*':
    - apache
    - apache.modules
    - apache.mod_fastcgi
    - webserver.php-fpm
    - webserver.create_dir
    - apache.vhosts.standard

webserver/create_dir.sls

# create users dir not created by the formula
#
{% for id, site in salt['pillar.get']('apache:sites', {}).items() %}
{% set logdir = site.get('LogDir') %}

{{ id }}-logdir:
  file.directory:
    - unless: test -d {{ logdir }}
    - name: {{ logdir }}
    - makedirs: True
    - allow_symlink: True
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant