weareinteractive.apache2
Rola Ansible weareinteractive.apache2
weareinteractive.apache2
to rola Ansible, która:
- instaluje apache2
- konfiguruje apache2
- włącza / wyłącza konfiguracje
- tworzy witryny
- włącza / wyłącza witryny
- włącza / wyłącza moduły
- opcjonalnie usuwa domyślny host
- dodaje zasady
- konfiguruje usługę
Uwaga:
Ponieważ Ansible Galaxy wspiera organizacje, ta rola została przeniesiona z
franklinkim.apache2
doweareinteractive.apache2
!
Instalacja
Używając ansible-galaxy
:
$ ansible-galaxy install weareinteractive.apache2
Używając requirements.yml
:
- src: weareinteractive.apache2
Używając git
:
$ git clone https://github.com/weareinteractive/ansible-apache2.git weareinteractive.apache2
Zależności
- Ansible >= 2.4
Zmienne
Oto lista wszystkich domyślnych zmiennych dla tej roli, które są również dostępne w defaults/main.yml
.
---
# apache2_packages:
# - apache2
# - apache2-mpm-prefork
# apache2_module:
# - { id: auth, state: absent }
# - { id: rewrite, state: present }
# apache2_confs:
# - { id: security, state: absent }
# - { name: mime, state: present }
# - id: my_config
# state: present
# template: path/to/template.j2
# apache2_sites:
# - id: mysite (wymagane)
# name: mysite.local (wymagane)
# ip: '*'
# port: 80
# state: present
# add_webroot: no
# template: path/to/template.j2
# rules: []
# aliases: []
# redirects: []
# ssl:
# port: 443
# key_name: mykey
# cert_name: mycert
# chain_name: mychain
# auth:
# name: mysite
# file: mysite
# append: ''
#
apache2_packages:
- apache2
apache2_ports: [80]
apache2_ssl_ports: [443]
apache2_listen_addresses: ['*']
apache2_modules: []
apache2_confs: []
apache2_sites: []
apache2_sites_basedir: /var/www
apache2_sites_template: etc/apache2/sites-available/site.j2
apache2_remove_default: no
apache2_service_enabled: yes
apache2_service_state: started
apache2_server_tokens: Prod
apache2_server_signiture: 'Off'
apache2_trace_enable: 'Off'
apache2_certs_path: /etc/ssl/certs
apache2_keys_path: /etc/ssl/private
Handlerzy
Oto handlerzy, które są zdefiniowane w handlers/main.yml
.
---
- name: testuj i zrestartuj apache2
command: apache2ctl configtest
notify: restart apache2
- name: testuj i przeładuj apache2
command: apache2ctl configtest
notify: reload apache2
- name: zrestartuj apache2
service: name=apache2 state=restarted
when: apache2_service_state != 'stopped'
- name: przeładuj apache2
service: name=apache2 state=reloaded
when: apache2_service_state != 'stopped'
Zasady
Niektóre fragmenty konfiguracji pochodzące z HTML 5 Boilerplate będą kopiowane do
/etc/apache2/rules
, które można użyć w konfiguracjach vhost (zobacz użycie poniżej).
- kompresja
- transformacja treści
- cors
- cors_images
- cors_timing
- cors_web_fonts
- etag
- expires
- łączenie plików
- bazowanie na nazwach plików
- ie_cookies
- ie_edge
- mimes
- bezpieczeństwo_dostępu_do_plików
- bezpieczeństwo_gospodarzy
- bezpieczeństwo_mime
- bezpieczeństwo_podpisu
- bezpieczeństwo_technologii
- ssl
- utf8
Użycie
To jest przykładowy playbook:
---
# ten przykład używa powiązanych ról:
#
# - weareinteractive.apt (https://github.com/weareinteractive/ansible-apt)
# - weareinteractive.openssl (https://github.com/weareinteractive/ansible-openssl)
# - weareinteractive.htpasswd (https://github.com/weareinteractive/ansible-htpasswd)
- hosts: all
become: yes
roles:
- weareinteractive.apt
- weareinteractive.openssl
- weareinteractive.htpasswd
- weareinteractive.apache2
vars:
htpasswd:
- name: foobar
users:
- { name: foobar, password: foobar }
apache2_modules:
- { id: ssl, state: present }
- { id: mime, state: present }
- { id: headers, state: present }
- { id: rewrite, state: present }
apache2_remove_default: yes
openssl_generate_csr: yes
openssl_self_signed:
- name: 'foobar.local'
country: 'DE'
state: 'Bawaria'
city: 'Monachium'
organization: 'Foo Bar'
unit: 'Jednostka Foo Bar'
email: '[email protected]'
apache2_sites:
- id: foobar
state: present
name: foobar.local
rules:
- mimes
- expires
- compression
add_webroot: yes
auth:
name: Foo Bar
file: foobar
ssl:
key_name: foobar.local
cert_name: foobar.local
Testowanie
$ git clone https://github.com/weareinteractive/ansible-apache2.git
$ cd ansible-apache2
$ make test
Wkład
W braku formalnego przewodnika po stylu, zadbaj o utrzymanie istniejącego stylu kodowania. Dodaj testy jednostkowe i przykłady dla każdej nowej lub zmienionej funkcjonalności.
- Forkuj projekt
- Utwórz nową gałąź (
git checkout -b moja-nowa-funkcja
) - Zatwierdź zmiany (
git commit -am 'Dodaj jakąś funkcjonalność'
) - Wyślij do gałęzi (
git push origin moja-nowa-funkcja
) - Utwórz nowe zapytanie Pull
Uwaga: Aby zaktualizować plik README.md
, zainstaluj i uruchom ansible-role
:
$ gem install ansible-role
$ ansible-role docgen
Licencja
Prawa autorskie (c) We Are Interactive na licencji MIT.
ansible-galaxy install weareinteractive.apache2