mirror of
https://github.com/geerlingguy/ansible-role-apache
synced 2024-12-22 11:00:18 +01:00
commit
7a9091c730
13 changed files with 114 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- name: restart apache
|
||||
service:
|
||||
name: "{{ apache_daemon }}"
|
||||
name: "{{ apache_service }}"
|
||||
state: restarted
|
||||
|
|
|
@ -3,7 +3,7 @@ dependencies: []
|
|||
|
||||
galaxy_info:
|
||||
author: geerlingguy
|
||||
description: Apache 2.x for RedHat/CentOS/Debian/Ubuntu.
|
||||
description: Apache 2.x for RedHat/CentOS/Debian/Ubuntu/Solaris.
|
||||
company: "Midwestern Mac, LLC"
|
||||
license: "license (BSD, MIT)"
|
||||
min_ansible_version: 1.4
|
||||
|
@ -20,5 +20,8 @@ galaxy_info:
|
|||
- raring
|
||||
- saucy
|
||||
- trusty
|
||||
- name: Solaris
|
||||
versions:
|
||||
- 11.3
|
||||
categories:
|
||||
- web
|
||||
|
|
19
tasks/configure-Solaris.yml
Normal file
19
tasks/configure-Solaris.yml
Normal file
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
- name: Configure Apache.
|
||||
lineinfile:
|
||||
dest: "{{ apache_server_root }}/{{ apache_daemon }}.conf"
|
||||
regexp: "{{ item.regexp }}"
|
||||
line: "{{ item.line }}"
|
||||
state: present
|
||||
with_items: apache_ports_configuration_items
|
||||
notify: restart apache
|
||||
|
||||
- name: Add apache vhosts configuration.
|
||||
template:
|
||||
src: "vhosts-{{ apache_vhosts_version }}.conf.j2"
|
||||
dest: "{{ apache_conf_path }}/{{ apache_vhosts_filename }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify: restart apache
|
||||
when: apache_create_vhosts
|
24
tasks/configure-Suse.yml
Normal file
24
tasks/configure-Suse.yml
Normal file
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
- name: Configure Apache.
|
||||
lineinfile:
|
||||
dest: "{{ apache_server_root }}/listen.conf"
|
||||
regexp: "{{ item.regexp }}"
|
||||
line: "{{ item.line }}"
|
||||
state: present
|
||||
with_items: apache_ports_configuration_items
|
||||
notify: restart apache
|
||||
|
||||
- name: Check whether certificates defined in vhosts exist.
|
||||
stat: path={{ item.certificate_file }}
|
||||
register: apache_ssl_certificates
|
||||
with_items: apache_vhosts_ssl
|
||||
|
||||
- name: Add apache vhosts configuration.
|
||||
template:
|
||||
src: "vhosts-{{ apache_vhosts_version }}.conf.j2"
|
||||
dest: "{{ apache_conf_path }}/{{ apache_vhosts_filename }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify: restart apache
|
||||
when: apache_create_vhosts
|
|
@ -12,9 +12,15 @@
|
|||
- include: setup-RedHat.yml
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
- include: setup-Suse.yml
|
||||
when: ansible_os_family == 'Suse'
|
||||
|
||||
- include: setup-Debian.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- include: setup-Solaris.yml
|
||||
when: ansible_os_family == 'Solaris'
|
||||
|
||||
# Figure out what version of Apache is installed.
|
||||
- name: Get installed version of Apache.
|
||||
shell: "{{ apache_daemon_path }}{{ apache_daemon }} -v"
|
||||
|
@ -36,11 +42,17 @@
|
|||
- include: configure-RedHat.yml
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
- include: configure-Suse.yml
|
||||
when: ansible_os_family == 'Suse'
|
||||
|
||||
- include: configure-Debian.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- include: configure-Solaris.yml
|
||||
when: ansible_os_family == 'Solaris'
|
||||
|
||||
- name: Ensure Apache has selected state and enabled on boot.
|
||||
service:
|
||||
name: "{{ apache_daemon }}"
|
||||
name: "{{ apache_service }}"
|
||||
state: "{{ apache_state }}"
|
||||
enabled: yes
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
- name: Update apt cache.
|
||||
apt: update_cache=yes cache_valid_time=86400
|
||||
|
||||
- name: Ensure Apache is installed.
|
||||
- name: Ensure Apache is installed on Debian.
|
||||
apt: "name={{ item }} state=installed"
|
||||
with_items: apache_packages
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- name: Ensure Apache is installed.
|
||||
- name: Ensure Apache is installed on RHEL.
|
||||
yum:
|
||||
name: "{{ item }}"
|
||||
state: installed
|
||||
|
|
6
tasks/setup-Solaris.yml
Normal file
6
tasks/setup-Solaris.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- name: Ensure Apache is installed on Solaris.
|
||||
pkg5:
|
||||
name: "{{ item }}"
|
||||
state: installed
|
||||
with_items: apache_packages
|
6
tasks/setup-Suse.yml
Normal file
6
tasks/setup-Suse.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- name: Ensure Apache is installed on Suse.
|
||||
zypper:
|
||||
name: "{{ item }}"
|
||||
state: installed
|
||||
with_items: apache_packages
|
|
@ -1,4 +1,5 @@
|
|||
---
|
||||
apache_service: apache2
|
||||
apache_daemon: apache2
|
||||
apache_daemon_path: /usr/sbin/
|
||||
apache_server_root: /etc/apache2
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
---
|
||||
apache_service: httpd
|
||||
apache_daemon: httpd
|
||||
apache_daemon_path: /usr/sbin/
|
||||
apache_server_root: /etc/httpd
|
||||
|
|
19
vars/Solaris.yml
Normal file
19
vars/Solaris.yml
Normal file
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
apache_service: apache24
|
||||
apache_daemon: httpd
|
||||
apache_daemon_path: /usr/apache2/2.4/bin/
|
||||
apache_server_root: /etc/apache2/2.4/
|
||||
apache_conf_path: /etc/apache2/2.4/conf.d
|
||||
|
||||
apache_vhosts_version: "2.2"
|
||||
|
||||
__apache_packages:
|
||||
- web/server/apache-24
|
||||
- web/server/apache-24/module/apache-ssl
|
||||
- web/server/apache-24/module/apache-security
|
||||
|
||||
apache_ports_configuration_items:
|
||||
- regexp: "^Listen "
|
||||
line: "Listen {{ apache_listen_port }}"
|
||||
- regexp: "^#?NameVirtualHost "
|
||||
line: "NameVirtualHost *:{{ apache_listen_port }}"
|
18
vars/Suse.yml
Normal file
18
vars/Suse.yml
Normal file
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
apache_service: apache2
|
||||
apache_daemon: httpd2
|
||||
apache_daemon_path: /usr/sbin/
|
||||
apache_server_root: /etc/apache2
|
||||
apache_conf_path: /etc/apache2/conf.d
|
||||
|
||||
apache_vhosts_version: "2.2"
|
||||
|
||||
__apache_packages:
|
||||
- apache2
|
||||
- openssh
|
||||
|
||||
apache_ports_configuration_items:
|
||||
- regexp: "^Listen "
|
||||
line: "Listen {{ apache_listen_port }}"
|
||||
- regexp: "^#?NameVirtualHost "
|
||||
line: "NameVirtualHost *:{{ apache_listen_port }}"
|
Loading…
Reference in a new issue