Tasks

main.yml

Synopsis: Main task.

Import tasks if enabled.

[tasks/main.yml]

 1---
 2# tasks for vbotka.apache
 3
 4- name: Include OS vars.
 5  ansible.builtin.import_tasks: vars.yml
 6  tags: [apache_vars, always]
 7
 8- name: Display variables.
 9  ansible.builtin.import_tasks: debug.yml
10  when: apache_debug | bool
11  tags: apache_debug
12
13- name: Sanity.
14  ansible.builtin.import_tasks: sanity.yml
15  when: apache_sanity | bool
16  tags: apache_sanity
17
18- name: Install packages.
19  ansible.builtin.import_tasks: pkg.yml
20  when: apache_install | bool
21  tags: apache_pkg
22
23- name: Copy sample files.
24  ansible.builtin.import_tasks: samples.yml
25  when: apache_samples | bool
26  tags: apache_samples
27
28- name: Configure httpd.conf
29  ansible.builtin.import_tasks: httpd.yml
30  tags: apache_httpd
31
32- name: Configure Includes
33  ansible.builtin.import_tasks: httpd-dirs.yml
34  tags: apache_httpd_dirs
35
36- name: Configure LoadModule in httpd.conf
37  ansible.builtin.import_tasks: httpd-modules.yml
38  tags: apache_httpd_modules
39
40- name: Configure PHP in Includes
41  ansible.builtin.import_tasks: httpd-php.yml
42  when: apache_php | bool
43  tags: apache_httpd_php
44
45- name: Configure aliases in httpd.conf
46  ansible.builtin.import_tasks: httpd-alias.yml
47  tags: apache_httpd_alias
48
49- name: Configure SSL.
50  ansible.builtin.import_tasks: httpd-ssl.yml
51  when: apache_ssl | bool
52  tags: apache_httpd_ssl
53
54- name: Configure virtual hosts.
55  ansible.builtin.import_tasks: httpd-vhosts.yml
56  tags: apache_httpd_vhosts
57
58- name: Configure virtual hosts from vars/conf.d
59  ansible.builtin.import_tasks: httpd-confd.yml
60  when: apache_confd | bool
61  tags: apache_httpd_confd
62
63- name: Configure service.
64  ansible.builtin.import_tasks: service.yml
65  tags: apache_service
66
67# EOF

vars.yml

Synopsis: Include OS specific variables from the role’s directory vars.

OS specific default variables will be loaded from the files in the directories vars and vars/defaults. OS specific custom variables, that will override default values, can be loaded from the files in the directory vars.

[tasks/vars.yml]

1---
2- name: "Vars: Include OS vars."  # noqa: var-naming[no-role-prefix]
3  vars:
4    al_os_vars_path: "{{ ansible_parent_role_paths.0 }}"
5  ansible.builtin.include_role:
6    name: "{{ apache_ansible_lib[ansible_role_name] }}"
7    tasks_from: al_include_os_vars_path
8
9# EOF

See also

Note

  • Put OS specific variables here.

  • Because of the precedence (15.role vars), there are limited options to override these variables.

Hint

Warning

  • Put customized OS specific variables into the files in the dictionary vars/

  • Changes stored in the directory vars/defaults will be overwritten by an update of the role.

debug.yml

Synopsis: Configure debug

Description of the task.

[tasks/debug.yml]

 1---
 2- name: Debug
 3  vars:
 4    msg: |-
 5      apache_role_version: {{ apache_role_version }}
 6      ansible_role_name: {{ ansible_role_name }}
 7
 8      ansible_facts.architecture: {{ ansible_facts.architecture }}
 9      ansible_facts.os_family: {{ ansible_facts.os_family }}
10      ansible_facts.distribution: {{ ansible_facts.distribution }}
11      ansible_facts.distribution_major_version: {{ ansible_facts.distribution_major_version }}
12      ansible_facts.distribution_version: {{ ansible_facts.distribution_version }}
13      ansible_facts.distribution_release: {{ ansible_facts.distribution_release }}
14      ansible_facts.python_version: {{ ansible_facts.python_version }}
15
16      apache_backup_conf: {{ apache_backup_conf | bool }}
17      apache_install: {{ apache_install | bool }}
18      apache_version: {{ apache_version }}
19      apache_packages:
20        {{ apache_packages | to_nice_yaml(indent=2) | indent(2) }}
21      apache_enable: {{ apache_enable | bool }}
22      apache_rcconf:
23        {{ apache_rcconf | to_yaml(indent=2) | indent(2) }}
24      apache_ssl: {{ apache_ssl | bool }}
25      apache_sslengine: {{ apache_sslengine }}
26      apache_servername: {{ apache_servername }}
27      apache_serveradmin: {{ apache_serveradmin }}
28      apache_dir: {{ apache_dir }}
29      apache_service: {{ apache_service }}
30      apache_conf_path: {{ apache_conf_path }}
31      apache_httpd_conf:
32        {{ apache_httpd_conf | to_yaml(indent=2) | indent(2) }}
33      apache_httpd_conf_modules:
34        {{ apache_httpd_conf_modules | to_yaml(indent=2) | indent(2) }}
35      apache_httpd_conf_ssl:
36        {{ apache_httpd_conf_ssl | to_nice_yaml(indent=2) | indent(2) }}
37      apache_httpd_conf_ssl_extra:
38        {{ apache_httpd_conf_ssl_extra | to_yaml(indent=2) | indent(2) }}
39      apache_httpd_conf_ssl_extra_absent:
40        {{ apache_httpd_conf_ssl_extra_absent | to_yaml(indent=2) | indent(2) }}
41      apache_vhost:
42        {{ apache_vhost | to_nice_yaml(indent=2) | indent(2) }}
43      apache_directory_blocks:
44        {{ apache_directory_blocks | to_nice_yaml(indent=2) | indent(2) }}
45      apache_alias:
46        {{ apache_alias | to_nice_yaml(indent=2) | indent(2) }}
47      apache_confd: {{ apache_confd }}
48      apache_confd_dir_vhosts: {{ apache_confd_dir_vhosts }}
49      apache_confd_dir_sections: {{ apache_confd_dir_sections }}
50
51      apache_samples: {{ apache_samples | bool }}
52      apache_samples_list:
53        {{ apache_samples_list | to_nice_yaml(indent=2) | indent(2) }}
54      apache_php: {{ apache_php | bool }}
55      apache_php_fpm: {{ apache_php_fpm | bool }}
56      apache_php_blocks:
57        {{ apache_php_blocks | to_nice_yaml(indent=2) | indent(2) }}
58      apache_sanity: {{ apache_sanity | bool }}
59  ansible.builtin.debug:
60    msg: "{{ '{}'.format(msg) }}"
61
62# EOF

sanity.yml

Synopsis: Configure sanity

Description of the task.

[tasks/sanity.yml]

1---
2- name: "Sanity: Enable apache_php_fpm if apache_php enabled."
3  when: apache_php_fpm | bool
4  ansible.builtin.assert:
5    that: apache_php | bool
6    fail_msg: "[ERR] apache_php must be enabled when apache_php_fpm is enabled."
7
8# EOF

pkg.yml

Synopsis: Configure pkg

Description of the task.

[tasks/pkg.yml]

1---
2- name: "Pkg: Install FreeBSD packages"
3  ansible.builtin.import_tasks: pkg-freebsd.yml
4  when: ansible_facts.os_family == 'FreeBSD'
5
6# EOF

pkg-freebsd.yml

Synopsis: Configure pkg-freebsd

Description of the task.

[tasks/pkg-freebsd.yml]

 1---
 2- name: Install packages
 3  when: freebsd_install_method == 'packages'
 4  block:
 5
 6    - name: "Packages: Install packages."
 7      community.general.pkgng:
 8        name: "{{ apache_packages }}"
 9      register: result
10      until: result is succeeded
11      retries: "{{ freebsd_install_retries }}"
12      delay: "{{ freebsd_install_delay }}"
13
14    - name: "Packages: Debug install packages apache_debug={{ apache_debug }}"
15      when: apache_debug | bool
16      ansible.builtin.debug:
17        var: result
18
19- name: Install ports
20  when: freebsd_install_method == 'ports'
21  block:
22
23    - name: "Packages: Install ports."
24      community.general.portinstall:
25        name: "{{ item }}"
26        use_packages: "{{ freebsd_use_packages | d(true) }}"
27      loop: "{{ apache_packages }}"
28      register: result
29      until: result is succeeded
30      retries: "{{ freebsd_install_retries }}"
31      delay: "{{ freebsd_install_delay }}"
32
33    - name: "Packages: Debug install ports apache_debug={{ apache_debug }}"
34      when: apache_debug | bool
35      ansible.builtin.debug:
36        var: result
37
38# EOF

samples.yml

Synopsis: <TBD>

<TBD>

[tasks/samples.yml]

 1---
 2- name: "Samples: Copy sample files."
 3  ansible.builtin.copy:
 4    remote_src: true
 5    src: "{{ apache_conf_path }}/{{ item }}.sample"
 6    dest: "{{ apache_conf_path }}/{{ item }}"
 7    mode: preserve
 8  loop: "{{ apache_samples_list }}"
 9
10# EOF

See also

  • <TBD>

httpd.yml

Synopsis: Configure lines in httpd.conf

Iterate the list apache_httpd_conf (8) and add lines to the configuration file (4).

[tasks/httpd.yml]

 1---
 2- name: "Httpd-conf: Configure parameters in {{ apache_conf_path ~ '/httpd.conf' }}"
 3  notify: "reload {{ ansible_role_name }}"
 4  ansible.builtin.lineinfile:
 5    dest: "{{ apache_conf_path }}/httpd.conf"
 6    regexp: ^{{ item.regexp }}\s+(.*)$
 7    line: "{{ item.regexp }} {{ item.line }}"
 8    backup: "{{ apache_backup_conf }}"
 9  loop: "{{ apache_httpd_conf }}"
10
11# EOF

See also

httpd-dirs.yml

Synopsis: Create files with the directory blocks in the Includes directory.

Iterate the list apache_directory_blocks (10) and create configuration files in the directory (5).

[tasks/httpd-dirs.yml]

 1---
 2- name: "Httpd-dirs: Configure directories in {{ apache_conf_path ~ '/Includes/' }}"
 3  notify: "reload {{ ansible_role_name }}"
 4  ansible.builtin.template:
 5    src: directory-block.j2
 6    dest: "{{ apache_conf_path }}/Includes/{{ item.Includefile }}"
 7    owner: root
 8    group: www
 9    mode: "0644"
10    backup: "{{ apache_backup_conf }}"
11  loop: "{{ apache_directory_blocks }}"
12  loop_control:
13    label: "{{ item.Directory }}"
14
15# EOF

See also

httpd-modules.yml

Synopsis: Load Apache modules.

Iterate apache_httpd_conf_modules (13). When item.preset (14) insert line LoadModule ... (10) to httpd.conf (8). Iterate apache_httpd_conf_modules (23). When not item.preset (24) comment line # LoadModule ... (19) in httpd.conf (18).

[tasks/httpd-modules.yml]

 1---
 2- name: Load modules in httpd.conf
 3  notify: "restart {{ ansible_role_name }}"
 4  block:
 5
 6    - name: "Httpd-modules: Load modules in {{ apache_conf_path ~ '/httpd.conf' }}"
 7      when: item.present | d(true)
 8      ansible.builtin.lineinfile:
 9        dest: "{{ apache_conf_path }}/httpd.conf"
10        regexp: ^\s*#*\s*LoadModule {{ item.module }}
11        line: "    LoadModule {{ item.module }} libexec/{{ apache_dir }}/{{ item.mod }}"
12        insertbefore: LoadModule
13        backup: "{{ apache_backup_conf }}"
14      loop: "{{ apache_httpd_conf_modules }}"
15
16    - name: "Httpd-modules: Unload modules in {{ apache_conf_path ~ '/httpd.conf' }}"
17      when: not item.present | d(true)
18      ansible.builtin.lineinfile:
19        dest: "{{ apache_conf_path }}/httpd.conf"
20        regexp: ^\s*#*\s*LoadModule {{ item.module }}
21        line: "    # LoadModule {{ item.module }}"
22        insertbefore: LoadModule
23        backup: "{{ apache_backup_conf }}"
24      loop: "{{ apache_httpd_conf_modules }}"
25
26# EOF

See also

httpd-php.yml

Synopsis: Configure httpd-php

Description of the task.

[tasks/httpd-php.yml]

 1---
 2- name: "Httpd-php: Config PHP in {{ apache_conf_path ~ '/Includes/' }}"
 3  notify: "reload {{ ansible_role_name }}"
 4  ansible.builtin.blockinfile:
 5    dest: "{{ apache_conf_path }}/Includes/{{ item.includefile }}"
 6    block: "{{ item.block }}"
 7    owner: root
 8    group: www
 9    mode: "0640"
10    create: true
11    backup: "{{ apache_backup_conf }}"
12    state: "{{ item.state }}"
13  loop: "{{ apache_php_blocks }}"
14  loop_control:
15    label: "{{ item.includefile }} {{ item.state }}"
16
17# EOF

httpd-alias.yml

Synopsis: Configure aliases in httpd.conf

When not an empty list (12) iterate apache_alias (7-9) and update blocks in the configuration file (4).

[tasks/httpd-alias.yml]

 1---
 2- name: "Httpd-alias: Configure aliases in {{ apache_conf_path ~ '/httpd.conf' }}"
 3  when: apache_alias | length > 0
 4  notify: "reload {{ ansible_role_name }}"
 5  ansible.builtin.blockinfile:
 6    dest: "{{ apache_conf_path }}/httpd.conf"
 7    insertafter: <IfModule alias_module>
 8    block: |2
 9        {% for item in apache_alias %}
10        {{ item }}
11        {% endfor %}
12    backup: "{{ apache_backup_conf }}"
13
14# EOF

See also

httpd-ssl.yml

Synopsis: Configure SSL in extra/httpd-ssl.conf

Iterate apache_httpd_conf_ssl_extra (16) and configure lines in extra/httpd-ssl.conf. Iterate apache_httpd_conf_ssl_extra_absent (24) and remove lines from extra/httpd-ssl.conf. Iterate apache_httpd_conf_ssl_listen (31) and add configuration lines in extra/httpd-ssl.conf). Iterate apache_httpd_conf_ssl (38) and configure lines in httpd.conf.

[tasks/httpd-ssl.yml]

 1---
 2- name: Configure SSL.
 3  notify: "reload {{ ansible_role_name }}"
 4  block:
 5
 6    - name: "Httpd-ssl: Present extra lines in {{ apache_conf_path ~ '/extra/httpd-ssl.conf' }}"
 7      ansible.builtin.lineinfile:
 8        dest: "{{ apache_conf_path }}/extra/httpd-ssl.conf"
 9        regexp: ^{{ item.regexp }}
10        line: "{{ item.regexp }}{{ item.line }}"
11        # TODO: Remove trailing spaces from the attribute regexp
12        # regexp: ^{{ item.regexp }}\s+(.*)$
13        # line: "{{ item.regexp }} {{ item.line }}"
14        backup: "{{ apache_backup_conf }}"
15      loop: "{{ apache_httpd_conf_ssl_extra }}"
16
17    - name: "Httpd-ssl: Absent extra lines in {{ apache_conf_path ~ '/extra/httpd-ssl.conf' }}"
18      ansible.builtin.lineinfile:
19        state: absent
20        dest: "{{ apache_conf_path }}/extra/httpd-ssl.conf"
21        regexp: "{{ item }}"
22        backup: "{{ apache_backup_conf }}"
23      loop: "{{ apache_httpd_conf_ssl_extra_absent }}"
24
25    - name: "Httpd-ssl: SSL Listen in {{ apache_conf_path ~ '/extra/httpd-ssl.conf' }}"
26      ansible.builtin.lineinfile:
27        dest: "{{ apache_conf_path }}/extra/httpd-ssl.conf"
28        line: "{{ item }}"
29        backup: "{{ apache_backup_conf }}"
30      loop: "{{ apache_httpd_conf_ssl_listen }}"
31
32    - name: "Httpd-ssl: SSL in {{ apache_conf_path ~ '/httpd.conf' }}"
33      ansible.builtin.lineinfile:
34        dest: "{{ apache_conf_path }}/httpd.conf"
35        line: "{{ item }}"
36        backup: "{{ apache_backup_conf }}"
37      loop: "{{ apache_httpd_conf_ssl }}"
38
39# EOF

httpd-vhosts.yml

Synopsis: Configure virtual hosts in extra directory.

Loop the dictionary apache_vhost (9, 22, 34) and optionally (12) create directories DocumentRoot (5). Create configuration files with the Apache virtual hosts (17). See the template vhost.j2 (16). Include created files (31) in the configuration file (29).

[tasks/httpd-vhosts.yml]

 1---
 2- name: "Httpd-vhosts: Create documnent roots for virtual hosts."
 3  when: item.create_document_root | d(false)
 4  ansible.builtin.file:
 5    state: directory
 6    path: "{{ item.DocumentRoot }}"
 7    owner: "{{ apache_data_owner }}"
 8    group: "{{ apache_data_group }}"
 9    mode: "{{ apache_dir_mode }}"
10  loop: "{{ apache_vhost }}"
11  loop_control:
12    label: "{{ item.ServerName }}"
13
14- name: "Httpd-vhosts: Configure virtual hosts in {{ apache_conf_path ~ '/extra/' }}"
15  notify: "reload {{ ansible_role_name }}"
16  ansible.builtin.template:
17    src: vhost.j2
18    dest: "{{ apache_conf_path }}/extra/{{ item.ServerName }}.conf"
19    owner: "{{ apache_data_owner }}"
20    group: "{{ apache_data_group }}"
21    mode: "{{ apache_data_mode }}"
22    backup: "{{ apache_backup_conf }}"
23  loop: "{{ apache_vhost }}"
24  loop_control:
25    label: "{{ item.ServerName }}"
26
27- name: "Httpd-vhosts: Incl virtual hosts in {{ apache_conf_path ~ '/httpd.conf' }}"
28  notify: "reload {{ ansible_role_name }}"
29  ansible.builtin.lineinfile:
30    dest: "{{ apache_conf_path }}/httpd.conf"
31    regexp: ^Include etc/apache{{ apache_version }}/extra/{{ item.ServerName }}.conf
32    line: Include etc/apache{{ apache_version }}/extra/{{ item.ServerName }}.conf
33    insertbefore: BOF
34    backup: "{{ apache_backup_conf }}"
35  loop: "{{ apache_vhost }}"
36  loop_control:
37    label: "{{ item.ServerName }}"
38
39# EOF

See also

httpd-confd.yml

Synopsis: Configure virtual hosts.

Configure virtual hosts (2) and configuration sections of the directories (6).

[tasks/httpd-confd.yml]

 1---
 2- name: "Httpd-confd: Configure virtual hosts from {{ apache_confd_dir_vhosts }}"
 3  ansible.builtin.import_tasks: httpd-confd-vhosts.yml
 4  tags: apache_httpd_confd_vhosts
 5
 6- name: "Httpd-confd: Configure includes from {{ apache_confd_dir_sections }}"
 7  ansible.builtin.import_tasks: httpd-confd-includes.yml
 8  tags: apache_httpd_confd_includes
 9
10# EOF

See also

  • httpd-confd-vhosts.yml and httpd-confd-includes.yml

httpd-confd-vhosts.yml

Synopsis: Configure virtual hosts. Create files.

Use the filter encode_apache to configure virtual hosts. See the template vhost2.j2. Take the YAML configuration files from the directory apache_confd_dir_vhosts (4) at master and create files with the Apache virtual hosts in the directory (30) at the remote host. The created files will be included in the configuration file (40).

Include data from conf.d (2-20)

Include tasks from the file al_include_confd_vars_list (8) in the role vbotka.ansible_lib (7). This task takes as parameters the directory with the YAML configuration files (4) and the type of the list (5), and returns the list with the YAML configurations of the virtual hosts stored in the variable al_include_confd_vars_list. The variable can be printed (14) when debug is enabled apache_debug: true (11). The parameters (4, 5) are tested inside the included tasks.

Create directories for virtual hosts (22-24)

Include tasks from fn/httpd-confd-vhost-dirs.yml .

Configure virtual hosts in extra directory (26-47)

Create the Apache configuration files for the virtual hosts with the help of encode_apache filter. Store the configuration file (33). Include virtual hosts in httpd.conf (42).

[tasks/httpd-confd-vhosts.yml]

 1---
 2- name: "Httpd-confd-vhosts: Include al_include_confd_vars_list"
 3  vars:
 4    al_include_confd_dir: "{{ apache_confd_dir_vhosts }}"
 5    al_include_confd_vars_list_type: fname
 6  ansible.builtin.include_role:
 7    name: "{{ apache_ansible_lib[ansible_role_name] }}"
 8    tasks_from: al_include_confd_vars_list
 9
10- name: "Httpd-confd-vhosts: Debug al_include_confd_vars_list apache_debug={{ apache_debug }}"
11  when: apache_debug | bool
12  ansible.builtin.debug:
13    var: item
14  loop: "{{ al_include_confd_vars_list | d([]) }}"
15
16- name: "Httpd-confd-vhosts: Debug list directories for virtual hosts apache_debug={{ apache_debug }}"
17  when: apache_debug | bool
18  ansible.builtin.debug:
19    msg: "{{ item | json_query('[].content[].sections[].content[].options[].DocumentRoot') }}"
20  loop: "{{ al_include_confd_vars_list | d([]) | json_query('[].vars') }}"
21
22- name: "Httpd-confd-vhosts: Create directories for virtual hosts."
23  ansible.builtin.include_tasks: fn/httpd-confd-vhost-dirs.yml
24  loop: "{{ al_include_confd_vars_list | d([]) | json_query('[].vars') }}"
25
26- name: Configure virtual hosts
27  notify: "reload {{ ansible_role_name }}"
28  block:
29
30    - name: "Httpd-confd-vhosts: Configure virtual hosts in {{ apache_conf_path ~ '/extra/' }}"
31      ansible.builtin.template:
32        src: vhost2.j2
33        dest: "{{ apache_conf_path }}/extra/{{ item.fname }}.conf"
34        owner: "{{ apache_data_owner }}"
35        group: "{{ apache_data_group }}"
36        mode: "{{ apache_data_mode }}"
37        backup: "{{ apache_backup_conf }}"
38      loop: "{{ al_include_confd_vars_list | d([]) }}"
39
40    - name: "Httpd-confd-vhosts: Incl virtual hosts in {{ apache_conf_path ~ '/httpd.conf' }}"
41      ansible.builtin.lineinfile:
42        dest: "{{ apache_conf_path }}/httpd.conf"
43        regexp: ^Include etc/apache{{ apache_version }}/extra/{{ item.fname }}.conf
44        line: Include etc/apache{{ apache_version }}/extra/{{ item.fname }}.conf
45        insertbefore: BOF
46        backup: "{{ apache_backup_conf }}"
47      loop: "{{ al_include_confd_vars_list | d([]) }}"
48
49# EOF

See also

httpd-confd-vhost-dirs.yml

Synopsis: Create DocumentRoot directories for vhosts.

<TBD>

[tasks/fn/httpd-confd-vhost-dirs.yml]

 1---
 2- name: "Httpd-confd-vhost-dirs: Create directories for virtual hosts"
 3  ansible.builtin.file:
 4    state: directory
 5    path: "{{ vhost_dir }}"
 6    owner: "{{ apache_data_owner }}"
 7    group: "{{ apache_data_group }}"
 8    mode: "{{ apache_dir_mode }}"
 9  loop: "{{ item | json_query('[].content[].sections[].content[].options[].DocumentRoot') }}"
10  loop_control:
11    loop_var: vhost_dir
12
13# EOF

See also

  • <TBD>

httpd-confd-includes.yml

Synopsis: Configure sections using the filter encode_apache.

Take the YAML configuration files from the directory apache_confd_dir_sections (7) at master and create the configuration files (24) at the remote host. The created configuration files are included in the configuration file httpd.conf by default. For example,

shell> grep Includes /usr/local/etc/apache24/httpd.conf
Include etc/apache24/Includes/*.conf

Include data from conf.d (2-19)

Include tasks from the file al_include_confd_vars_list (13) in the role vbotka.ansible_lib (12). This task takes as parameters the directory of the YAML configuration files (7) and the type of the list (8), and returns the list with the YAML configurations of the sections stored in the variable al_include_confd_vars_list. The parameters (7, 8) are tested inside the included tasks.

Configure sections in Includes directory (21-30)

Use the filter encode_apache to create the configuration files (24) for the sections. See the template section2.j2.

[tasks/httpd-confd-includes.yml]

 1---
 2- name: "Httpd-confd-includes: Include al_include_confd_vars_list"
 3  vars:
 4    al_include_confd_dir: "{{ apache_confd_dir_sections }}"
 5    al_include_confd_vars_list_type: fname
 6  ansible.builtin.include_role:
 7    name: "{{ apache_ansible_lib[ansible_role_name] }}"
 8    tasks_from: al_include_confd_vars_list
 9
10- name: "Httpd-confd-includes: Debug al_include_confd_vars_list apache_debug={{ apache_debug }}"
11  when: apache_debug | bool
12  ansible.builtin.debug:
13    var: item
14  loop: "{{ al_include_confd_vars_list }}"
15
16- name: "Httpd-confd-includes: Configure sections in {{ apache_conf_path ~ '/Includes/' }}"
17  notify: "reload {{ ansible_role_name }}"
18  ansible.builtin.template:
19    src: section2.j2
20    dest: "{{ apache_conf_path }}/Includes/{{ item.fname }}.conf"
21    owner: "{{ apache_data_owner }}"
22    group: "{{ apache_data_group }}"
23    mode: "{{ apache_data_mode }}"
24    backup: "{{ apache_backup_conf }}"
25  loop: "{{ al_include_confd_vars_list }}"
26
27# EOF

See also

service.yml

Synopsis: Configure service.

At the moment, only the configuration of FreeBSD is implemented (2).

[tasks/service.yml]

1---
2- name: "Service: Config FreeBSD."
3  ansible.builtin.import_tasks: rcconf.yml
4  when: ansible_facts.os_family == 'FreeBSD'
5
6# EOF

See also

  • rcconf.yml

rcconf.yml

Synopsis: Configure service in FreeBSD.

Configure (2), enable (11) or disable (20) the service.

[tasks/rcconf.yml]

 1---
 2- name: "Rc-conf: Configure /etc/rc.conf"
 3  notify: "graceful {{ ansible_role_name }}"
 4  community.general.sysrc:
 5    name: "{{ item.key }}"
 6    value: "{{ item.value }}"
 7  loop: "{{ apache_rcconf }}"
 8
 9- name: "Rc-conf: Enable and Start Apache"
10  when: apache_enable | bool
11  notify: "enable and start {{ ansible_role_name }}"
12  community.general.sysrc:
13    name: "{{ apache_service }}_enable"
14    value: "YES"
15
16- name: "Rc-conf: Disable and Stop Apache"
17  when: not apache_enable | bool
18  notify: "disable and stop {{ ansible_role_name }}"
19  community.general.sysrc:
20    name: "{{ apache_service }}_enable"
21    value: "NO"
22
23# EOF

See also

  • <TBD>