Skip to content

Commit

Permalink
Added variable apache_install true. Fixed lint. Formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
vbotka committed Oct 20, 2019
1 parent 6c7839a commit 750e0ad
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 65 deletions.
12 changes: 7 additions & 5 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
---
# defaults for vbotka.apache

apache_enable: True
apache_debug: False
apache_ssl: False
apache_php: False
apache_backup_conf: no
apache_install: true
apache_enable: true
apache_debug: false
apache_ssl: false
apache_php: false
apache_backup_conf: false

apache_SSLEngine: "off"

# httpd.conf
Expand Down
10 changes: 5 additions & 5 deletions docs/examples/host_vars/srv.example.com/apache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ apache_confd_dir_vhosts: "{{ playbook_dir }}/servers/apache.d/vhosts"
apache_confd_dir_sections: "{{ playbook_dir }}/servers/apache.d/sections"

apache_httpd_conf_modules:
- { module: "socache_shmcb_module", mod: "mod_socache_shmcb.so" }
- { module: "ssl_module", mod: "mod_ssl.so" }
- { module: "php{{ apache_php_lib }}_module", mod: "libphp{{ apache_php_lib }}.so" }
- { module: "cgi_module", mod: "mod_cgi.so", present: true }
- { module: "cgid_module", mod: "mod_cgid.so", present: true }
- {module: "socache_shmcb_module", mod: "mod_socache_shmcb.so"}
- {module: "ssl_module", mod: "mod_ssl.so"}
- {module: "php{{ apache_php_lib }}_module", mod: "libphp{{ apache_php_lib }}.so"}
- {module: "cgi_module", mod: "mod_cgi.so", present: true}
- {module: "cgid_module", mod: "mod_cgid.so", present: true}

apache_directory_blocks: {}
apache_vhost: {}
Expand Down
24 changes: 12 additions & 12 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
---
# handlers for vbotka.apache

- name: enable and start apache
- name: "enable and start apache"
service:
name: "{{ apache_service }}"
state: started
enabled: yes
state: "started"
enabled: true

- name: disable and stop apache
- name: "disable and stop apache"
service:
name: "{{ apache_service }}"
state: stopped
enabled: no
state: "stopped"
enabled: false

- name: restart apache
- name: "restart apache"
when: apache_enable|bool
service:
name: "{{ apache_service }}"
state: restarted
state: "restarted"

- name: reload apache
- name: "reload apache"
when: apache_enable|bool
service:
name: "{{ apache_service }}"
state: reloaded
state: "reloaded"

- name: graceful apache
- name: "graceful apache"
when: apache_enable|bool
command: "/usr/local/etc/rc.d/{{ apache_service }} graceful"

- name: gracefulstop apache
- name: "gracefulstop apache"
when: apache_enable|bool
command: "/usr/local/etc/rc.d/{{ apache_service }} gracefulstop"

Expand Down
59 changes: 31 additions & 28 deletions tasks/debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,46 @@
- name: "Apache Debug"
vars:
msg: |
ansible_architecture [ {{ ansible_architecture }} ]
ansible_os_family [ {{ ansible_os_family }} ]
ansible_distribution [ {{ ansible_distribution }} ]
ansible_distribution_major_version [ {{ ansible_distribution_major_version }} ]
ansible_distribution_version [ {{ ansible_distribution_version }} ]
ansible_distribution_release [ {{ ansible_distribution_release }} ]
ansible_architecture [{{ ansible_architecture }}]
ansible_os_family [{{ ansible_os_family }}]
ansible_distribution [{{ ansible_distribution }}]
ansible_distribution_major_version [{{ ansible_distribution_major_version }}]
ansible_distribution_version [{{ ansible_distribution_version }}]
ansible_distribution_release [{{ ansible_distribution_release }}]
apache_enable [ {{ apache_enable }} ]
apache_ssl [ {{ apache_ssl }} ]
apache_SSLEngine [ {{ apache_SSLEngine }} ]
apache_php [ {{ apache_php }} ]
apache_backup_conf [ {{ apache_backup_conf }} ]
apache_ServerName [ {{ apache_ServerName }} ]
apache_ServerAdmin [ {{ apache_ServerAdmin }} ]
apache_dir [ {{ apache_dir }} ]
apache_service [ {{ apache_service }} ]
apache_conf_path [ {{ apache_conf_path }} ]
apache_httpd_conf
{{ apache_httpd_conf | to_yaml }}
apache_install [{{ apache_install }}]
apache_packages
{{ apache_packages | to_nice_yaml }}
{{ apache_packages|to_nice_yaml }}
apache_enable [{{ apache_enable }}]
apache_ssl [{{ apache_ssl }}]
apache_SSLEngine [{{ apache_SSLEngine }}]
apache_php [{{ apache_php }}]
apache_backup_conf [{{ apache_backup_conf }}]
apache_ServerName [{{ apache_ServerName }}]
apache_ServerAdmin [{{ apache_ServerAdmin }}]
apache_dir [{{ apache_dir }}]
apache_service [{{ apache_service }}]
apache_conf_path [{{ apache_conf_path }}]
apache_httpd_conf
{{ apache_httpd_conf|to_yaml }}
apache_httpd_conf_modules
{{ apache_httpd_conf_modules | to_yaml }}
{{ apache_httpd_conf_modules|to_yaml }}
apache_httpd_conf_ssl
{{ apache_httpd_conf_ssl | to_nice_yaml }}
{{ apache_httpd_conf_ssl|to_nice_yaml }}
apache_httpd_conf_ssl_extra
{{ apache_httpd_conf_ssl_extra | to_yaml }}
{{ apache_httpd_conf_ssl_extra|to_yaml }}
apache_httpd_conf_ssl_extra_absent
{{ apache_httpd_conf_ssl_extra_absent | to_yaml }}
{{ apache_httpd_conf_ssl_extra_absent|to_yaml }}
apache_vhost
{{ apache_vhost | to_nice_yaml }}
{{ apache_vhost|to_nice_yaml }}
apache_directory_blocks
{{ apache_directory_blocks | to_nice_yaml }}
{{ apache_directory_blocks|to_nice_yaml }}
apache_alias
{{ apache_alias | to_nice_yaml }}
apache_confd_dir_vhosts [ {{ apache_confd_dir_vhosts }} ]
apache_confd_dir_sections [ {{ apache_confd_dir_sections }} ]
{{ apache_alias|to_nice_yaml }}
apache_confd_dir_vhosts [{{ apache_confd_dir_vhosts }}]
apache_confd_dir_sections [{{ apache_confd_dir_sections }}]
debug:
msg: "{{ msg.split('\n') }}"

Expand Down
2 changes: 1 addition & 1 deletion tasks/fn/httpd-confd-vhost-dirs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: "httpd-confd-vhost-dirs: Create directories for virtual hosts"
file:
state: directory
state: "directory"
path: "{{ vhost_dir }}"
owner: "{{ apache_data_owner }}"
group: "{{ apache_data_group }}"
Expand Down
6 changes: 3 additions & 3 deletions tasks/httpd-confd-vhosts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
al_include_confd_vars_list_type: "fname"
- name: "httpd-confd-vhosts: Include al_include_confd_vars_list"
include_role:
name: vbotka.ansible_lib
tasks_from: al_include_confd_vars_list
name: "vbotka.ansible_lib"
tasks_from: "al_include_confd_vars_list"
- name: "httpd-confd-vhosts: Debug al_include_confd_vars_list"
when: apache_debug|bool
debug:
Expand All @@ -23,7 +23,7 @@
loop: "{{ al_include_confd_vars_list|json_query('[].vars') }}"

- name: "httpd-confd-vhosts: Create directories for virtual hosts"
include_tasks: fn/httpd-confd-vhost-dirs.yml
include_tasks: "fn/httpd-confd-vhost-dirs.yml"
loop: "{{ al_include_confd_vars_list|json_query('[].vars') }}"

- name: "httpd-confd-vhosts: Configure virtual hosts in {{ apache_conf_path }}/extra/"
Expand Down
4 changes: 2 additions & 2 deletions tasks/httpd-confd.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---

- name: "httpd-confd: Configure virtual hosts from {{ apache_confd_dir_vhosts }}"
import_tasks: httpd-confd-vhosts.yml
import_tasks: "httpd-confd-vhosts.yml"
tags: apache-httpd-confd-vhosts

- name: "httpd-confd: Configure includes from {{ apache_confd_dir_sections }}"
import_tasks: httpd-confd-includes.yml
import_tasks: "httpd-confd-includes.yml"
tags: apache-httpd-confd-includes

# EOF
Expand Down
2 changes: 1 addition & 1 deletion tasks/httpd-ssl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
notify: reload apache
- name: "httpd-ssl: Absent extra lines in {{ apache_conf_path }}/extra/httpd-ssl.conf"
lineinfile:
state: absent
state: "absent"
dest: "{{ apache_conf_path }}/extra/httpd-ssl.conf"
regexp: "{{ item }}"
backup: "{{ apache_backup_conf }}"
Expand Down
2 changes: 1 addition & 1 deletion tasks/httpd-vhosts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

- name: "httpd-vhosts: Create directories for virtual hosts"
file:
state: directory
state: "directory"
path: "{{ item.DocumentRoot }}"
owner: "{{ apache_data_owner }}"
group: "{{ apache_data_group }}"
Expand Down
1 change: 1 addition & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
tags: [apache-debug, always]

- import_tasks: packages.yml
when: apache_install|bool
tags: apache-packages

- import_tasks: httpd.yml
Expand Down
6 changes: 3 additions & 3 deletions tasks/packages-freebsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
name: "{{ item }}"
loop: "{{ apache_packages }}"
register: result
retries: "{{ freebsd_install_retries }}"
until: result is succeeded
retries: "{{ freebsd_install_retries }}"
delay: "{{ freebsd_install_delay }}"

- name: "packages: Install ports"
when: freebsd_install_method == "ports"
portinstall:
name: "{{ item }}"
use_packages: "{{ freebsd_use_packages|default(True) }}"
use_packages: "{{ freebsd_use_packages|default(true) }}"
loop: "{{ apache_packages }}"
register: result
retries: "{{ freebsd_install_retries }}"
until: result is succeeded
retries: "{{ freebsd_install_retries }}"
delay: "{{ freebsd_install_delay }}"

# EOF
Expand Down
2 changes: 1 addition & 1 deletion tasks/packages.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

- name: "packages: Install FreeBSD packages"
import_tasks: packages-freebsd.yml
import_tasks: "packages-freebsd.yml"
when: ansible_os_family == "FreeBSD"

# EOF
Expand Down
2 changes: 1 addition & 1 deletion tasks/service.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

- name: "service: Config FreeBSD"
import_tasks: rcconf.yml
import_tasks: "rcconf.yml"
when: ansible_os_family == "FreeBSD"

# EOF
Expand Down
4 changes: 2 additions & 2 deletions tasks/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
al_os_vars_path: "{{ role_path }}"
- name: "vars: Include OS vars"
include_role:
name: vbotka.ansible_lib
tasks_from: al_include_os_vars_path.yml
name: "vbotka.ansible_lib"
tasks_from: "al_include_os_vars_path.yml"

# EOF
...

0 comments on commit 750e0ad

Please sign in to comment.