Skip to content

Commit

Permalink
Merge pull request #6 from wcm-io-devops/feature/update-from-forked-repo
Browse files Browse the repository at this point in the history
Update from geerlingguy.apache
  • Loading branch information
tobias-richter authored Nov 30, 2018
2 parents 330d7fb + ac2bda0 commit 2673b0d
Show file tree
Hide file tree
Showing 18 changed files with 122 additions and 77 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.retry
tests/test.sh
*/__pycache__
*.pyc
34 changes: 22 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
---
language: python
services: docker

env:
- distro: centos7
- distro: centos6
- distro: ubuntu1804
- distro: ubuntu1604
- distro: ubuntu1404
- distro: debian9
- distro: debian8
global:
- ROLE_NAME: apache
matrix:
- MOLECULE_DISTRO: centos7
- MOLECULE_DISTRO: centos6
- MOLECULE_DISTRO: ubuntu1804
- MOLECULE_DISTRO: ubuntu1604
- MOLECULE_DISTRO: ubuntu1404
- MOLECULE_DISTRO: debian9
- MOLECULE_DISTRO: debian8

script:
# Download test shim.
- wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/
- chmod +x ${PWD}/tests/test.sh
install:
# Install test dependencies.
- pip install molecule docker

before_script:
# Use actual Ansible Galaxy role name for the project directory.
- cd ../
- mv ansible-role-$ROLE_NAME wcm_io_devops.$ROLE_NAME
- cd wcm_io_devops.$ROLE_NAME

script:
# Run tests.
- ${PWD}/tests/test.sh
- molecule test

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
16 changes: 8 additions & 8 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ apache_allow_override: "All"
apache_options: "-Indexes +FollowSymLinks"

apache_vhosts_ssl: []
# Additional properties:
# 'serveradmin, serveralias, allow_override, options, extra_parameters'.
# - servername: "local.dev",
# documentroot: "/var/www/html",
# certificate_file: "/path/to/certificate.crt",
# certificate_key_file: "/path/to/certificate.key",
# # Optional.
# certificate_chain_file: "/path/to/certificate_chain.crt"
# Additional properties:
# 'serveradmin, serveralias, allow_override, options, extra_parameters'.
# - servername: "local.dev",
# documentroot: "/var/www/html",
# certificate_file: "/path/to/certificate.crt",
# certificate_key_file: "/path/to/certificate.key",
# # Optional.
# certificate_chain_file: "/path/to/certificate_chain.crt"

apache_ignore_missing_ssl_certificate: true

Expand Down
9 changes: 5 additions & 4 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ galaxy_info:
- name: EL
versions:
- all
- name: Fedora
versions:
- all
- name: Amazon
versions:
- all
Expand All @@ -24,9 +27,6 @@ galaxy_info:
- trusty
- xenial
- bionic
- name: Suse
versions:
- all
- name: Solaris
versions:
- 11.3
Expand All @@ -35,5 +35,6 @@ galaxy_info:
- apache
- webserver
- html
- httpd

allow_duplicates: yes
allow_duplicates: true
29 changes: 29 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
options:
config-file: molecule/default/yaml-lint.yml
platforms:
- name: instance
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
provisioner:
name: ansible
lint:
name: ansible-lint
playbooks:
converge: ${MOLECULE_PLAYBOOK:-playbook.yml}
scenario:
name: default
verifier:
name: testinfra
lint:
name: flake8
21 changes: 21 additions & 0 deletions molecule/default/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
- name: Converge
hosts: all
become: true

vars:
apache_listen_port_ssl: 443
apache_create_vhosts: true
apache_vhosts_filename: "vhosts.conf"
apache_vhosts:
- servername: "example.com"
documentroot: "/var/www/vhosts/example_com"

pre_tasks:
- name: Update apt cache.
apt: update_cache=yes cache_valid_time=600
when: ansible_os_family == 'Debian'
changed_when: false

roles:
- role: wcm_io_devops.apache
6 changes: 6 additions & 0 deletions molecule/default/yaml-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
extends: default
rules:
line-length:
max: 120
level: warning
2 changes: 1 addition & 1 deletion tasks/configure-RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@
dest: "{{ apache_conf_path }}/ssl.conf"
regexp: "##\\n##\\s*SSL Virtual Host Context(.*\\n)*</VirtualHost>"
when: apache_remove_default_vhost_ssl
notify: restart apache
notify: restart apache
19 changes: 12 additions & 7 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

- name: Include variables for Amazon Linux.
include_vars: "AmazonLinux.yml"
when: ansible_distribution == "Amazon" and ansible_distribution_major_version == "NA"
when:
- ansible_distribution == "Amazon"
- ansible_distribution_major_version == "NA"

- name: Define apache_packages.
set_fact:
Expand All @@ -17,26 +19,29 @@

# Figure out what version of Apache is installed.
- name: Get installed version of Apache.
shell: "{{ apache_daemon_path }}{{ apache_daemon }} -v"
command: "{{ apache_daemon_path }}{{ apache_daemon }} -v"
changed_when: false
check_mode: no
check_mode: false
register: _apache_version

- name: Create apache_version variable.
set_fact:
apache_version: "{{ _apache_version.stdout.split()[2].split('/')[1] }}"

- include_vars: apache-22.yml
- name: Include Apache 2.2 variables.
include_vars: apache-22.yml
when: "apache_version.split('.')[1] == '2'"

- include_vars: apache-24.yml
- name: Include Apache 2.4 variables.
include_vars: apache-24.yml
when: "apache_version.split('.')[1] == '4'"

# Configure Apache.
- include_tasks: "configure-{{ ansible_os_family }}.yml"
- name: Configure Apache.
include_tasks: "configure-{{ ansible_os_family }}.yml"

- name: Ensure Apache has selected state and enabled on boot.
service:
name: "{{ apache_service }}"
state: "{{ apache_state }}"
enabled: yes
enabled: true
3 changes: 1 addition & 2 deletions tasks/setup-Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
apt: update_cache=yes cache_valid_time=3600

- name: Ensure Apache is installed on Debian.
apt: "name={{ item }} state={{ apache_packages_state }}"
with_items: "{{ apache_packages }}"
apt: "name={{ apache_packages }} state={{ apache_packages_state }}"
7 changes: 3 additions & 4 deletions tasks/setup-RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
- name: Ensure Apache is installed on RHEL.
yum:
name: "{{ item }}"
package:
name: "{{ apache_packages }}"
state: "{{ apache_packages_state }}"
enablerepo: "{{ apache_enablerepo }}"
with_items: "{{ apache_packages }}"
enablerepo: "{{ apache_enablerepo | default(omit, true) }}"
3 changes: 1 addition & 2 deletions tasks/setup-Solaris.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
- name: Ensure Apache is installed on Solaris.
pkg5:
name: "{{ item }}"
name: "{{ apache_packages }}"
state: "{{ apache_packages_state }}"
with_items: "{{ apache_packages }}"
3 changes: 1 addition & 2 deletions tasks/setup-Suse.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
- name: Ensure Apache is installed on Suse.
zypper:
name: "{{ item }}"
name: "{{ apache_packages }}"
state: "{{ apache_packages_state }}"
with_items: "{{ apache_packages }}"
11 changes: 0 additions & 11 deletions tests/README.md

This file was deleted.

13 changes: 0 additions & 13 deletions tests/test.yml

This file was deleted.

2 changes: 1 addition & 1 deletion vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ apache_conf_path: /etc/apache2

__apache_packages:
- apache2
- apache2-utils
- apache2-utils
2 changes: 1 addition & 1 deletion vars/Suse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ apache_vhosts_version: "2.4"

__apache_packages:
- apache2
- openssh
- openssh
16 changes: 8 additions & 8 deletions vars/apache-24.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ apache_default_vhost_filenames:
apache_ports_configuration_items:
# Debian/Ubuntu and RedHat/CentOS/Amazon Linux Regex for http
- {
regexp: "^Listen\\s+\\d+$",
line: "Listen {{ apache_listen_port }}"
regexp: "^Listen\\s+\\d+$",
line: "Listen {{ apache_listen_port }}"
}
# RedHat/CentOS 7, Amazon Linux
- {
regexp: "^Listen\\s+\\d+\\s+https$",
replace: "Listen {{ apache_listen_port_ssl }} https"
regexp: "^Listen\\s+\\d+\\s+https$",
replace: "Listen {{ apache_listen_port_ssl }} https"
}
# Debian, SUSE
- {
regexp: "^(\\s*<IfModule\\s+.+>(?:\\n+\\s+#.+)*\\s+)Listen\\s+\\d+",
replace: "\\1Listen {{ apache_listen_port_ssl }}"
regexp: "^(\\s*<IfModule\\s+.+>(?:\\n+\\s+#.+)*\\s+)Listen\\s+\\d+",
replace: "\\1Listen {{ apache_listen_port_ssl }}"
}
# SUSE
- {
regexp: "^(# - name-based virtual hosting:\\n(?:#\\n)*)#?\\s*NameVirtualHost\\s+.*:\\d+",
replace: "\\1NameVirtualHost {{ apache_listen_ip }}:{{ apache_listen_port }}"
regexp: "^(# - name-based virtual hosting:\\n(?:#\\n)*)#?\\s*NameVirtualHost\\s+.*:\\d+",
replace: "\\1NameVirtualHost {{ apache_listen_ip }}:{{ apache_listen_port }}"
}

0 comments on commit 2673b0d

Please sign in to comment.