From 170a9c2446184130721e393dc608068d90069a34 Mon Sep 17 00:00:00 2001 From: liquidat Date: Mon, 1 Feb 2016 10:37:57 +0100 Subject: [PATCH] Add Suse support - set proper package and service name apache2 - configure given packages for Suse - install packages - start service --- tasks/configure-Suse.yml | 24 ++++++++++++++++++++++++ tasks/main.yml | 6 ++++++ tasks/setup-Suse.yml | 6 ++++++ vars/Suse.yml | 19 +++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 tasks/configure-Suse.yml create mode 100644 tasks/setup-Suse.yml create mode 100644 vars/Suse.yml diff --git a/tasks/configure-Suse.yml b/tasks/configure-Suse.yml new file mode 100644 index 0000000..3df9692 --- /dev/null +++ b/tasks/configure-Suse.yml @@ -0,0 +1,24 @@ +--- +- name: Configure Apache. + lineinfile: + dest: "{{ apache_server_root }}/conf/{{ apache_daemon }}.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 diff --git a/tasks/main.yml b/tasks/main.yml index d60a115..0715fc2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -12,6 +12,9 @@ - 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' @@ -39,6 +42,9 @@ - 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' diff --git a/tasks/setup-Suse.yml b/tasks/setup-Suse.yml new file mode 100644 index 0000000..21e4967 --- /dev/null +++ b/tasks/setup-Suse.yml @@ -0,0 +1,6 @@ +--- +- name: Ensure Apache is installed. + zypper: + name: "{{ item }}" + state: installed + with_items: apache_packages diff --git a/vars/Suse.yml b/vars/Suse.yml new file mode 100644 index 0000000..38ec749 --- /dev/null +++ b/vars/Suse.yml @@ -0,0 +1,19 @@ +--- +apache_service: apache2 +apache_daemon: apache2 +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 + - apache2-devel + - openssh + +apache_ports_configuration_items: + - regexp: "^Listen " + line: "Listen {{ apache_listen_port }}" + - regexp: "^#?NameVirtualHost " + line: "NameVirtualHost *:{{ apache_listen_port }}"