buluma.httpd

Ansible 角色 httpd

在您的系统上安装和配置 httpd。

GitHub 版本 问题 合并请求 下载
github Version Issues PullRequests Ansible Role

示例剧本

此示例来自 molecule/default/converge.yml,在每次推送、合并请求和发布时进行测试。

---
- name: Converge
  hosts: all
  become: true
  gather_facts: true

  vars_files:
    - ../../vars/main.yml
    - ../../defaults/main.yml

  pre_tasks:
    - name: 更新 apt 缓存。
      apt: update_cache=true cache_valid_time=600
      when: ansible_os_family == 'Debian'

  roles:
    - role: buluma.httpd
      # https_ssl_enable: true
      httpd_port: 8080
      httpd_ssl_port: 8443
      httpd_locations:
        - name: my_location
          location: /my_location
          backend_url: "http://localhost:8080/myapplication"
      # httpd_vhosts:
      #   - name: my_vhost_docroot
      #     servername: www1.example.com
      #     documentroot: "{{ httpd_data_directory }}/www1.example.com"
      #   - name: my_vhost_backend_http
      #     servername: www2.example.com
      #     backend_url: "http://www.example.com/"
      #     serveralias:
      #       - example.com
      #       - www.example.com
      #   - name: my_vhost_remote
      #     servername: www3.example.com
      #     remote: "http://localhost:3128/"
      #   - name: my_vhost_backend_https
      #     servername: www4.example.com
      #     backend_url: "https://www.example.com/"
      #   - name: my_vhost_piratebay
      #     servername: piratebay.nl
      #     backend_url: "https://thepirate-bay.org/"
      #     proxy_preserve_host: Off
      #     proxy_requests: Off
      #     setenv:
      #       - name: force-proxy-request-1.0
      #         value: 1
      #       - name: proxy-nokeepalive
      #         value: 1
      #       - name: proxy-initial-not-pooled
      #       - name: proxy-sendchunks
      #         value: 1
      #   - name: no_doc_root
      #     servername: nodocroot.example.com
      #     documentroot: /var/www/html/nodocroot
      #     create_docroot: false
      httpd_directories:
        - name: my_directory
          path: "{{ httpd_data_directory }}/my_directory"
          # options:
          #   - Indexes
          #   - FollowSymLinks
          allow_override: All

机器需要准备好。在 CI 中,这通常使用 molecule/default/prepare.yml 完成:

---
- name: Prepare
  hosts: all
  become: true
  gather_facts: false

  roles:
    - role: buluma.bootstrap
    - role: buluma.epel
    - role: buluma.buildtools
    - role: buluma.python_pip
    - role: buluma.openssl
      openssl_items:
        - name: apache-httpd
          common_name: "{{ ansible_fqdn }}"

查看 完整说明和示例 以了解如何使用这些角色。

角色变量

变量的默认值设置在 defaults/main.yml 中:

---
# httpd 的默认文件

# 使用的服务器名称。
httpd_servername: "{{ ansible_fqdn }}"

# 使用的非 SSL 端口。
httpd_port: 80

# 是否启用(自签名证书)SSL?
https_ssl_enable: false

# 要配置 https,请设置要侦听的主机名。
httpd_ssl_servername: "{{ ansible_fqdn }}"

# 对于 SSL,需要一个 TCP 端口。
httpd_ssl_port: 443

# SSL 证书:
httpd_openssl_crt: "{{ httpd_openssl_crt_directory }}/apache-httpd.crt"

# SSL 密钥
httpd_openssl_key: "{{ httpd_openssl_key_directory }}/apache-httpd.key"

# 是否保留“它工作”页面
httpd_remove_example: false

# 要安装的附加 httpd 模块

httpd_additionnal_modules: []

httpd_custom_modules_to_activate_with_command: []

apache_global_vhost_settings: |
  DirectoryIndex index.php index.html

# 用于 vhosts 的模板。用于覆盖您自己的设置。
vhost_conf_template: vhost.conf.j2

default_vhost_conf: default_vhost.conf

要求

使用的角色状态

以下角色用于准备系统。您可以用其他方式准备您的系统。

需求 GitHub 版本
buluma.bootstrap Ansible Molecule Version
buluma.buildtools Ansible Molecule Version
buluma.epel Ansible Molecule Version
buluma.openssl Ansible Molecule Version
buluma.python_pip Ansible Molecule Version
buluma.selinux Ansible Molecule Version

上下文

此角色是多个兼容角色的一部分。有关更多信息,请查看 这些角色的文档

下面是相关角色的概述:

依赖关系

兼容性

此角色已在这些 容器映像 上进行测试:

容器 标签
EL 8, 9
Debian 所有
Fedora 所有
opensuse 所有
Ubuntu jammy, focal, bionic, lunar, noble

所需的 Ansible 最小版本为 2.12,已对以下版本进行测试:

  • 之前的版本。
  • 当前版本。
  • 开发版本。

如果您发现问题,请在 GitHub 上报告。

更新日志

角色历史

许可证

Apache-2.0

作者信息

Shadow Walker

关于项目

Install and configure httpd on your system.

安装
ansible-galaxy install buluma.httpd
许可证
apache-2.0
下载
528.9k
拥有者
DevOps Engineer