Add default user/group attributes as required by some states

This commit is contained in:
Javier Bértoli 2017-03-29 07:32:18 -03:00
parent 7d5e588b6e
commit 475fb8347e
7 changed files with 32 additions and 10 deletions

View File

@ -1,3 +1,4 @@
{%- from "apache/map.jinja" import apache with context -%}
# Managed by saltstack # Managed by saltstack
# envvars - default environment variables for apache2ctl # envvars - default environment variables for apache2ctl
@ -15,8 +16,8 @@ fi
# Since there is no sane way to get the parsed apache2 config in scripts, some # Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl, # settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc. # /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
export APACHE_RUN_USER={{ salt['pillar.get']('apache:user', 'www-data') }} export APACHE_RUN_USER={{ apache.user }}
export APACHE_RUN_GROUP={{ salt['pillar.get']('apache:group', 'www-data') }} export APACHE_RUN_GROUP={{ apache.group }}
export APACHE_PID_FILE=/var/run/apache2$SUFFIX.pid export APACHE_PID_FILE=/var/run/apache2$SUFFIX.pid
export APACHE_RUN_DIR=/var/run/apache2$SUFFIX export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX

View File

@ -1,3 +1,4 @@
{%- from "apache/map.jinja" import apache with context -%}
# Managed by saltstack # Managed by saltstack
# envvars - default environment variables for apache2ctl # envvars - default environment variables for apache2ctl
@ -15,8 +16,8 @@ fi
# Since there is no sane way to get the parsed apache2 config in scripts, some # Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl, # settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc. # /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
export APACHE_RUN_USER={{ salt['pillar.get']('apache:user', 'www-data') }} export APACHE_RUN_USER={{ apache.user }}
export APACHE_RUN_GROUP={{ salt['pillar.get']('apache:group', 'www-data') }} export APACHE_RUN_GROUP={{ apache.group }}
# temporary state file location. This might be changed to /run in Wheezy+1 # temporary state file location. This might be changed to /run in Wheezy+1
export APACHE_PID_FILE=/var/run/apache2/apache2$SUFFIX.pid export APACHE_PID_FILE=/var/run/apache2/apache2$SUFFIX.pid
export APACHE_RUN_DIR=/var/run/apache2$SUFFIX export APACHE_RUN_DIR=/var/run/apache2$SUFFIX

View File

@ -1,3 +1,4 @@
{%- from "apache/map.jinja" import apache with context -%}
# Managed by saltstack # Managed by saltstack
# envvars - default environment variables for apache2ctl # envvars - default environment variables for apache2ctl
@ -7,8 +8,8 @@ unset HOME
APACHE_CONFDIR=/usr/local/etc/apache24 APACHE_CONFDIR=/usr/local/etc/apache24
export APACHE_RUN_USER={{ salt['pillar.get']('apache:user', 'www') }} export APACHE_RUN_USER={{ apache.user }}
export APACHE_RUN_GROUP={{ salt['pillar.get']('apache:group', 'www') }} export APACHE_RUN_GROUP={{ apache.group }}
export APACHE_RUN_DIR={{ salt['pillar.get']('apache:run_dir', '/var/run') }} export APACHE_RUN_DIR={{ salt['pillar.get']('apache:run_dir', '/var/run') }}
## The locale used by some modules like mod_dav ## The locale used by some modules like mod_dav

View File

@ -3,6 +3,13 @@
apache: apache:
pkg.installed: pkg.installed:
- name: {{ apache.server }} - name: {{ apache.server }}
group.present:
- name: {{ apache.group }}
- system: True
user.present:
- name: {{ apache.user }}
- gid: {{ apache.group }}
- system: True
service.running: service.running:
- name: {{ apache.service }} - name: {{ apache.service }}
- enable: True - enable: True

View File

@ -5,6 +5,8 @@
'Gentoo': { 'Gentoo': {
'server': 'www-servers/apache', 'server': 'www-servers/apache',
'service': 'apache2', 'service': 'apache2',
'user': 'apache',
'group': 'apache',
'configfile': '/etc/apache2/httpd.conf', 'configfile': '/etc/apache2/httpd.conf',
'mod_wsgi': 'www-apache/mod_wsgi', 'mod_wsgi': 'www-apache/mod_wsgi',
@ -23,6 +25,8 @@
'Debian': { 'Debian': {
'server': 'apache2', 'server': 'apache2',
'service': 'apache2', 'service': 'apache2',
'user': 'www-data',
'group': 'www-data',
'configfile': '/etc/apache2/apache2.conf', 'configfile': '/etc/apache2/apache2.conf',
'portsfile': '/etc/apache2/ports.conf', 'portsfile': '/etc/apache2/ports.conf',
@ -45,6 +49,8 @@
'RedHat': { 'RedHat': {
'server': 'httpd', 'server': 'httpd',
'service': 'httpd', 'service': 'httpd',
'user': 'apache',
'group': 'apache',
'configfile': '/etc/httpd/conf/httpd.conf', 'configfile': '/etc/httpd/conf/httpd.conf',
'mod_wsgi': 'mod_wsgi', 'mod_wsgi': 'mod_wsgi',
@ -65,6 +71,8 @@
'Suse': { 'Suse': {
'server': 'apache2', 'server': 'apache2',
'service': 'apache2', 'service': 'apache2',
'user': 'apache',
'group': 'apache',
'configfile': '/etc/apache2/httpd.conf', 'configfile': '/etc/apache2/httpd.conf',
'mod_wsgi': 'apache2-mod_wsgi', 'mod_wsgi': 'apache2-mod_wsgi',
@ -83,6 +91,8 @@
'FreeBSD': { 'FreeBSD': {
'server': 'apache22', 'server': 'apache22',
'service': 'apache22', 'service': 'apache22',
'user': 'www',
'group': 'www',
'configfile': '/usr/local/etc/apache22/httpd.conf', 'configfile': '/usr/local/etc/apache22/httpd.conf',
'portsfile': '/usr/local/etc/apache22/ports.conf', 'portsfile': '/usr/local/etc/apache22/ports.conf',

View File

@ -24,12 +24,12 @@ a2enmod pagespeed:
file: file:
- directory - directory
- makedirs: true - makedirs: true
- user: {{ salt['pillar.get']('apache:user', 'www-data') }} - user: {{ apache.user }}
- group: {{ salt['pillar.get']('apache:group', 'www-data') }} - group: {{ apache.group }}
- require: - require:
- pkg: libapache2-mod-pagespeed - pkg: libapache2-mod-pagespeed
- user: {{ salt['pillar.get']('apache:user', 'www-data') }} - user: {{ apache.user }}
- group: {{ salt['pillar.get']('apache:group', 'www-data') }} - group: {{ apache.group }}
{% endfor %} {% endfor %}
# Here we hardcode a logrotate entry to take care of the logs # Here we hardcode a logrotate entry to take care of the logs

View File

@ -5,6 +5,8 @@ apache:
lookup: lookup:
server: apache2 server: apache2
service: apache2 service: apache2
user: some_system_user
group: some_system_group
vhostdir: /etc/apache2/sites-available vhostdir: /etc/apache2/sites-available
confdir: /etc/apache2/conf.d confdir: /etc/apache2/conf.d