Add "tasks/apache.yml"
This commit is contained in:
parent
c526ee4fc1
commit
7992fcc291
7 changed files with 51 additions and 1 deletions
|
@ -9,3 +9,5 @@ common__certbot__pre_hook: 'systemctl is-active nginx.service && systemctl stop
|
||||||
common__nginx__remove_default: true
|
common__nginx__remove_default: true
|
||||||
common__nginx__upstreams: []
|
common__nginx__upstreams: []
|
||||||
common__nginx__sites: []
|
common__nginx__sites: []
|
||||||
|
|
||||||
|
common__apache__remove_default: true
|
||||||
|
|
|
@ -16,3 +16,9 @@
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
name: nginx
|
name: nginx
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
|
- name: common | Restart Apache
|
||||||
|
systemd:
|
||||||
|
daemon_reload: true
|
||||||
|
name: apache2
|
||||||
|
state: restarted
|
||||||
|
|
|
@ -10,6 +10,7 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'package_name',
|
'package_name',
|
||||||
[
|
[
|
||||||
|
'apache2',
|
||||||
'apt-transport-https',
|
'apt-transport-https',
|
||||||
'bash-completion',
|
'bash-completion',
|
||||||
'certbot',
|
'certbot',
|
||||||
|
@ -19,6 +20,7 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||||
'gnupg2',
|
'gnupg2',
|
||||||
'iptables-persistent',
|
'iptables-persistent',
|
||||||
'less',
|
'less',
|
||||||
|
'nginx',
|
||||||
'procps',
|
'procps',
|
||||||
'software-properties-common',
|
'software-properties-common',
|
||||||
'vim',
|
'vim',
|
||||||
|
@ -63,6 +65,11 @@ def test_nginx_default_removed(host):
|
||||||
assert not host.file('/etc/nginx/sites-enabled/default').exists
|
assert not host.file('/etc/nginx/sites-enabled/default').exists
|
||||||
|
|
||||||
|
|
||||||
|
def test_apache_default_removed(host):
|
||||||
|
assert host.file('/etc/apache2/sites-available/000-default.conf').exists
|
||||||
|
assert not host.file('/etc/apache2/sites-enabled/000-default.conf').exists
|
||||||
|
|
||||||
|
|
||||||
def test_certbot_cli_config(host):
|
def test_certbot_cli_config(host):
|
||||||
f = host.file('/etc/letsencrypt/cli.ini')
|
f = host.file('/etc/letsencrypt/cli.ini')
|
||||||
|
|
||||||
|
|
30
tasks/apache.yml
Normal file
30
tasks/apache.yml
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
---
|
||||||
|
- name: Install Apache
|
||||||
|
apt:
|
||||||
|
name: apache2
|
||||||
|
|
||||||
|
- name: Create directories for Apache configuration
|
||||||
|
file:
|
||||||
|
state: directory
|
||||||
|
path: '{{ item }}'
|
||||||
|
mode: 'u=rwx,g=rx,o=rx'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
with_items:
|
||||||
|
- '{{ common__apache__conf_dir }}'
|
||||||
|
- '{{ common__apache__available_dir }}'
|
||||||
|
- '{{ common__apache__enabled_dir }}'
|
||||||
|
|
||||||
|
- name: Disable directory listing
|
||||||
|
lineinfile:
|
||||||
|
path: /etc/apache2/apache2.conf
|
||||||
|
regexp: '^Options Indexes FollowSymLinks$'
|
||||||
|
line: 'Options FollowSymLinks'
|
||||||
|
notify: common | Restart Apache
|
||||||
|
|
||||||
|
- name: Remove Apache default site
|
||||||
|
file:
|
||||||
|
state: absent
|
||||||
|
path: '{{ common__apache__enabled_dir }}/000-default.conf'
|
||||||
|
when: common__apache__remove_default|bool
|
||||||
|
notify: common | Restart Apache
|
|
@ -5,3 +5,4 @@
|
||||||
- include_tasks: iptables.yml
|
- include_tasks: iptables.yml
|
||||||
- include_tasks: certbot.yml
|
- include_tasks: certbot.yml
|
||||||
- include_tasks: nginx.yml
|
- include_tasks: nginx.yml
|
||||||
|
- include_tasks: apache.yml
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
file:
|
file:
|
||||||
state: absent
|
state: absent
|
||||||
path: '{{ common__nginx__enabled_dir }}/default'
|
path: '{{ common__nginx__enabled_dir }}/default'
|
||||||
when: common__nginx__remove_default | bool
|
when: common__nginx__remove_default|bool
|
||||||
notify: common | Restart Nginx
|
notify: common | Restart Nginx
|
||||||
|
|
||||||
- name: Add Nginx upstreams
|
- name: Add Nginx upstreams
|
||||||
|
|
|
@ -11,3 +11,7 @@ common__nginx__conf_dir: '/etc/nginx'
|
||||||
common__nginx__confd_dir: '{{ common__nginx__conf_dir }}/conf.d'
|
common__nginx__confd_dir: '{{ common__nginx__conf_dir }}/conf.d'
|
||||||
common__nginx__available_dir: '{{ common__nginx__conf_dir }}/sites-available'
|
common__nginx__available_dir: '{{ common__nginx__conf_dir }}/sites-available'
|
||||||
common__nginx__enabled_dir: '{{ common__nginx__conf_dir }}/sites-enabled'
|
common__nginx__enabled_dir: '{{ common__nginx__conf_dir }}/sites-enabled'
|
||||||
|
|
||||||
|
common__apache__conf_dir: '/etc/apache2'
|
||||||
|
common__apache__available_dir: '{{ common__apache__conf_dir }}/sites-available'
|
||||||
|
common__apache__enabled_dir: '{{ common__apache__conf_dir }}/sites-enabled'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue