From e0381502e3fb3385c8af10ded27dfa4c71adb558 Mon Sep 17 00:00:00 2001 From: Rick Box Date: Fri, 3 Feb 2017 04:07:30 +0000 Subject: [PATCH] Adds in Apache2 role - Ubuntu 16.04 Building on from the previous commit https://review.openstack.org/427869 this adds in Apache2 role to host the pre-seed files and some Ubuntu install files. Change-Id: Ib0c2469e25f5e7a03c7c79efc201cd51f673966e --- .../roles/apache_install/README.md | 23 +++++++++++ .../roles/apache_install/defaults/main.yml | 26 ++++++++++++ .../roles/apache_install/handlers/main.yml | 20 ++++++++++ .../roles/apache_install/meta/main.yml | 22 ++++++++++ .../roles/apache_install/tasks/configure.yml | 40 +++++++++++++++++++ .../roles/apache_install/tasks/install.yml | 25 ++++++++++++ .../roles/apache_install/tasks/main.yml | 18 +++++++++ .../apache_install/templates/sites-allowed.j2 | 7 ++++ 8 files changed, 181 insertions(+) create mode 100644 multi-node-aio-xenial-ansible/roles/apache_install/README.md create mode 100644 multi-node-aio-xenial-ansible/roles/apache_install/defaults/main.yml create mode 100644 multi-node-aio-xenial-ansible/roles/apache_install/handlers/main.yml create mode 100644 multi-node-aio-xenial-ansible/roles/apache_install/meta/main.yml create mode 100644 multi-node-aio-xenial-ansible/roles/apache_install/tasks/configure.yml create mode 100644 multi-node-aio-xenial-ansible/roles/apache_install/tasks/install.yml create mode 100644 multi-node-aio-xenial-ansible/roles/apache_install/tasks/main.yml create mode 100644 multi-node-aio-xenial-ansible/roles/apache_install/templates/sites-allowed.j2 diff --git a/multi-node-aio-xenial-ansible/roles/apache_install/README.md b/multi-node-aio-xenial-ansible/roles/apache_install/README.md new file mode 100644 index 00000000..acffb058 --- /dev/null +++ b/multi-node-aio-xenial-ansible/roles/apache_install/README.md @@ -0,0 +1,23 @@ +apache_install +========= + +This module installs Apache2 and configures a site + +Requirements +------------ + +This module requires Ansible 2.0+ + +Role Variables +-------------- + +See defaults for variables and descriptions + +Example Playbook +---------------- + +Example to call: + + - hosts: all + roles: + - { role: url: default } diff --git a/multi-node-aio-xenial-ansible/roles/apache_install/defaults/main.yml b/multi-node-aio-xenial-ansible/roles/apache_install/defaults/main.yml new file mode 100644 index 00000000..de387956 --- /dev/null +++ b/multi-node-aio-xenial-ansible/roles/apache_install/defaults/main.yml @@ -0,0 +1,26 @@ +--- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# name: apache_install/defaults +# description: ALL our default variables for apache_install go in here +#------------------------------------------------------------------------------ +# Packages - All our required packages we need installing +#------------------------------------------------------------------------------ + +# - pre-requisites - +packages: # Packages required for apache role to work + - apache2 + +# - variables - +url: blank # Default sub folder +publish_root: blank # What will the default path be for the apache site diff --git a/multi-node-aio-xenial-ansible/roles/apache_install/handlers/main.yml b/multi-node-aio-xenial-ansible/roles/apache_install/handlers/main.yml new file mode 100644 index 00000000..7c223848 --- /dev/null +++ b/multi-node-aio-xenial-ansible/roles/apache_install/handlers/main.yml @@ -0,0 +1,20 @@ +--- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# name: apache_install/handlers +# description: All our handlers for apache_install go in here + +- name: restart_apache2 + service: + name: apache2 + state: restarted diff --git a/multi-node-aio-xenial-ansible/roles/apache_install/meta/main.yml b/multi-node-aio-xenial-ansible/roles/apache_install/meta/main.yml new file mode 100644 index 00000000..40077de8 --- /dev/null +++ b/multi-node-aio-xenial-ansible/roles/apache_install/meta/main.yml @@ -0,0 +1,22 @@ +--- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +galaxy_info: + author: "Stuart Grace - BBC R&D" + license: Apache2 + min_ansible_version: 2.0 + platforms: + - name: Ubuntu + versions: + - xenial +dependencies: [] diff --git a/multi-node-aio-xenial-ansible/roles/apache_install/tasks/configure.yml b/multi-node-aio-xenial-ansible/roles/apache_install/tasks/configure.yml new file mode 100644 index 00000000..f5acd554 --- /dev/null +++ b/multi-node-aio-xenial-ansible/roles/apache_install/tasks/configure.yml @@ -0,0 +1,40 @@ +--- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# module: apache_install/tasks/configure +# description: Configure apache_install + +- name: Create default index to show host info + copy: + content: "System - {{ ansible_fqdn }}" + dest: /var/www/html/index.html + +- name: Create control file for apache site + template: + src: sites-allowed.j2 + dest: "/etc/apache2/sites-available/{{ url }}.conf" + mode: 0644 + notify: restart_apache2 + +- name: Create publish root path + file: + path: "{{ publish_root }}" + state: directory + recurse: yes + +- name: Enable apache site using symlink + file: + path: "/etc/apache2/sites-enabled/{{ url }}.conf" + src: "/etc/apache2/sites-available/{{ url }}.conf" + state: link + notify: restart_apache2 diff --git a/multi-node-aio-xenial-ansible/roles/apache_install/tasks/install.yml b/multi-node-aio-xenial-ansible/roles/apache_install/tasks/install.yml new file mode 100644 index 00000000..b3b46f0a --- /dev/null +++ b/multi-node-aio-xenial-ansible/roles/apache_install/tasks/install.yml @@ -0,0 +1,25 @@ +--- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# module: apache_install/tasks/install +# description: Install our required packages for apache_install + +- name: Install all required packages for apache_install + apt: + pkg: "{{ packages }}" + state: latest + +- name: Make sure Apache2 is enabled + service: + name: apache2 + enabled: yes diff --git a/multi-node-aio-xenial-ansible/roles/apache_install/tasks/main.yml b/multi-node-aio-xenial-ansible/roles/apache_install/tasks/main.yml new file mode 100644 index 00000000..de5dbba4 --- /dev/null +++ b/multi-node-aio-xenial-ansible/roles/apache_install/tasks/main.yml @@ -0,0 +1,18 @@ +--- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# module: apache_install/tasks +# description: Install apache onto an Ubuntu 16.xx server + +- include: install.yml +- include: configure.yml diff --git a/multi-node-aio-xenial-ansible/roles/apache_install/templates/sites-allowed.j2 b/multi-node-aio-xenial-ansible/roles/apache_install/templates/sites-allowed.j2 new file mode 100644 index 00000000..35252335 --- /dev/null +++ b/multi-node-aio-xenial-ansible/roles/apache_install/templates/sites-allowed.j2 @@ -0,0 +1,7 @@ +### MANAGED BY {{ role_path|basename }} ANSIBLE ROLE ### + +Alias /{{ url }} {{ publish_root }} + + Require all granted + Options +Indexes +