Tasks
main.yml
Synopsis: Main task.
Import tasks if enabled.
1---
2# tasks for vbotka.apache
3
4- name: Import vars.yml
5 ansible.builtin.import_tasks: vars.yml
6 tags: [apache_vars, always]
7
8- name: Import debug.yml
9 ansible.builtin.import_tasks: debug.yml
10 when: apache_debug | bool
11 tags: apache_debug
12
13- name: Import packages.yml
14 ansible.builtin.import_tasks: packages.yml
15 when: apache_install | bool
16 tags: apache_packages
17
18- name: Import samples.yml
19 ansible.builtin.import_tasks: samples.yml
20 when: apache_samples | bool
21 tags: apache_samples
22
23- name: Import httpd.yml
24 ansible.builtin.import_tasks: httpd.yml
25 tags: apache_httpd
26
27- name: Import httpd-dirs.yml
28 ansible.builtin.import_tasks: httpd-dirs.yml
29 tags: apache_httpd_dirs
30
31- name: Import httpd-modules.yml
32 ansible.builtin.import_tasks: httpd-modules.yml
33 tags: apache_httpd_modules
34
35- name: Import httpd-alias.yml
36 ansible.builtin.import_tasks: httpd-alias.yml
37 tags: apache_httpd_alias
38
39- name: Import httpd-ssl.yml
40 ansible.builtin.import_tasks: httpd-ssl.yml
41 tags: apache_httpd_ssl
42
43- name: Import httpd-vhosts.yml
44 ansible.builtin.import_tasks: httpd-vhosts.yml
45 tags: apache_httpd_vhosts
46
47- name: Import httpd-confd.yml
48 ansible.builtin.import_tasks: httpd-confd.yml
49 tags: apache_httpd_confd
50
51- name: Import service.yml
52 ansible.builtin.import_tasks: service.yml
53 tags: apache_service
54
55# 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.
1---
2- name: "Vars: Include OS vars" # noqa: var-naming[no-role-prefix]
3 ansible.builtin.include_role:
4 name: vbotka.ansible_lib
5 tasks_from: al_include_os_vars_path
6 vars:
7 al_os_vars_path: "{{ ansible_parent_role_paths.0 }}"
8
9# EOF
See also
Review the precedence, naming conventions, and other details in the included tasks (6) al_include_os_vars_path.yml
See Variables
Note
Put OS specific variables here.
Because of the precedence (15.role vars), there are limited options to override these variables.
Hint
It might be more convenient to maintain the variables incrementally.
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.
1---
2- name: Debug
3 vars:
4 msg: |-
5 ansible_architecture: {{ ansible_architecture }}
6 ansible_os_family: {{ ansible_os_family }}
7 ansible_distribution: {{ ansible_distribution }}
8 ansible_distribution_major_version: {{ ansible_distribution_major_version }}
9 ansible_distribution_version: {{ ansible_distribution_version }}
10 ansible_distribution_release: {{ ansible_distribution_release }}
11 ansible_python_version: {{ ansible_python_version }}
12
13 apache_install: {{ apache_install }}
14 apache_version: {{ apache_version }}
15 apache_packages:
16 {{ apache_packages | to_nice_yaml(indent=2) | indent(2) }}
17 apache_enable: {{ apache_enable }}
18 apache_rcconf:
19 {{ apache_rcconf | to_yaml(indent=2) | indent(2) }}
20 apache_ssl: {{ apache_ssl }}
21 apache_sslengine: {{ apache_sslengine }}
22 apache_php: {{ apache_php }}
23 apache_backup_conf: {{ apache_backup_conf }}
24 apache_servername: {{ apache_servername }}
25 apache_serveradmin: {{ apache_serveradmin }}
26 apache_dir: {{ apache_dir }}
27 apache_service: {{ apache_service }}
28 apache_conf_path: {{ apache_conf_path }}
29 apache_httpd_conf:
30 {{ apache_httpd_conf | to_yaml(indent=2) | indent(2) }}
31 apache_httpd_conf_modules:
32 {{ apache_httpd_conf_modules | to_yaml(indent=2) | indent(2) }}
33 apache_httpd_conf_ssl:
34 {{ apache_httpd_conf_ssl | to_nice_yaml(indent=2) | indent(2) }}
35 apache_httpd_conf_ssl_extra:
36 {{ apache_httpd_conf_ssl_extra | to_yaml(indent=2) | indent(2) }}
37 apache_httpd_conf_ssl_extra_absent:
38 {{ apache_httpd_conf_ssl_extra_absent | to_yaml(indent=2) | indent(2) }}
39 apache_vhost:
40 {{ apache_vhost | to_nice_yaml(indent=2) | indent(2) }}
41 apache_directory_blocks:
42 {{ apache_directory_blocks | to_nice_yaml(indent=2) | indent(2) }}
43 apache_alias:
44 {{ apache_alias | to_nice_yaml(indent=2) | indent(2) }}
45 apache_confd_dir_vhosts: {{ apache_confd_dir_vhosts }}
46 apache_confd_dir_sections: {{ apache_confd_dir_sections }}
47 apache_samples: {{ apache_samples }}
48 apache_samples_list:
49 {{ apache_samples_list | to_nice_yaml(indent=2) | indent(2) }}
50 ansible.builtin.debug:
51 msg: "{{ '{}'.format(msg) }}"
52
53# EOF
packages.yml
Synopsis: Install packages for supported OS.
<TBD>
1---
2- name: "Packages: Install FreeBSD packages"
3 ansible.builtin.import_tasks: packages-freebsd.yml
4 when: ansible_os_family == 'FreeBSD'
5
6# EOF
See also
<TBD>
packages-freebsd.yml
Synopsis: <TBD>
<TBD>
1---
2- name: "Packages: Install packages"
3 community.general.pkgng:
4 name: "{{ apache_packages }}"
5 register: result
6 until: result is succeeded
7 retries: "{{ freebsd_install_retries }}"
8 delay: "{{ freebsd_install_delay }}"
9 when: freebsd_install_method == 'packages'
10
11- name: "Packages: Debug install packages"
12 ansible.builtin.debug:
13 var: result
14 when: apache_debug | bool
15
16- name: "Packages: Install ports"
17 community.general.portinstall:
18 name: "{{ item }}"
19 use_packages: "{{ freebsd_use_packages | d(true) }}"
20 loop: "{{ apache_packages }}"
21 register: result
22 until: result is succeeded
23 retries: "{{ freebsd_install_retries }}"
24 delay: "{{ freebsd_install_delay }}"
25 when: freebsd_install_method == 'ports'
26
27- name: "Packages: Debug install ports"
28 ansible.builtin.debug:
29 var: result
30 when: apache_debug | bool
31
32# EOF
See also
<TBD>
samples.yml
Synopsis: <TBD>
<TBD>
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
(9) and add lines to the configuration file (5).
1---
2- name: "Httpd_conf: Configure parameters in {{ apache_conf_path ~ '/httpd.conf' }}"
3 ansible.builtin.lineinfile:
4 dest: "{{ apache_conf_path }}/httpd.conf"
5 regexp: ^{{ item.regexp }}\s+(.*)$
6 line: "{{ item.regexp }} {{ item.line }}"
7 backup: "{{ apache_backup_conf }}"
8 loop: "{{ apache_httpd_conf }}"
9 notify: Reload apache
10
11# EOF
See also
Variable apache_httpd_conf
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).
1---
2- name: "Httpd-dirs: Configure directories in {{ apache_conf_path ~ '/Includes/' }}"
3 ansible.builtin.template:
4 src: directory-block.j2
5 dest: "{{ apache_conf_path }}/Includes/{{ item.Includefile }}"
6 owner: root
7 group: www
8 mode: "0644"
9 backup: "{{ apache_backup_conf }}"
10 loop: "{{ apache_directory_blocks }}"
11 loop_control:
12 label: "{{ item.Directory }}"
13 notify: Reload apache
14
15# EOF
See also
Template directory-block.j2
Variable apache_directory_blocks
httpd-modules.yml
Synopsis: Load Apache modules. Optionally configure PHP module. (TODO: General configuration of modules.)
Iterate apache_httpd_conf_modules
(9). When item.preset
(11) insert line LoadModule
...
(6) to httpd.conf (4). Iterate apache_httpd_conf_modules
(20). When not item.preset
(22) comment line # LoadModule ...
(17) in httpd.conf (15). Configure PHP (28-36) in
Includes/php.conf when apache_php
is enabled (43).
1---
2- name: "Httpd-modules: Load modules in {{ apache_conf_path ~ '/httpd.conf' }}"
3 ansible.builtin.lineinfile:
4 dest: "{{ apache_conf_path }}/httpd.conf"
5 regexp: ^\s*#*\s*LoadModule {{ item.module }}
6 line: " LoadModule {{ item.module }} libexec/{{ apache_dir }}/{{ item.mod }}"
7 insertbefore: LoadModule
8 backup: "{{ apache_backup_conf }}"
9 loop: "{{ apache_httpd_conf_modules }}"
10 notify: Restart apache
11 when: item.present | d(true)
12
13- name: "Httpd-modules: Unload modules in {{ apache_conf_path ~ '/httpd.conf' }}"
14 ansible.builtin.lineinfile:
15 dest: "{{ apache_conf_path }}/httpd.conf"
16 regexp: ^\s*#*\s*LoadModule {{ item.module }}
17 line: " # LoadModule {{ item.module }}"
18 insertbefore: LoadModule
19 backup: "{{ apache_backup_conf }}"
20 loop: "{{ apache_httpd_conf_modules }}"
21 notify: Restart apache
22 when: not item.present | d(true)
23
24- name: "Httpd-modules: Config PHP in {{ apache_conf_path ~ '/Includes/php.conf' }}"
25 ansible.builtin.blockinfile:
26 dest: "{{ apache_conf_path }}/Includes/php.conf"
27 block: |
28 <IfModule dir_module>
29 DirectoryIndex index.html index.php
30 </IfModule>
31 <FilesMatch "\.php$">
32 SetHandler application/x-httpd-php
33 </FilesMatch>
34 <FilesMatch "\.phps$">
35 SetHandler application/x-httpd-php-source
36 </FilesMatch>
37 owner: root
38 group: www
39 mode: "0640"
40 create: true
41 backup: "{{ apache_backup_conf }}"
42 notify: Restart apache
43 when: apache_php | bool
44
45# EOF
See also
Variable apache_httpd_conf_modules
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).
1---
2- name: "Httpd-alias: Configure aliases in {{ apache_conf_path ~ '/httpd.conf' }}"
3 ansible.builtin.blockinfile:
4 dest: "{{ apache_conf_path }}/httpd.conf"
5 insertafter: <IfModule alias_module>
6 block: |2
7 {% for item in apache_alias %}
8 {{ item }}
9 {% endfor %}
10 backup: "{{ apache_backup_conf }}"
11 notify: Reload apache
12 when: apache_alias | length > 0
13
14# EOF
See also
Variable apache_alias
httpd-ssl.yml
Synopsis: Configure SSL in extra/httpd-ssl.conf
Iterate apache_httpd_conf_ssl_extra
(10) and configure lines in
extra/httpd-ssl.conf
. Iterate apache_httpd_conf_ssl_extra_absent
(19) and remove lines
from extra/httpd-ssl.conf
. Iterate apache_httpd_conf_ssl_listen
(27) and add configuration lines
in extra/httpd-ssl.conf
). Iterate apache_httpd_conf_ssl
(35) and configure lines in
httpd.conf
.
1---
2- name: "Httpd-ssl: Configure {{ apache_conf_path ~ '/extra/httpd-ssl.conf' }}"
3 when: apache_ssl | bool
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 notify: Reload apache
17
18 - name: "Httpd-ssl: Absent extra lines in {{ apache_conf_path ~ '/extra/httpd-ssl.conf' }}"
19 ansible.builtin.lineinfile:
20 state: absent
21 dest: "{{ apache_conf_path }}/extra/httpd-ssl.conf"
22 regexp: "{{ item }}"
23 backup: "{{ apache_backup_conf }}"
24 loop: "{{ apache_httpd_conf_ssl_extra_absent }}"
25 notify: Reload apache
26
27 - name: "Httpd-ssl: SSL Listen in {{ apache_conf_path ~ '/extra/httpd-ssl.conf' }}"
28 ansible.builtin.lineinfile:
29 dest: "{{ apache_conf_path }}/extra/httpd-ssl.conf"
30 line: "{{ item }}"
31 backup: "{{ apache_backup_conf }}"
32 loop: "{{ apache_httpd_conf_ssl_listen }}"
33 notify: Reload apache
34
35 - name: "Httpd-ssl: SSL in {{ apache_conf_path ~ '/httpd.conf' }}"
36 ansible.builtin.lineinfile:
37 dest: "{{ apache_conf_path }}/httpd.conf"
38 line: "{{ item }}"
39 backup: "{{ apache_backup_conf }}"
40 loop: "{{ apache_httpd_conf_ssl }}"
41 notify: Reload apache
42
43# EOF
See also
Variable apache_httpd_conf_ssl
Variable apache_httpd_conf_ssl_extra
Variable apache_httpd_conf_ssl_extra_absent
Variable apache_httpd_conf_ssl_listen
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).
1---
2- name: "Httpd-vhosts: Create directories for virtual hosts"
3 ansible.builtin.file:
4 state: directory
5 path: "{{ item.DocumentRoot }}"
6 owner: "{{ apache_data_owner }}"
7 group: "{{ apache_data_group }}"
8 mode: "{{ apache_dir_mode }}"
9 loop: "{{ apache_vhost }}"
10 loop_control:
11 label: "{{ item.ServerName }}"
12 when: item.create_document_root | d(false)
13
14- name: "Httpd-vhosts: Configure virtual hosts in {{ apache_conf_path ~ '/extra/' }}"
15 ansible.builtin.template:
16 src: vhost.j2
17 dest: "{{ apache_conf_path }}/extra/{{ item.ServerName }}.conf"
18 owner: "{{ apache_data_owner }}"
19 group: "{{ apache_data_group }}"
20 mode: "{{ apache_data_mode }}"
21 backup: "{{ apache_backup_conf }}"
22 loop: "{{ apache_vhost }}"
23 loop_control:
24 label: "{{ item.ServerName }}"
25 notify: Reload apache
26
27- name: "Httpd-vhosts: Incl virtual hosts in {{ apache_conf_path ~ '/httpd.conf' }}"
28 ansible.builtin.lineinfile:
29 dest: "{{ apache_conf_path }}/httpd.conf"
30 regexp: ^Include etc/apache{{ apache_version }}/extra/{{ item.ServerName }}.conf
31 line: Include etc/apache{{ apache_version }}/extra/{{ item.ServerName }}.conf
32 insertbefore: BOF
33 backup: "{{ apache_backup_conf }}"
34 loop: "{{ apache_vhost }}"
35 loop_control:
36 label: "{{ item.ServerName }}"
37 notify: Reload apache
38
39# EOF
httpd-confd.yml
Synopsis: Configure virtual hosts.
Configure virtual hosts (2) and configuration sections of the directories (6).
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
(6) at master and create files with the Apache virtual hosts
in the directory (31) at the remote host. The created files will be included in the configuration
file (41).
Include data from conf.d (2-16)
Include tasks from the file al_include_confd_vars_list
(11) in the role vbotka.ansible_lib
(12). This task takes as parameters the directory with the YAML configuration files (6) and the
type of the list (7), 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 (15) when debug
is enabled apache_debug: true
(16). The parameters (6,7) are tested inside the included tasks.
Create directories for virtual hosts (24-26)
Include tasks from fn/httpd-confd-vhost-dirs.yml
.
Configure virtual hosts in extra directory (28-37)
Create the Apache configuration files for the virtual hosts with the help of encode_apache
filter. Store the configuration file (31).
Include virtual hosts in httpd.conf (39-47)
Include virtual hosts in httpd.conf.
[tasks/httpd-confd-vhosts.yml]
1---
2- name: "Httpd-confd-vhosts: Include variables from {{ apache_confd_dir_vhosts }}"
3 block:
4 - name: "Httpd-confd-vhosts: Set variables for al_include_confd_vars_list"
5 ansible.builtin.set_fact:
6 al_include_confd_dir: "{{ apache_confd_dir_vhosts }}"
7 al_include_confd_vars_list_type: fname
8 - name: "Httpd-confd-vhosts: Include al_include_confd_vars_list"
9 ansible.builtin.include_role:
10 name: vbotka.ansible_lib
11 tasks_from: al_include_confd_vars_list
12 - name: "Httpd-confd-vhosts: Debug al_include_confd_vars_list"
13 ansible.builtin.debug:
14 var: item
15 loop: "{{ al_include_confd_vars_list }}"
16 when: apache_debug | bool
17
18- name: "Httpd-confd-vhosts: Debug list directories for virtual hosts"
19 ansible.builtin.debug:
20 msg: "{{ item | json_query('[].content[].sections[].content[].options[].DocumentRoot') }}"
21 loop: "{{ al_include_confd_vars_list | json_query('[].vars') }}"
22 when: apache_debug | bool
23
24- name: "Httpd-confd-vhosts: Create directories for virtual hosts"
25 ansible.builtin.include_tasks: fn/httpd-confd-vhost-dirs.yml
26 loop: "{{ al_include_confd_vars_list | json_query('[].vars') }}"
27
28- name: "Httpd-confd-vhosts: Configure virtual hosts in {{ apache_conf_path ~ '/extra/' }}"
29 ansible.builtin.template:
30 src: vhost2.j2
31 dest: "{{ apache_conf_path }}/extra/{{ item.fname }}.conf"
32 owner: "{{ apache_data_owner }}"
33 group: "{{ apache_data_group }}"
34 mode: "{{ apache_data_mode }}"
35 backup: "{{ apache_backup_conf }}"
36 loop: "{{ al_include_confd_vars_list }}"
37 notify: Reload apache
38
39- name: "Httpd-confd-vhosts: Incl virtual hosts in {{ apache_conf_path ~ '/httpd.conf' }}"
40 ansible.builtin.lineinfile:
41 dest: "{{ apache_conf_path }}/httpd.conf"
42 regexp: ^Include etc/apache{{ apache_version }}/extra/{{ item.fname }}.conf
43 line: Include etc/apache{{ apache_version }}/extra/{{ item.fname }}.conf
44 insertbefore: BOF
45 backup: "{{ apache_backup_conf }}"
46 loop: "{{ al_include_confd_vars_list }}"
47 notify: Reload apache
48
49# EOF
See also
Template vhost2.j2
Example of the configuration file vars/conf.d/vhosts-sample/example.com.yml
Included task al_include_confd_vars_list.yml.
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
(6) at master
and create the configuration files (23) 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-18)
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 (6) and the
type of the list (7), and returns the list with the YAML configurations of the sections stored in
the variable al_include_confd_vars_list
. The parameters (6,7) are tested inside the included
tasks.
Configure sections in Includes directory (20-29)
Use the filter encode_apache
to create the configuration files (23) for the sections. See the
template section2.j2
.
[tasks/httpd-confd-includes.yml]
1---
2- name: Include sections from apache_confd_dir_sections
3 block:
4 - name: "Httpd-confd-includes: Set variables for al_include_confd_vars_list"
5 ansible.builtin.set_fact:
6 al_include_confd_dir: "{{ apache_confd_dir_sections }}"
7 al_include_confd_vars_list_type: fname
8
9 - name: "Httpd-confd-includes: Include al_include_confd_vars_list"
10 ansible.builtin.include_role:
11 name: vbotka.ansible_lib
12 tasks_from: al_include_confd_vars_list
13
14 - name: "Httpd-confd-includes: Debug al_include_confd_vars_list"
15 ansible.builtin.debug:
16 var: item
17 loop: "{{ al_include_confd_vars_list }}"
18 when: apache_debug | bool
19
20- name: "Httpd-confd-includes: Configure sections in {{ apache_conf_path ~ '/Includes/' }}"
21 ansible.builtin.template:
22 src: section2.j2
23 dest: "{{ apache_conf_path }}/Includes/{{ item.fname }}.conf"
24 owner: "{{ apache_data_owner }}"
25 group: "{{ apache_data_group }}"
26 mode: "{{ apache_data_mode }}"
27 backup: "{{ apache_backup_conf }}"
28 loop: "{{ al_include_confd_vars_list }}"
29 notify: Reload apache
30
31# EOF
See also
Template section2.j2
Example of the configuration file vars/conf.d/section-sample/usr-local-www-example.com.yml
Details of the format are described in the filter encode_apache
service.yml
Synopsis: Configure service.
At the moment, only configuration of FreeBSD is implemented (3).
1---
2- name: "Service: Config FreeBSD"
3 ansible.builtin.import_tasks: rcconf.yml
4 when: ansible_os_family == 'FreeBSD'
5
6# EOF
See also
rcconf.yml
rcconf.yml
Synopsis: Configure service in FreeBSD.
Configure (3), enable (12) or disable (21) the service.
1---
2- name: "Rc_conf: configure /etc/rc.conf"
3 ansible.builtin.lineinfile:
4 dest: /etc/rc.conf
5 regexp: ^\s*{{ item.key }}\s*=(.*)$
6 line: '{{ item.key }}="{{ item.value }}"'
7 backup: "{{ apache_backup_conf }}"
8 loop: "{{ apache_rcconf }}"
9 notify: Graceful apache
10
11- name: "Rc_conf: Enable and Start Apache"
12 ansible.builtin.lineinfile:
13 dest: /etc/rc.conf
14 regexp: ^\s*{{ apache_service }}_enable\s*=(.*)$
15 line: '{{ apache_service }}_enable="YES"'
16 backup: "{{ apache_backup_conf }}"
17 notify: Enable and start apache
18 when: apache_enable | bool
19
20- name: "Rc_conf: Disable and Stop Apache"
21 ansible.builtin.lineinfile:
22 dest: /etc/rc.conf
23 regexp: ^\s*{{ apache_service }}_enable\s*=(.*)$
24 line: '{{ apache_service }}_enable="NO"'
25 backup: "{{ apache_backup_conf }}"
26 notify: Disable and stop apache
27 when: not apache_enable | bool
28
29# EOF
See also
<TBD>