supertarto.apache

Ansible apache

CI

Instalar y configurar Apache con Ansible.

Requisitos

Ninguno

Plataformas probadas

  • Debian 10 (Buster)
  • Debian 11 (Bullseye)
  • Debian 12 (Bookworm)

Variables del rol

El servicio de Apache, la ruta de configuración de Apache y los paquetes a instalar.

apache_service: apache2
apache_server_conf: /etc/apache2

apache_packages:
  - apache2
  - apache2-utils

Configuración de puertos, que se cargará en ports.conf

apache_listen_port: 80
apache_ports_configuration_items:
  - regexp: "^Listen "
    line: "Listen {{ apache_listen_port }}"

Modificaciones en security.conf, para fines de producción.

apache_server_token: Prod
apache_server_signature: "Off"
apache_trace_enabled: "Off"
apache_security_configuration_items:
  - regexp: "^ServerTokens "
    line: "ServerTokens {{ apache_server_token }}"
  - regexp: "^ServerSignature "
    line: "ServerSignature {{ apache_server_signature }}"
  - regexp: "^TraceEnable "
    line: "TraceEnable {{ apache_trace_enabled }}"

Una lista de módulos a habilitar y una lista de módulos a deshabilitar. El valor predeterminado es "vacío".

apache_mods_enabled: []
apache_mods_disabled: []

¿Quieres crear un nuevo archivo de vhosts? Si se establece en verdadero, ¿cómo se llamará el archivo de configuración?

apache_create_vhosts: true
apache_vhosts_filename: "my-vhosts.conf"

¿Necesitamos eliminar los hosts predeterminados? Si se establece en verdadero, ¿qué archivo de configuración debe ser eliminado? También se puede usar para eliminar vhosts personalizados.

apache_remove_default_vhost: true
apache_default_vhost_filename:
 - 000-default.conf

apache_vhost_config se utiliza para configurar tu virtualhost. Puedes tener múltiples vhosts. Si no deseas establecer un parámetro específico, simplemente elimínalo. Por ejemplo, si no quieres definir un serveralias, o si no necesitas una "location", elimina esas líneas.

Otras variables están destinadas a ser multilínea: apache_vhost_config.custom_param, apache_vhost_config.directory.config, apache_vhost_config.location.config, apache_vhost_config.file.config. No olvides el carácter "|". Aquí puedes ver un ejemplo. Por defecto, apache_vhost_config está vacío. Debes definirlo tú mismo para adaptarlo a tus necesidades.

apache_vhost_config:
  - listen_ip: "*"
    listen_port: 80
    server_name: host1
    custom_param: |
        Redirect / https://host1
    
  - listen_ip: "*"
    listen_port: 443
    server_name: host1
    serveralias: alias1
    documentroot: "/var/www/html"
    serveradmin: admin@localhost
    custom_param: |
      ProxyRequests Off
      ProxyPreserveHost On
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
      LogLevel warn
    ssl_engine: "on"
    ssl_certificate_file: /etc/ssl/certs/certif.crt
    ssl_certificate_key_file: /etc/ssl/private/certif.key
    ssl_certificate_chain_file: /etc/ssl/certs/chain
    directory:
      - path: "/var/www/html"
        config: |
          AllowOverride All
          Order deny,allow
          allow from all
      - path: "/usr/lib/cgi-bin"
        config: |
          SSLOptions +StdEnvVars
    location:
      - path: "/"
        config: |
          Options -Indexes
          Options -Includes
          Options -FollowSymLinks
          ProxyPass http://localhost:8080/ min=0 max=100 smax=50 ttl=10
          ProxyPassReverse http://localhost/
    file:
      - path: '\.(cgi|shtml|phtml|php)$'
        config: |
          SSLOptions +StdEnvVars

Ejemplos

- hosts: somehost
  roles:
    - supertarto.apache

  vars:
    apache_mods_enabled:
        - ssl
    apache_create_vhosts: true
    apache_vhosts_filename: "mysite.conf"
    apache_vhost_config:
        - listen_ip: "*"
          listen_port: 80
          server_name: host1
          custom_param: |
            Redirect / https://host1

        - listen_ip: "*"
          listen_port: 443
          server_name: host1
          serveralias: alias1
          documentroot: "/var/www/html"
          serveradmin: admin@localhost
          custom_param: |
            ProxyRequests Off
            ProxyPreserveHost On
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
            LogLevel warn
          ssl_engine: "on"
          ssl_certificate_file: /etc/ssl/certs/certif.crt
          ssl_certificate_key_file: /etc/ssl/private/certif.key
          ssl_certificate_chain_file: /etc/ssl/certs/chain
          directory:
            - path: "/var/www/html"
              config: |
                AllowOverride All
                Order deny,allow
                allow from all            

Instalación

ansible-galaxy install supertarto.apache

Licencia

GPL V3.0

Acerca del proyecto

Install and configure apache2 with ansible

Instalar
ansible-galaxy install supertarto.apache
Licencia
gpl-3.0
Descargas
1.6k
Propietario