supertarto.apache
Ansible Apache
Ansibleを使ってApacheをインストールし、設定します。
必要条件
なし
テスト済みプラットフォーム
- Debian 10 (Buster)
- Debian 11 (Bullseye)
- Debian 12 (Bookworm)
ロール変数
Apacheサービス、Apache設定ファイルのパス、インストールするパッケージ。
apache_service: apache2
apache_server_conf: /etc/apache2
apache_packages:
- apache2
- apache2-utils
ポートの設定、ports.confに読み込むためのもの。
apache_listen_port: 80
apache_ports_configuration_items:
- regexp: "^Listen "
line: "Listen {{ apache_listen_port }}"
プロダクション用のsecurity.confの変更。
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 }}"
有効にするモジュールのリストと、無効にするモジュールのリスト。デフォルト値は「空」です。
apache_mods_enabled: []
apache_mods_disabled: []
新しいvhostsファイルを作成しますか?trueに設定すると、設定ファイルの名前はどうなりますか?
apache_create_vhosts: true
apache_vhosts_filename: "my-vhosts.conf"
デフォルトのホストを削除する必要がありますか?trueに設定すると、どの設定ファイルを削除する必要がありますか?カスタムvhostsを削除するためにも使用できます。
apache_remove_default_vhost: true
apache_default_vhost_filename:
- 000-default.conf
apache_vhost_configは、仮想ホストを設定するために使用します。複数のvhostsを持つことができます。特定のパラメータを設定したくない場合は、その行を削除してください。たとえば、serveraliasを定義したくない場合や、「location」が不要な場合は、その行を削除してください。
他の変数は複数行の入力を行うためのものです:apache_vhost_config.custom_param、apache_vhost_config.directory.config、apache_vhost_config.location.config、apache_vhost_config.file.config。先頭の「|」を忘れないでください。 ここに例があります。デフォルトでapache_vhost_configは空です。これを自分のニーズに合わせて定義する必要があります。
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
例
- 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
インストール
ansible-galaxy install supertarto.apache
ライセンス
GPL V3.0