From e0d90927794a58b1c97e151c3c98c106190801da Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Wed, 12 Aug 2020 14:52:03 -0500 Subject: [PATCH 1/9] Upgrade Travis CI docker version to fix Molecule tests. --- .travis.yml | 4 ++++ .yamllint | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index 14fa2dd9..8d349d0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,10 @@ env: - MOLECULE_DISTRO: debian10 - MOLECULE_DISTRO: debian9 +before_install: + # Upgrade Docker to work with docker-py. + - curl https://gist.githubusercontent.com/geerlingguy/ce883ad4aec6a5f1187ef93bd338511e/raw/36612d28981d92863f839c5aefe5b7dd7193d6c6/travis-ci-docker-upgrade.sh | sudo bash + install: # Install test dependencies. - pip install molecule yamllint ansible-lint docker diff --git a/.yamllint b/.yamllint index a3dbc38e..76a383c6 100644 --- a/.yamllint +++ b/.yamllint @@ -1,6 +1,10 @@ --- extends: default + rules: line-length: max: 120 level: warning + +ignore: | + .github/stale.yml From 04600b45f600b15998bfab3526b72e97ce90dcbc Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Thu, 20 Aug 2020 12:22:09 -0500 Subject: [PATCH 2/9] Fix linting issues. --- .yamllint | 1 + tasks/configure-Debian.yml | 3 +++ tasks/configure-RedHat.yml | 1 + tasks/configure-Solaris.yml | 1 + tasks/configure-Suse.yml | 1 + 5 files changed, 7 insertions(+) diff --git a/.yamllint b/.yamllint index 76a383c6..f2033dd2 100644 --- a/.yamllint +++ b/.yamllint @@ -8,3 +8,4 @@ rules: ignore: | .github/stale.yml + .travis.yml diff --git a/tasks/configure-Debian.yml b/tasks/configure-Debian.yml index e115e61e..e9b2ad43 100644 --- a/tasks/configure-Debian.yml +++ b/tasks/configure-Debian.yml @@ -5,6 +5,7 @@ regexp: "{{ item.regexp }}" line: "{{ item.line }}" state: present + mode: 0644 with_items: "{{ apache_ports_configuration_items }}" notify: restart apache @@ -13,6 +14,7 @@ src: "{{ apache_server_root }}/mods-available/{{ item }}" dest: "{{ apache_server_root }}/mods-enabled/{{ item }}" state: link + mode: 0644 with_items: "{{ apache_mods_enabled }}" notify: restart apache @@ -43,6 +45,7 @@ src: "{{ apache_conf_path }}/sites-available/{{ apache_vhosts_filename }}" dest: "{{ apache_conf_path }}/sites-enabled/{{ apache_vhosts_filename }}" state: link + mode: 0644 notify: restart apache when: apache_create_vhosts | bool diff --git a/tasks/configure-RedHat.yml b/tasks/configure-RedHat.yml index 95675e45..85774614 100644 --- a/tasks/configure-RedHat.yml +++ b/tasks/configure-RedHat.yml @@ -5,6 +5,7 @@ regexp: "{{ item.regexp }}" line: "{{ item.line }}" state: present + mode: 0644 with_items: "{{ apache_ports_configuration_items }}" notify: restart apache diff --git a/tasks/configure-Solaris.yml b/tasks/configure-Solaris.yml index b6c121ba..2fbf8320 100644 --- a/tasks/configure-Solaris.yml +++ b/tasks/configure-Solaris.yml @@ -5,6 +5,7 @@ regexp: "{{ item.regexp }}" line: "{{ item.line }}" state: present + mode: 0644 with_items: "{{ apache_ports_configuration_items }}" notify: restart apache diff --git a/tasks/configure-Suse.yml b/tasks/configure-Suse.yml index 54d4d1c1..9f084cfd 100644 --- a/tasks/configure-Suse.yml +++ b/tasks/configure-Suse.yml @@ -5,6 +5,7 @@ regexp: "{{ item.regexp }}" line: "{{ item.line }}" state: present + mode: 0644 with_items: "{{ apache_ports_configuration_items }}" notify: restart apache From 0e8c90d88ede387d8253e2b47dfd8783031988b3 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Thu, 20 Aug 2020 19:19:01 -0500 Subject: [PATCH 3/9] Ignore the tyranny of ansible-lint rule 106. --- .ansible-lint | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .ansible-lint diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 00000000..55572942 --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,2 @@ +skip_list: + - '106' From 2277b6178c17afcc6137115541ffd14210b3c8ff Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Thu, 15 Oct 2020 17:01:59 -0500 Subject: [PATCH 4/9] Make sure docker driver is installed with molecule. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8d349d0f..92547cb6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ before_install: install: # Install test dependencies. - - pip install molecule yamllint ansible-lint docker + - pip install molecule[docker] yamllint ansible-lint docker before_script: # Use actual Ansible Galaxy role name for the project directory. From 358d78970089564c55350bbde09ef584b8c1c28a Mon Sep 17 00:00:00 2001 From: Nico Bellack Date: Mon, 26 Oct 2020 17:19:36 +0100 Subject: [PATCH 5/9] Deploy vhost files to vhosts.d on RHEL 8 --- tasks/configure-RedHat.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tasks/configure-RedHat.yml b/tasks/configure-RedHat.yml index 4bc6280b..bcb74de6 100644 --- a/tasks/configure-RedHat.yml +++ b/tasks/configure-RedHat.yml @@ -1,4 +1,8 @@ --- +- name: Change vhosts path on RHEL 8 hosts + set_fact: + _apache_vhosts_path: "{{ apache_server_root + '/vhosts.d' if ansible_pkg_mgr == 'dnf' else apache_conf_path }}" + - name: Install SELinux Python dependencies. package: name: >- @@ -75,7 +79,7 @@ - name: Add apache vhosts configuration. template: src: "{{ apache_vhosts_template }}" - dest: "{{ apache_conf_path }}/{{ apache_vhosts_filename }}" + dest: "{{ _apache_vhosts_path }}/{{ apache_vhosts_filename }}" owner: root group: root mode: 0644 @@ -84,7 +88,7 @@ - name: Remove apache vhosts configuration. file: - path: "{{ apache_conf_path }}/{{ apache_vhosts_filename }}" + path: "{{ _apache_vhosts_path }}/{{ apache_vhosts_filename }}" state: absent notify: restart apache when: not apache_create_vhosts From 9efa0ca6d8e0652ea002693b18c1a3b988f7b40a Mon Sep 17 00:00:00 2001 From: Nico Bellack Date: Mon, 26 Oct 2020 17:47:55 +0100 Subject: [PATCH 6/9] Improve variable handling; update README and defaults --- README.md | 5 +++++ defaults/main.yml | 4 ++++ tasks/configure-RedHat.yml | 8 ++------ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 113da0d8..8689eacb 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,11 @@ If you have enabled any additional repositories such as _ondrej/apache2_, [geerl If you would like to only create SSL vhosts when the vhost certificate is present (e.g. when using Let’s Encrypt), set `apache_ignore_missing_ssl_certificate` to `false`. When doing this, you might need to run your playbook more than once so all the vhosts are configured (if another part of the playbook generates the SSL certificates). + #apache_rhel_custom_vhosts_path: /etc/httpd/vhosts.d + +On RHEL/CentOS, in some occasions you might want to use a custom directory for your +virtual host files instead of `/etc/httpd/conf.d`. Use this variable then. + ## .htaccess-based Basic Authorization If you require Basic Auth support, you can add it either through a custom template, or by adding `extra_parameters` to a VirtualHost configuration, like so: diff --git a/defaults/main.yml b/defaults/main.yml index 009a9689..47ca7493 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -62,3 +62,7 @@ apache_restart_state: restarted # Apache package state; use `present` to make sure it's installed, or `latest` # if you want to upgrade or switch versions using a new repo. apache_packages_state: present + +# On RHEL/CentOS, in some occasions you might want to use a custom directory for your +# virtual host files instead of /etc/httpd/conf.d. Use this variable then. +#apache_rhel_custom_vhosts_path: /etc/httpd/vhosts.d \ No newline at end of file diff --git a/tasks/configure-RedHat.yml b/tasks/configure-RedHat.yml index bcb74de6..620bfd5a 100644 --- a/tasks/configure-RedHat.yml +++ b/tasks/configure-RedHat.yml @@ -1,8 +1,4 @@ --- -- name: Change vhosts path on RHEL 8 hosts - set_fact: - _apache_vhosts_path: "{{ apache_server_root + '/vhosts.d' if ansible_pkg_mgr == 'dnf' else apache_conf_path }}" - - name: Install SELinux Python dependencies. package: name: >- @@ -79,7 +75,7 @@ - name: Add apache vhosts configuration. template: src: "{{ apache_vhosts_template }}" - dest: "{{ _apache_vhosts_path }}/{{ apache_vhosts_filename }}" + dest: "{{ apache_rhel_custom_vhosts_path | default(apache_conf_path) }}/{{ apache_vhosts_filename }}" owner: root group: root mode: 0644 @@ -88,7 +84,7 @@ - name: Remove apache vhosts configuration. file: - path: "{{ _apache_vhosts_path }}/{{ apache_vhosts_filename }}" + path: "{{ apache_rhel_custom_vhosts_path | default(apache_conf_path) }}/{{ apache_vhosts_filename }}" state: absent notify: restart apache when: not apache_create_vhosts From 8eaa30ca47ccd001b3d5f573383ed5929854e655 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Mon, 26 Oct 2020 20:08:25 -0500 Subject: [PATCH 7/9] Switch to travis-ci.com. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b4f52ec4..eab7e8c6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Ansible Role: Apache 2.x -[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-apache.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-apache) +[![Build Status](https://travis-ci.com/geerlingguy/ansible-role-apache.svg?branch=master)](https://travis-ci.com/geerlingguy/ansible-role-apache) An Ansible Role that installs Apache 2.x on RHEL/CentOS, Debian/Ubuntu, SLES and Solaris. From 5aa60e3e49c07390c169e2f710faea7586dcc676 Mon Sep 17 00:00:00 2001 From: Nico Bellack Date: Tue, 27 Oct 2020 12:51:06 +0100 Subject: [PATCH 8/9] Add newline at end of file to satisfy ansible lint --- defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 47ca7493..056d84d0 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -65,4 +65,4 @@ apache_packages_state: present # On RHEL/CentOS, in some occasions you might want to use a custom directory for your # virtual host files instead of /etc/httpd/conf.d. Use this variable then. -#apache_rhel_custom_vhosts_path: /etc/httpd/vhosts.d \ No newline at end of file +#apache_rhel_custom_vhosts_path: /etc/httpd/vhosts.d From 83f2c81e5af0ba30e8f4e80d735f5c102018dd63 Mon Sep 17 00:00:00 2001 From: Nico Bellack Date: Tue, 27 Oct 2020 16:00:17 +0100 Subject: [PATCH 9/9] Use apache2_module again instead of upstream-way --- tasks/configure-Debian.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tasks/configure-Debian.yml b/tasks/configure-Debian.yml index 84d750f7..4564203a 100644 --- a/tasks/configure-Debian.yml +++ b/tasks/configure-Debian.yml @@ -20,11 +20,9 @@ notify: restart apache - name: Enable Apache mods. - file: - src: "{{ apache_server_root }}/mods-available/{{ item }}" - dest: "{{ apache_server_root }}/mods-enabled/{{ item }}" - state: link - mode: 0644 + apache2_module: + name: "{{ item | regex_replace('(\\w+)\\.load','\\1') }}" + state: present with_items: "{{ apache_mods_enabled }}" notify: restart apache