Remove Apache

This commit is contained in:
Alex Kotov 2021-09-19 00:17:32 +05:00
parent 89eec02d71
commit 45bceb779c
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
11 changed files with 0 additions and 191 deletions

View file

@ -1,11 +0,0 @@
Ansible Role - Common
=====================
Syslog facilities:
* `local7` - web servers (Nginx, Apache)
Syslog tags:
* `nginx` - Nginx web server
* `httpd` - Apache web server

View file

@ -13,9 +13,3 @@ common__nginx__state: null
common__nginx__remove_default: true
common__nginx__upstreams: []
common__nginx__sites: []
common__apache__state: null
common__apache__remove_default: true
common__apache__listen: ['127.0.0.1:8080']
common__apache__modules: ['alias', 'cgid', 'env', 'rewrite', 'ssl']
common__apache__sites: []

View file

@ -1,2 +0,0 @@
CustomLog "| /usr/bin/logger -plocal7.info -thttpd" combined
ErrorLog "| /usr/bin/logger -plocal7.error -thttpd"

View file

@ -10,9 +10,3 @@
daemon_reload: true
name: nginx
state: restarted
- name: common | Restart Apache
systemd:
daemon_reload: true
name: apache2
state: restarted

View file

@ -1,93 +0,0 @@
---
- name: Install Apache
apt:
name: apache2
- name: Create directories for Apache configuration
file:
state: directory
path: '{{ item }}'
mode: 'u=rwx,go=rx'
owner: root
group: root
with_items:
- '{{ common__apache__conf_dir }}'
- '{{ common__apache__conf_available_dir }}'
- '{{ common__apache__conf_enabled_dir }}'
- '{{ common__apache__available_dir }}'
- '{{ common__apache__enabled_dir }}'
- '{{ common__apache__snippets_dir }}'
notify: common | Restart Apache
- name: Configure Apache ports
template:
src: templates/apache/ports.conf
dest: '{{ common__apache__conf_dir }}/ports.conf'
mode: 'u=rw,go=r'
owner: root
group: root
notify: common | Restart Apache
- name: Disable Apache logging
file:
state: absent
path: '{{ common__apache__conf_enabled_dir }}/other-vhosts-access-log.conf'
notify: common | Restart Apache
- name: Install Apache log config
copy:
src: 'files/apache/syslog.conf'
dest: '{{ common__apache__conf_available_dir }}/syslog.conf'
mode: 'u=rw,go=r'
owner: root
group: root
notify: common | Restart Apache
- name: Enable Apache log config
file:
state: link
src: '{{ common__apache__conf_available_dir }}/syslog.conf'
dest: '{{ common__apache__conf_enabled_dir }}/syslog.conf'
owner: root
group: root
notify: common | Restart Apache
- name: Disable directory listing
lineinfile:
path: '{{ common__apache__conf_dir }}/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
- name: Enable Apache modules
command: '/usr/sbin/a2enmod "{{ item }}"'
register: common__apache__enable_apache_modules_result
changed_when: >
common__apache__enable_apache_modules_result.stdout is search('Enabling module')
with_items: '{{ common__apache__modules }}'
notify: common | Restart Apache
- name: Add Apache sites
template:
src: 'templates/apache/{{ item.type }}.conf'
dest: '{{ common__apache__available_dir }}/{{ item.domain }}.conf'
mode: 'u=rw,go=r'
owner: root
group: root
with_items: '{{ common__apache__sites }}'
notify: common | Restart Apache
- name: Enable Apache sites
command: '/usr/sbin/a2ensite "{{ item.domain }}.conf"'
register: common__apache__enable_apache_sites_result
changed_when: >
common__apache__enable_apache_sites_result.stdout is search('Enabling site')
with_items: '{{ common__apache__sites }}'
notify: common | Restart Apache

View file

@ -1,15 +0,0 @@
---
- name: Purge Apache
apt:
state: absent
purge: true
name:
- apache2
- apache2-bin
- apache2-data
- apache2-utils
- name: Delete Apache configuration
file:
state: absent
path: '{{ common__apache__conf_dir }}'

View file

@ -1,10 +0,0 @@
---
- name: Uninstall Apache
apt:
state: absent
purge: false
name:
- apache2
- apache2-bin
- apache2-data
- apache2-utils

View file

@ -18,20 +18,6 @@
when: common__certbot__state == 'install'
- meta: flush_handlers
- fail:
msg: 'Invalid `common__apache__state`: {{ common__apache__state }}'
when: (common__apache__state != None) and
(common__apache__state != 'purge') and
(common__apache__state != 'remove') and
(common__apache__state != 'install')
- include_tasks: apache/purge.yml
when: common__apache__state == 'purge'
- include_tasks: apache/remove.yml
when: common__apache__state == 'remove'
- include_tasks: apache/install.yml
when: common__apache__state == 'install'
- meta: flush_handlers
- fail:
msg: 'Invalid `common__nginx__state`: {{ common__nginx__state }}'
when: (common__nginx__state != None) and

View file

@ -1,24 +0,0 @@
NameVirtualHost *:80
<VirtualHost *:80>
ServerName {{ item.domain }}
Redirect permanent / https://{{ item.domain }}
</VirtualHost>
<VirtualHost _default_:443>
ServerName {{ item.domain }}
DocumentRoot {{ item.root }}
RewriteEngine on
SSLEngine on
SSLCertificateFile {{ item.cert }}
SSLCertificateKeyFile {{ item.key }}
SSLCertificateChainFile {{ item.chain }}
{% for rewrite in item.rewrites %}
RewriteRule {{ rewrite }}
{% endfor %}
</VirtualHost>

View file

@ -1,3 +0,0 @@
{% for listen in common__apache__listen %}
Listen {{ listen }}
{% endfor %}

View file

@ -12,13 +12,6 @@ common__nginx__available_dir: '{{ common__nginx__conf_dir }}/sites-available'
common__nginx__enabled_dir: '{{ common__nginx__conf_dir }}/sites-enabled'
common__nginx__snippets_dir: '{{ common__nginx__conf_dir }}/snippets'
common__apache__conf_dir: '/etc/apache2'
common__apache__conf_available_dir: '{{ common__apache__conf_dir }}/conf-available'
common__apache__conf_enabled_dir: '{{ common__apache__conf_dir }}/conf-enabled'
common__apache__available_dir: '{{ common__apache__conf_dir }}/sites-available'
common__apache__enabled_dir: '{{ common__apache__conf_dir }}/sites-enabled'
common__apache__snippets_dir: '{{ common__apache__conf_dir }}/snippets'
common__certbot__nginx_ssl_ciphers:
- 'ECDHE-ECDSA-AES128-GCM-SHA256'
- 'ECDHE-RSA-AES128-GCM-SHA256'