Tasks

main.yml

Synopsis: Main task.

Import tasks if enabled.

[tasks/main.yml]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
---
# tasks for vbotka.apache

- name: Import vars.yml
  ansible.builtin.import_tasks: vars.yml
  tags: [apache-vars, always]

- name: Import debug.yml
  ansible.builtin.import_tasks: debug.yml
  when: apache_debug|bool
  tags: apache-debug

- name: Import packages.yml
  ansible.builtin.import_tasks: packages.yml
  when: apache_install|bool
  tags: apache-packages

- name: Import samples.yml
  ansible.builtin.import_tasks: samples.yml
  when: apache_samples|bool
  tags: apache-samples

- name: Import httpd.yml
  ansible.builtin.import_tasks: httpd.yml
  tags: apache-httpd

- name: Import httpd-dirs.yml
  ansible.builtin.import_tasks: httpd-dirs.yml
  tags: apache-httpd-dirs

- name: Import httpd-modules.yml
  ansible.builtin.import_tasks: httpd-modules.yml
  tags: apache-httpd-modules

- name: Import httpd-alias.yml
  ansible.builtin.import_tasks: httpd-alias.yml
  tags: apache-httpd-alias

- name: Import httpd-ssl.yml
  ansible.builtin.import_tasks: httpd-ssl.yml
  tags: apache-httpd-ssl

- name: Import httpd-vhosts.yml
  ansible.builtin.import_tasks: httpd-vhosts.yml
  tags: apache-httpd-vhosts

- name: Import httpd-confd.yml
  ansible.builtin.import_tasks: httpd-confd.yml
  tags: apache-httpd-confd

- name: Import service.yml
  ansible.builtin.import_tasks: service.yml
  tags: apache-service

# 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
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
---

- name: "vars: Include OS vars"
  block:
    - name: "vars: Set variables for al_include_os_vars_path"
      ansible.builtin.set_fact:
        al_os_vars_path: "{{ role_path }}"
    - name: "vars: Include OS vars"
      ansible.builtin.include_role:
        name: vbotka.ansible_lib
        tasks_from: al_include_os_vars_path

# EOF
...

See also

Note

  • Put OS specific variables here. Because of the precedence (15.role vars), there are limited options to override these variables, if necessary.

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
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
---

- name: 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_python_version [{{ ansible_python_version }}]

      apache_install [{{ apache_install }}]
      apache_version [{{ apache_version }}]
      apache_packages
      {{ apache_packages|to_nice_yaml }}
      apache_enable [{{ apache_enable }}]
      apache_rcconf
      {{ apache_rcconf|to_yaml }}
      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_ssl
      {{ apache_httpd_conf_ssl|to_nice_yaml }}
      apache_httpd_conf_ssl_extra
      {{ apache_httpd_conf_ssl_extra|to_yaml }}
      apache_httpd_conf_ssl_extra_absent
      {{ apache_httpd_conf_ssl_extra_absent|to_yaml }}
      apache_vhost
      {{ apache_vhost|to_nice_yaml }}
      apache_directory_blocks
      {{ 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_samples [{{ apache_samples }}]
      apache_samples_list
      {{ apache_samples_list|to_nice_yaml }}
  ansible.builtin.debug:
    msg: "{{ '{}'.format(msg) }}"

# EOF
...

packages.yml

Synopsis: Install packages for supported OS.

<TBD>

[tasks/packages.yml]

1
2
3
4
5
6
7
8
---

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

# EOF
...

See also

  • <TBD>

packages-freebsd.yml

Synopsis: <TBD>

<TBD>

[tasks/packages-freebsd.yml]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
---

- name: "packages: Install packages"
  community.general.pkgng:
    name: "{{ apache_packages }}"
  register: result
  until: result is succeeded
  retries: "{{ freebsd_install_retries }}"
  delay: "{{ freebsd_install_delay }}"
  when: freebsd_install_method == "packages"

- name: "packages: Debug install packages"
  ansible.builtin.debug:
    var: result
  when: apache_debug|bool

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

- name: "packages: Debug install ports"
  ansible.builtin.debug:
    var: result
  when: apache_debug|bool
# EOF
...

See also

  • <TBD>

samples.yml

Synopsis: <TBD>

<TBD>

[tasks/samples.yml]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
---

- name: "samples: Copy sample files"
  ansible.builtin.copy:
    remote_src: true
    src: "{{ apache_conf_path }}/{{ item }}.sample"
    dest: "{{ apache_conf_path }}/{{ item }}"
    mode: preserve
  loop: "{{ apache_samples_list }}"

# EOF
...

See also

  • <TBD>

httpd.yml

Synopsis: Configure lines in httpd.conf

Iterate the list apache_httpd_conf (9) and add lines to the configuration file (5).

[tasks/httpd.yml]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
---

- name: "httpd_conf: Configure parameters in {{ apache_conf_path }}/httpd.conf"
  ansible.builtin.lineinfile:
    dest: "{{ apache_conf_path }}/httpd.conf"
    regexp: '^{{ item.regexp }}\s(.*)$'
    line: "{{ item.regexp }} {{ item.line }}"
    backup: "{{ apache_backup_conf }}"
  loop: "{{ apache_httpd_conf }}"
  notify: reload apache

# EOF
...

See also

httpd-dirs.yml

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

Iterate the list apache_directory_blocks (11) and create configuration files in the directory (6).

[tasks/httpd-dirs.yml]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
---

- name: "httpd-dirs: Configure directories in {{ apache_conf_path }}/Includes/"
  ansible.builtin.template:
    src: directory-block.j2
    dest: "{{ apache_conf_path }}/Includes/{{ item.Includefile }}"
    owner: root
    group: www
    mode: "0644"
    backup: "{{ apache_backup_conf }}"
  loop: "{{ apache_directory_blocks }}"
  loop_control:
    label: "{{ item.Directory }}"
  notify: reload apache

# EOF
...

See also

httpd-modules.yml

Synopsis: Load Apache modules. Optionally configure PHP module. (TODO: General configuration of modules.)

Iterate apache_httpd_conf_modules (10). When item.preset (12) insert line LoadModule ... (7) to httpd.conf (5). Iterate apache_httpd_conf_modules (21). When not item.preset (23) comment line # LoadModule ... (18) in httpd.conf (16). Configure PHP (29-37) in Includes/php.conf when apache_php is enabled (44).

[tasks/httpd-modules.yml]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---

- name: "httpd-modules: Load modules in {{ apache_conf_path }}/httpd.conf"
  ansible.builtin.lineinfile:
    dest: "{{ apache_conf_path }}/httpd.conf"
    regexp: '^\s*#*\s*LoadModule {{ item.module }}'
    line: "    LoadModule {{ item.module }} libexec/{{ apache_dir }}/{{ item.mod }}"
    insertbefore: LoadModule
    backup: "{{ apache_backup_conf }}"
  loop: "{{ apache_httpd_conf_modules }}"
  notify: restart apache
  when: item.present|default(true)

- name: "httpd-modules: Unload modules in {{ apache_conf_path }}/httpd.conf"
  ansible.builtin.lineinfile:
    dest: "{{ apache_conf_path }}/httpd.conf"
    regexp: '^\s*#*\s*LoadModule {{ item.module }}'
    line: "    # LoadModule {{ item.module }}"
    insertbefore: LoadModule
    backup: "{{ apache_backup_conf }}"
  loop: "{{ apache_httpd_conf_modules }}"
  notify: restart apache
  when: not item.present|default(true)

- name: "httpd-modules: Config PHP in {{ apache_conf_path }}/Includes/php.conf"
  ansible.builtin.blockinfile:
    dest: "{{ apache_conf_path }}/Includes/php.conf"
    block: |
      <IfModule dir_module>
        DirectoryIndex index.html index.php
      </IfModule>
      <FilesMatch "\.php$">
        SetHandler application/x-httpd-php
      </FilesMatch>
      <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
      </FilesMatch>
    owner: root
    group: www
    mode: "0640"
    create: true
    backup: "{{ apache_backup_conf }}"
  notify: restart apache
  when: apache_php|bool

# EOF
...

See also

httpd-alias.yml

Synopsis: Configure aliases in httpd.conf

When not an empty list (13) iterate apache_alias (8-10) and update blocks in the configuration file (5).

[tasks/httpd-alias.yml]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
---

- name: "httpd-alias: Configure aliases in {{ apache_conf_path }}/httpd.conf"
  ansible.builtin.blockinfile:
    dest: "{{ apache_conf_path }}/httpd.conf"
    insertafter: "<IfModule alias_module>"
    block: |2
        {% for item in apache_alias %}
        {{ item }}
        {% endfor %}
    backup: "{{ apache_backup_conf }}"
  notify: reload apache
  when: apache_alias|length > 0

# EOF
...

See also

httpd-ssl.yml

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

Iterate apache_httpd_conf_ssl_extra (11) and configure lines in extra/httpd-ssl.conf. Iterate apache_httpd_conf_ssl_extra_absent (22) and remove lines from extra/httpd-ssl.conf (19). Iterate apache_httpd_conf_ssl_listen (30) and add configuration lines in extra/httpd-ssl.conf (27). Iterate apache_httpd_conf_ssl (38) and configure lines in httpd.conf (35).

[tasks/httpd-ssl.yml]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
---

- name: "httpd-ssl: Configure {{ apache_conf_path }}/extra/httpd-ssl.conf"
  block:

    - name: "httpd-ssl: Present extra lines in {{ apache_conf_path }}/extra/httpd-ssl.conf"
      ansible.builtin.lineinfile:
        dest: "{{ apache_conf_path }}/extra/httpd-ssl.conf"
        regexp: "^{{ item.regexp }}"
        line: "{{ item.regexp }}{{ item.line }}"
        backup: "{{ apache_backup_conf }}"
      loop: "{{ apache_httpd_conf_ssl_extra }}"
      notify: reload apache

    - name: "httpd-ssl: Absent extra lines in {{ apache_conf_path }}/extra/httpd-ssl.conf"
      ansible.builtin.lineinfile:
        state: absent
        dest: "{{ apache_conf_path }}/extra/httpd-ssl.conf"
        regexp: "{{ item }}"
        backup: "{{ apache_backup_conf }}"
      loop: "{{ apache_httpd_conf_ssl_extra_absent }}"
      notify: reload apache

    - name: "httpd-ssl: SSL Listen in {{ apache_conf_path }}/extra/httpd-ssl.conf"
      ansible.builtin.lineinfile:
        dest: "{{ apache_conf_path }}/extra/httpd-ssl.conf"
        line: "{{ item }}"
        backup: "{{ apache_backup_conf }}"
      loop: "{{ apache_httpd_conf_ssl_listen }}"
      notify: reload apache

    - name: "httpd-ssl: SSL in {{ apache_conf_path }}/httpd.conf"
      ansible.builtin.lineinfile:
        dest: "{{ apache_conf_path }}/httpd.conf"
        line: "{{ item }}"
        backup: "{{ apache_backup_conf }}"
      loop: "{{ apache_httpd_conf_ssl }}"
      notify: reload apache

  when: apache_ssl|bool

# EOF
...

httpd-vhosts.yml

Synopsis: Configure virtual hosts in extra directory.

Loop the dictionary apache_vhost (10,23,35) and optionally (13) create directories DocumentRoot (5,6). Create configuration files with the Apache virtual hosts (18). See the template vhost.j2 (17). Include created files (32) in the configuration file (30).

[tasks/httpd-vhosts.yml]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
---

- name: "httpd-vhosts: Create directories for virtual hosts"
  ansible.builtin.file:
    state: directory
    path: "{{ item.DocumentRoot }}"
    owner: "{{ apache_data_owner }}"
    group: "{{ apache_data_group }}"
    mode: "{{ apache_dir_mode }}"
  loop: "{{ apache_vhost }}"
  loop_control:
    label: "{{ item.ServerName }}"
  when: item.create_document_root|default(False)

- name: "httpd-vhosts: Configure virtual hosts in {{ apache_conf_path }}/extra/"
  ansible.builtin.template:
    src: vhost.j2
    dest: "{{ apache_conf_path }}/extra/{{ item.ServerName }}.conf"
    owner: "{{ apache_data_owner }}"
    group: "{{ apache_data_group }}"
    mode: "{{ apache_data_mode }}"
    backup: "{{ apache_backup_conf }}"
  loop: "{{ apache_vhost }}"
  loop_control:
    label: "{{ item.ServerName }}"
  notify: reload apache

- name: "httpd-vhosts: Incl virtual hosts in {{ apache_conf_path }}/httpd.conf"
  ansible.builtin.lineinfile:
    dest: "{{ apache_conf_path }}/httpd.conf"
    regexp: "^Include etc/apache{{ apache_version }}/extra/{{ item.ServerName }}.conf"
    line: "Include etc/apache{{ apache_version }}/extra/{{ item.ServerName }}.conf"
    insertbefore: BOF
    backup: "{{ apache_backup_conf }}"
  loop: "{{ apache_vhost }}"
  loop_control:
    label: "{{ item.ServerName }}"
  notify: reload apache

# EOF
...

See also

httpd-confd.yml

Synopsis: Configure virtual hosts.

Configure virtual hosts (3) and configuration sections of the directories (7).

[tasks/httpd-confd.yml]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
---

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

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

# 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 (7) at master and create files with the Apache virtual hosts in the directory (32) at the remote host. The created files will be included in the configuration file (42).

Include data from conf.d (3-17)

Include tasks from the file al_include_confd_vars_list (12) in the role vbotka.ansible_lib (11). This task takes as parameters the directory with the YAML configuration files (7) and the type of the list (8), 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 (16) when debug is enabled apache_debug: true (17). The parameters (7,8) are tested inside the included tasks.

Create directories for virtual hosts (25-27)

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

Configure virtual hosts in extra directory (29-38)

Create the Apache configuration files for the virtual hosts with the help of encode_apache filter. Store the configuration file (32).

Include virtual hosts in httpd.conf (40-48)

Include virtual hosts in httpd.conf.

[tasks/httpd-confd-vhosts.yml]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---

- name: "httpd-confd-vhosts: Include variables from {{ apache_confd_dir_vhosts }}"
  block:
    - name: "httpd-confd-vhosts: Set variables for al_include_confd_vars_list"
      ansible.builtin.set_fact:
        al_include_confd_dir: "{{ apache_confd_dir_vhosts }}"
        al_include_confd_vars_list_type: fname
    - name: "httpd-confd-vhosts: Include al_include_confd_vars_list"
      ansible.builtin.include_role:
        name: vbotka.ansible_lib
        tasks_from: al_include_confd_vars_list
    - name: "httpd-confd-vhosts: Debug al_include_confd_vars_list"
      ansible.builtin.debug:
        var: item
      loop: "{{ al_include_confd_vars_list }}"
      when: apache_debug|bool

- name: "httpd-confd-vhosts: Debug list directories for virtual hosts"
  ansible.builtin.debug:
    msg: "{{ item|json_query('[].content[].sections[].content[].options[].DocumentRoot') }}"
  loop: "{{ al_include_confd_vars_list|json_query('[].vars') }}"
  when: apache_debug|bool

- name: "httpd-confd-vhosts: Create directories for virtual hosts"
  ansible.builtin.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/"
  ansible.builtin.template:
    src: vhost2.j2
    dest: "{{ apache_conf_path }}/extra/{{ item.fname }}.conf"
    owner: "{{ apache_data_owner }}"
    group: "{{ apache_data_group }}"
    mode: "{{ apache_data_mode }}"
    backup: "{{ apache_backup_conf }}"
  loop: "{{ al_include_confd_vars_list }}"
  notify: reload apache

- name: "httpd-confd-vhosts: Incl virtual hosts in {{ apache_conf_path }}/httpd.conf"
  ansible.builtin.lineinfile:
    dest: "{{ apache_conf_path }}/httpd.conf"
    regexp: "^Include etc/apache{{ apache_version }}/extra/{{ item.fname }}.conf"
    line: "Include etc/apache{{ apache_version }}/extra/{{ item.fname }}.conf"
    insertbefore: BOF
    backup: "{{ apache_backup_conf }}"
  loop: "{{ al_include_confd_vars_list }}"
  notify: reload apache

# EOF
...

See also

httpd-confd-vhost-dirs.yml

Synopsis: Create DocumentRoot directories for vhosts.

<TBD>

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
---

- name: "httpd-confd-vhost-dirs: Create directories for virtual hosts"
  ansible.builtin.file:
    state: directory
    path: "{{ vhost_dir }}"
    owner: "{{ apache_data_owner }}"
    group: "{{ apache_data_group }}"
    mode: "{{ apache_dir_mode }}"
  loop: "{{ item|json_query('[].content[].sections[].content[].options[].DocumentRoot') }}"
  loop_control:
    loop_var: vhost_dir

# EOF
...

See also

  • <TBD>

httpd-confd-includes.yml

Synopsis: Configure sections with the filter encode_apache.

Take the YAML configuration files from the directory apache_confd_dir_sections (7) at master and create the configuration files (22) 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 (3-17)

Include tasks from the file al_include_confd_vars_list (12) in the role vbotka.ansible_lib (11). 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 (19-28)

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

[tasks/httpd-confd-includes.yml]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
---

- name: "httpd-confd-includes: Include sections from {{ apache_confd_dir_sections }}"
  block:
    - name: "httpd-confd-includes: Set variables for al_include_confd_vars_list"
      ansible.builtin.set_fact:
        al_include_confd_dir: "{{ apache_confd_dir_sections }}"
        al_include_confd_vars_list_type: fname
    - name: "httpd-confd-includes: Include al_include_confd_vars_list"
      ansible.builtin.include_role:
        name: vbotka.ansible_lib
        tasks_from: al_include_confd_vars_list
    - name: "httpd-confd-includes: Debug al_include_confd_vars_list"
      ansible.builtin.debug:
        var: item
      loop: "{{ al_include_confd_vars_list }}"
      when: apache_debug|bool

- name: "httpd-confd-includes: Configure sections in {{ apache_conf_path }}/Includes/"
  ansible.builtin.template:
    src: section2.j2
    dest: "{{ apache_conf_path }}/Includes/{{ item.fname }}.conf"
    owner: "{{ apache_data_owner }}"
    group: "{{ apache_data_group }}"
    mode: "{{ apache_data_mode }}"
    backup: "{{ apache_backup_conf }}"
  loop: "{{ al_include_confd_vars_list }}"
  notify: reload apache

# EOF
...

See also

service.yml

Synopsis: Configure service.

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

[tasks/service.yml]

1
2
3
4
5
6
7
8
---

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

# EOF
...

See also

  • rcconf.yml

rcconf.yml

Synopsis: Configure service in FreeBSD.

Configure (3), enable (12) or disable (21) the service.

[tasks/rcconf.yml]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
---

- name: "rc_conf: configure /etc/rc.conf"
  ansible.builtin.lineinfile:
    dest: /etc/rc.conf
    regexp: '^\s*{{ item.key }}\s*=(.*)$'
    line: '{{ item.key }}="{{ item.value }}"'
    backup: "{{ apache_backup_conf }}"
  loop: "{{ apache_rcconf }}"
  notify: graceful apache

- name: "rc_conf: Enable and Start Apache"
  ansible.builtin.lineinfile:
    dest: /etc/rc.conf
    regexp: '^\s*{{ apache_service }}_enable\s*=(.*)$'
    line: '{{ apache_service }}_enable="YES"'
    backup: "{{ apache_backup_conf }}"
  notify: enable and start apache
  when: apache_enable|bool

- name: "rc_conf: Disable and Stop Apache"
  ansible.builtin.lineinfile:
    dest: /etc/rc.conf
    regexp: '^\s*{{ apache_service }}_enable\s*=(.*)$'
    line: '{{ apache_service }}_enable="NO"'
    backup: "{{ apache_backup_conf }}"
  notify: disable and stop apache
  when: not apache_enable|bool

# EOF
...

See also

  • <TBD>