Tasks

main.yml

Synopsis: Main task.

Import tasks if enabled.

[tasks/main.yml]

  1---
  2# tasks for freebsd_postinstall
  3
  4- name: Import vars.yml
  5  ansible.builtin.import_tasks: vars.yml
  6  when: fp_vars|bool
  7  tags: [fp_vars, always]
  8
  9- name: Import debug.yml
 10  ansible.builtin.import_tasks: debug.yml
 11  when: fp_debug|bool
 12  tags: fp_debug
 13
 14- name: Import sanity.yml
 15  ansible.builtin.import_tasks: sanity.yml
 16  when: fp_sanity|bool
 17  tags: always
 18
 19- name: Import cloud-providers.yml
 20  ansible.builtin.import_tasks: cloud-providers.yml
 21  tags: fp_cloud_proividers
 22
 23- name: Import loader.yml
 24  ansible.builtin.import_tasks: loader.yml
 25  when: fp_loader|bool
 26  tags: fp_loader
 27
 28- name: Import sysctl.yml
 29  ansible.builtin.import_tasks: sysctl.yml
 30  when: fp_sysctl|bool
 31  tags: fp_sysctl
 32
 33- name: Import tmpmfs.yml
 34  ansible.builtin.import_tasks: tmpmfs.yml
 35  when: fp_tmpmfs|bool
 36  tags: fp_tmpmfs
 37
 38- name: Import devfs.yml
 39  ansible.builtin.import_tasks: devfs.yml
 40  when: fp_devfs|bool
 41  tags: fp_devfs
 42
 43- name: Import dhclient.yml
 44  ansible.builtin.import_tasks: dhclient.yml
 45  when: fp_dhclient|bool
 46  tags: fp_dhclient
 47
 48- name: Import make.yml
 49  ansible.builtin.import_tasks: make.yml
 50  when: fp_make|bool
 51  tags: fp_make
 52
 53- name: Import swap.yml
 54  ansible.builtin.import_tasks: swap.yml
 55  when: fp_swap|bool
 56  tags: fp_swap
 57
 58- name: Import flush_handlers
 59  ansible.builtin.meta: flush_handlers
 60
 61- name: Import fstab.yml
 62  ansible.builtin.import_tasks: fstab.yml
 63  when: fp_fstab|bool
 64  tags: fp_fstab
 65
 66- name: Import mount-iso.yml
 67  ansible.builtin.import_tasks: mount-iso.yml
 68  when: fp_mount_iso|bool
 69  tags: fp_mount_iso
 70
 71- name: Import mount-img.yml
 72  ansible.builtin.import_tasks: mount-img.yml
 73  when: fp_mount_img|bool
 74  tags: fp_mount_img
 75
 76- name: Import packages.yml
 77  ansible.builtin.import_tasks: packages.yml
 78  when: fp_install|bool
 79  tags: fp_packages
 80
 81- name: Import copy.yml
 82  ansible.builtin.import_tasks: copy.yml
 83  when: fp_copy|bool
 84  tags: fp_copy
 85
 86- name: Import libmap.yml
 87  ansible.builtin.import_tasks: libmap.yml
 88  when: fp_libmap|bool
 89  tags: fp_libmap
 90
 91- name: Import groupwrappers.yml
 92  ansible.builtin.import_tasks: groupwrappers.yml
 93  when: fp_groupwrappers|bool
 94  tags: fp_groupwrappers
 95
 96- name: Import groups.yml
 97  ansible.builtin.import_tasks: groups.yml
 98  when: fp_groups|bool
 99  tags: fp_groups
100
101- name: Import users.yml
102  ansible.builtin.import_tasks: users.yml
103  when: fp_users|bool
104  tags: fp_users
105
106- name: Import passwords.yml
107  ansible.builtin.import_tasks: passwords.yml
108  when: fp_passwords|bool
109  tags: fp_passwords
110
111- name: Import hostname.yml
112  ansible.builtin.import_tasks: hostname.yml
113  when: fp_hostname|bool
114  tags: fp_hostname
115
116- name: Import hosts.yml
117  ansible.builtin.import_tasks: hosts.yml
118  when: fp_hosts|bool
119  tags: fp_hosts
120
121- name: Import inetd.yml
122  ansible.builtin.import_tasks: inetd.yml
123  when: fp_inetd|bool
124  tags: fp_inetd
125
126- name: Import ssh.yml
127  ansible.builtin.import_tasks: ssh.yml
128  when: fp_ssh|bool
129  tags: fp_ssh
130
131- name: Import sshd.yml
132  ansible.builtin.import_tasks: sshd.yml
133  when: fp_sshd|bool
134  tags: fp_sshd
135
136- name: Import authorized-key.yml
137  ansible.builtin.import_tasks: authorized-key.yml
138  when: fp_authorized_key|bool
139  tags: fp_authorized_key
140
141- name: Import timezone.yml
142  ansible.builtin.import_tasks: timezone.yml
143  when: fp_timezone|bool
144  tags: fp_timezone
145
146- name: Import ntp.yml
147  ansible.builtin.import_tasks: ntp.yml
148  when: fp_ntp|bool
149  tags: fp_ntp
150
151- name: Import ntpdate.yml
152  ansible.builtin.import_tasks: ntpdate.yml
153  when: fp_ntpdate|bool
154  tags: fp_ntpdate
155
156- name: Import nfs.yml
157  ansible.builtin.import_tasks: nfs.yml
158  when: fp_nfs|bool
159  tags: fp_nfs
160
161- name: Import nfsd.yml
162  ansible.builtin.import_tasks: nfsd.yml
163  when: fp_nfsd|bool
164  tags: fp_nfsd
165
166- name: Import smartd.yml
167  ansible.builtin.import_tasks: smartd.yml
168  when: fp_smartd|bool
169  tags: fp_smartd
170
171- name: Import apcupsd.yml
172  ansible.builtin.import_tasks: apcupsd.yml
173  when: fp_apcupsd|bool
174  tags: fp_apcupsd
175
176- name: Import hostapd.yml
177  ansible.builtin.import_tasks: hostapd.yml
178  when: fp_hostapd|bool
179  tags: fp_hostapd
180
181- name: Import procmail.yml
182  ansible.builtin.import_tasks: procmail.yml
183  when: fp_procmail|bool
184  tags: fp_procmail
185
186- name: Import motd.yml
187  ansible.builtin.import_tasks: motd.yml
188  when: fp_motd|bool
189  tags: fp_motd
190
191- name: Import gitserver.yml
192  ansible.builtin.import_tasks: gitserver.yml
193  when: fp_gitserver|bool
194  tags: fp_gitserver
195
196- name: Import sudoers.yml
197  ansible.builtin.import_tasks: sudoers.yml
198  when: fp_sudoers|bool
199  tags: fp_sudoers
200
201- name: Import cron.yml
202  ansible.builtin.import_tasks: cron.yml
203  when: fp_cron|bool
204  tags: fp_cron
205
206- name: Import resolvconf.yml
207  ansible.builtin.import_tasks: resolvconf.yml
208  when: fp_resolvconf|bool
209  tags: fp_resolvconf
210
211- name: Import aliases.yml
212  ansible.builtin.import_tasks: aliases.yml
213  when: fp_aliases|bool
214  tags: fp_aliases
215
216- name: Import periodic.yml
217  ansible.builtin.import_tasks: periodic.yml
218  when: fp_periodic|bool
219  tags: fp_periodic
220
221- name: Import wpasupplicant.yml
222  ansible.builtin.import_tasks: wpasupplicant.yml
223  when: fp_wpasupplicant|bool
224  tags: fp_wpasupplicant
225
226- name: Import linux.yml
227  ansible.builtin.import_tasks: linux.yml
228  when: fp_linux|bool
229  tags: fp_linux
230
231- name: Import login.yml
232  ansible.builtin.import_tasks: login.yml
233  when: fp_login|bool
234  tags: fp_login
235
236- name: Import snmpd.yml
237  ansible.builtin.import_tasks: snmpd.yml
238  when: fp_snmpd|bool
239  tags: fp_snmpd
240
241- name: Import qemu.yml
242  ansible.builtin.import_tasks: qemu.yml
243  when: fp_qemu|bool
244  tags: fp_qemu
245
246- name: Import freebsd-update.yml
247  ansible.builtin.import_tasks: freebsd-update.yml
248  when: fp_freebsd_update|bool
249  tags: fp_freebsd_update
250
251- name: Import syslogd.yml
252  ansible.builtin.import_tasks: syslogd.yml
253  when: fp_syslogd|bool
254  tags: fp_syslogd
255
256# EOF
257...

aliases.yml

Synopsis: Configure aliases.

Description of the task.

[tasks/aliases.yml]

 1---
 2
 3- name: "aliases: Configure {{ fp_aliases_conf_file }}"
 4  ansible.builtin.lineinfile:
 5    dest: "{{ fp_aliases_conf_file }}"
 6    regexp: '^\s*{{ item.alias }}:(.*)$'
 7    line: '{{ item.alias }}: {{ item.user }}'
 8    backup: "{{ fp_backup }}"
 9  loop: "{{ fp_aliases_conf }}"
10  notify: newaliases
11
12# EOF
13...

apcupsd.yml

Synopsis: Configure apcupsd.

Description of the task.

[tasks/apcupsd.yml]

 1---
 2
 3- name: "apcupsd: Enable and start apcupsd"
 4  ansible.builtin.lineinfile:
 5    dest: /etc/rc.conf
 6    regexp: '^\s*apcupsd_enable\s*=(.*)$'
 7    line: 'apcupsd_enable="YES"'
 8    backup: "{{ fp_backup }}"
 9  when: fp_apcupsd_enabled|bool
10  notify: enable and start apcupsd
11  tags: fp_apcupsd_rcconf
12
13- name: "apcupsd: Disable and stop apcupsd"
14  ansible.builtin.lineinfile:
15    dest: /etc/rc.conf
16    regexp: '^\s*apcupsd_enable\s*=(.*)$'
17    line: 'apcupsd_enable="NO"'
18    backup: "{{ fp_backup }}"
19  when: not fp_apcupsd_enabled|bool
20  notify: disable and stop apcupsd
21  tags: fp_apcupsd_rcconf
22
23- name: "apcupsd: Create directory {{ fp_apcupsd_conf_dir }}"
24  ansible.builtin.file:
25    state: directory
26    path: "{{ fp_apcupsd_conf_dir }}"
27    mode: "{{ fp_apcupsd_conf_dir_mode }}"
28  tags: fp_apcupsd_conf
29
30- name: "apcupsd: Configure apcupsd.conf"
31  ansible.builtin.template:
32    src: apcupsd.conf.j2
33    dest: "{{ fp_apcupsd_conf_file }}"
34    owner: "{{ fp_apcupsd_conf_owner }}"
35    group: "{{ fp_apcupsd_conf_group }}"
36    mode: "{{ fp_apcupsd_conf_mode }}"
37    backup: "{{ fp_backup }}"
38  notify: restart apcupsd
39  tags: fp_apcupsd_conf
40
41- name: "apcupsd: {{ state }} apcupsd"
42  ansible.builtin.service:
43    name: apcupsd
44    state: "{{ state }}"
45  vars:
46    state: "{{ fp_apcupsd_enabled|bool|ternary('started', 'stopped') }}"
47
48# EOF
49...

authorized-key.yml

Synopsis: Configure authorized-key.

Description of the task.

[tasks/authorized-key.yml]

 1---
 2
 3- name: "authorized-key: Get list of users"
 4  ansible.builtin.getent:
 5    database: passwd
 6  tags: fp_authorized_key_debug
 7
 8- name: "authorized-key: Debug (fp_authorized_key_debug={{ fp_authorized_key_debug }})"
 9  vars:
10    msg: |-
11      fp_authorized_key_fail: {{ fp_authorized_key_fail|bool }}
12      fp_authorized_key_install_individually: {{ fp_authorized_key_install_individually|bool }}
13      fp_authorized_key_install_exclusive: {{ fp_authorized_key_install_exclusive|bool }}
14      fp_authorized_key_follow: {{ fp_authorized_key_follow|bool }}
15      fp_authorized_key_key_options: {{ fp_authorized_key_key_options|default('UNDEFINED') }}
16      fp_authorized_key_manage_dir: {{ fp_authorized_key_manage_dir|bool }}
17      fp_authorized_key_path: {{ fp_authorized_key_path|default('UNDEFINED') }}
18      fp_authorized_key_state: {{ fp_authorized_key_state|default('present') }}
19      fp_authorized_key_validate_certs: {{ fp_authorized_key_validate_certs|bool }}
20      fp_authorized_key_conf:
21        {{ fp_authorized_key_conf|to_nice_yaml(indent=2)|indent(2) }}
22      getent_passwd keys:
23        {{ getent_passwd.keys()|list|sort|to_yaml(indent=2)|indent(2) }}
24  ansible.builtin.debug:
25    msg: "{{ '{}'.format(msg) }}"
26  when: fp_authorized_key_debug|bool
27  tags: fp_authorized_key_debug
28
29- name: "authorized-key: Configure authorized keys individually"
30  ansible.posix.authorized_key:
31    user: "{{ item.user }}"
32    key: "{{ item.key }}"
33    exclusive: "{{ item.exclusive|default(omit) }}"
34    comment: "{{ item.comment|default(omit) }}"
35    follow: "{{ item.follow|default(omit) }}"
36    key_options: "{{ item.key_iptions|default(omit) }}"
37    manage_dir: "{{ item.manage_dir|default(omit) }}"
38    path: "{{ item.path|default(omit) }}"
39    state: "{{ item.state|default(omit) }}"
40    validate_certs: "{{ item.validate_certs|default(omit) }}"
41  loop: "{{ fp_authorized_key_conf }}"
42  loop_control:
43    label: "{{ item.user }}"
44  when:
45    - fp_authorized_key_install_individually|bool
46    - fp_authorized_key_fail|bool or (item.user in getent_passwd.keys())
47
48- name: "authorized-key: Configure joined authorized keys"
49  block:
50    - name: "authorized-key: Create list of users"
51      ansible.builtin.set_fact:
52        local_list_users: "{{ fp_authorized_key_conf|map(attribute='user')|unique }}"
53    - name: "authorized-key: Debug show list of users"
54      ansible.builtin.debug:
55        var: local_list_users
56      when: fp_authorized_key_debug|bool
57    - name: "authorized-key: Debug show joined keys"
58      ansible.builtin.debug:
59        msg: "{{ '{}'.format(msg) }}"
60      loop: "{{ local_list_users }}"
61      vars:
62        my_query: "[?user=='{{ item }}'].key"
63        msg: "{{ fp_authorized_key_conf|json_query(my_query)|join('\n') }}"
64      when: fp_authorized_key_debug|bool
65    - name: "authorized-key: Configure joined authorized keys"
66      ansible.posix.authorized_key:
67        user: "{{ item }}"
68        key: "{{ fp_authorized_key_conf|json_query(my_query)|join('\n') }}"
69        exclusive: "{{ fp_authorized_key_install_exclusive|bool }}"
70        comment: "{{ fp_authorized_key_comment|default(omit) }}"
71        follow: "{{ fp_authorized_key_follow|bool }}"
72        key_options: "{{ fp_authorized_key_key_options|default(omit) }}"
73        manage_dir: "{{ fp_authorized_key_manage_dir|bool }}"
74        path: "{{ fp_authorized_key_path|default(omit) }}"
75        state: "{{ fp_authorized_key_state|default(omit) }}"
76        validate_certs: "{{ fp_authorized_key_validate_certs|bool }}"
77      loop: "{{ local_list_users }}"
78      vars:
79        my_query: "[?user=='{{ item }}'].key"
80  when:
81    - not fp_authorized_key_install_individually|bool
82    - fp_authorized_key_fail|bool or (item.user in getent_passwd.keys())
83
84# EOF
85...

cloud-providers.yml

Synopsis: Configure cloud-providers.

Description of the task.

[tasks/cloud-providers.yml]

1---
2
3- name: Import cloud-providers/digitalocean.yml
4  import_tasks: cloud-providers/digitalocean.yml
5  when: digitalocean|bool
6  tags: fp_do
7
8# EOF
9...

copy.yml

Synopsis: Configure copy.

Description of the task.

[tasks/copy.yml]

 1---
 2
 3- name: "copy: Debug (fp_copy_debug={{ fp_copy_debug }})"
 4  vars:
 5    msg: |-
 6         fp_unarch_default: {{ fp_unarch_default }}
 7         fp_unarch_optional: {{ fp_unarch_optional }}
 8         fp_synchronize_default:
 9           {{ fp_synchronize_default|to_nice_yaml(indent=2)|indent(2) }}
10         fp_synchronize_optional:
11           {{ fp_synchronize_optional|to_nice_yaml(indent=2)|indent(2) }}
12         fp_copy_dir: {{ fp_copy_dir }}
13         fp_copy_dir_default: {{ fp_copy_dir_default }}
14         fp_copy_arch_defaul: {{ fp_copy_arch_default }}
15         fp_copy_dir_optional: {{ fp_copy_dir_optional }}
16         fp_copy_arch_optional: {{ fp_copy_arch_optional }}
17         fp_unarchive_keep_newer: {{ fp_unarchive_keep_newer }}
18         fp_synchronize_delete: {{ fp_synchronize_delete }}
19         fp_synchronize_archive: {{ fp_synchronize_archive }}
20         fp_synchronize_checksum: {{ fp_synchronize_checksum }}
21         fp_synchronize_compress: {{ fp_synchronize_compress }}
22         fp_synchronize_copy_links: {{ fp_synchronize_copy_links }}
23         fp_synchronize_dirs: {{ fp_synchronize_dirs }}
24         fp_synchronize_existing_only: {{ fp_synchronize_existing_only }}
25         fp_synchronize_group: {{ fp_synchronize_group }}
26         fp_synchronize_mode: {{ fp_synchronize_mode }}
27         fp_synchronize_owner: {{ fp_synchronize_owner }}
28         fp_synchronize_perms: {{ fp_synchronize_perms }}
29         fp_synchronize_times: {{ fp_synchronize_times }}
30         fp_synchronize_verify_host: {{ fp_synchronize_verify_host }}
31  ansible.builtin.debug:
32    msg: "{{ '{}'.format(msg) }}"
33  when: fp_copy_debug|bool
34  tags: fp_copy_debug
35
36# Sync default
37- name: "copy: Synchronize default files {{ fp_copy_dir }}/{{ fp_copy_dir_default }}"
38  ansible.builtin.import_tasks: copy/sync-default.yml
39  when: fp_synchronize_default|length > 0
40  tags: fp_copy_sync_default
41
42# Sync optional
43- name: "copy: Synchronize optional files {{ fp_copy_dir }}/{{ fp_copy_dir_optional }}"
44  ansible.builtin.import_tasks: copy/sync-optional.yml
45  when: fp_synchronize_optional|length > 0
46  tags: fp_copy_sync_optional
47
48# Unarch default
49- name: "copy: Extract default files {{ fp_copy_dir }}/{{ fp_copy_arch_defaul }}"
50  ansible.builtin.import_tasks: copy/unarch-default.yml
51  when: fp_unarch_default|bool
52  tags: fp_copy_unarch_default
53
54# Unarch optional
55- name: "copy: Extract optional files {{ fp_copy_dir }}/{{ fp_copy_arch_optional }}"
56  ansible.builtin.import_tasks: copy/unarch-optional.yml
57  when: fp_unarch_optional|bool
58  tags: fp_copy_unarch_optional
59
60# EOF
61...

cron.yml

Synopsis: Configure cron.

Description of the task.

[tasks/cron.yml]

  1---
  2
  3- name: "cron: Debug (fp_cron_debug={{ fp_cron_debug }})"
  4  vars:
  5    msg: |-
  6      fp_cron_dir: {{ fp_cron_dir }}
  7      fp_cron_var:
  8        {{ fp_cron_var|to_yaml(indent=2)|indent(2) }}
  9      fp_cron_tab:
 10        {{ fp_cron_tab|to_nice_yaml(indent=2)|indent(2) }}
 11      fp_cron_file_system: {{ fp_cron_file_system }}
 12      fp_cron_var_system:
 13        {{ fp_cron_var_system|to_yaml(indent=2)|indent(2) }}
 14      fp_cron_tab_system:
 15        {{ fp_cron_tab_system|to_nice_yaml(indent=2)|indent(2) }}
 16  ansible.builtin.debug:
 17    msg: "{{ '{}'.format(msg) }}"
 18  when: fp_cron_debug|bool
 19  tags: fp_cron_debug
 20
 21# Note on "cron – Manage cron.d and crontab entries"
 22# https://docs.ansible.com/ansible/latest/modules/cron_module.html
 23# Quoting from Synopsis: "When crontab jobs are managed: the module
 24# includes one line with the description of the crontab entry
 25# "#Ansible: <name>" corresponding to the “name” passed to the module,
 26# which is used by future ansible/module calls to find/check the
 27# state. The “name” parameter should be unique, and changing the
 28# “name” value will result in a new cron task being created (or a
 29# different one being removed).
 30
 31# If "# <name>" entry is present change it to "#Ansible: <name>" to
 32# avoid double-entries
 33
 34- name: "cron: Rename present crontab entries"
 35  ansible.builtin.include_tasks:
 36    file: fn/cron-rename-entry.yml
 37  loop: "{{ fp_cron_tab }}"
 38  tags: fp_cron_rename_entries
 39
 40- name: "cron: Rename present crontab entries system"
 41  ansible.builtin.replace:
 42    path: "{{ fp_cron_file_system }}"
 43    regexp: '^\s*#\s*{{ item.name }}$'
 44    replace: "#Ansible: {{ item.name }}"
 45    backup: "{{ fp_backup }}"
 46  loop: "{{ fp_cron_tab }}"
 47  loop_control:
 48    label: "{{ item.name }}"
 49  tags: fp_cron_rename_entries_system
 50
 51- name: "cron: Configure cron variables"
 52  community.general.cronvar:
 53    name: "{{ item.name }}"
 54    value: "{{ item.value }}"
 55    user: "{{ item.user }}"
 56  loop: "{{ fp_cron_var }}"
 57  tags: fp_cron_var
 58
 59- name: "cron: Configure crontab entries"
 60  ansible.builtin.cron:
 61    state: "{{ item.state }}"
 62    user: "{{ item.user }}"
 63    name: "{{ item.name }}"
 64    minute: "{{ item.minute }}"
 65    hour: "{{ item.hour }}"
 66    day: "{{ item.day }}"
 67    month: "{{ item.month }}"
 68    weekday: "{{ item.weekday }}"
 69    job: "{{ item.command }}"
 70  loop: "{{ fp_cron_tab }}"
 71  loop_control:
 72    label: "{{ item.name }}"
 73  tags: fp_cron_tab
 74
 75- name: "cron: Configure cron variables system"
 76  community.general.cronvar:
 77    cron_file: "{{ fp_cron_file_system }}"
 78    name: "{{ item.name }}"
 79    value: "{{ item.value }}"
 80  loop: "{{ fp_cron_var_system }}"
 81  tags: fp_cron_var_system
 82
 83- name: "cron: Configure crontab entries system"
 84  ansible.builtin.cron:
 85    cron_file: "{{ fp_cron_file_system }}"
 86    state: "{{ item.state }}"
 87    user: "{{ item.user }}"
 88    name: "{{ item.name }}"
 89    minute: "{{ item.minute }}"
 90    hour: "{{ item.hour }}"
 91    day: "{{ item.day }}"
 92    month: "{{ item.month }}"
 93    weekday: "{{ item.weekday }}"
 94    job: "{{ item.command }}"
 95  loop: "{{ fp_cron_tab_system }}"
 96  loop_control:
 97    label: "{{ item.name }}"
 98  tags: fp_cron_tab_system
 99
100# TODO:
101# /etc/cron.d
102# /usr/local/etc/cron.d
103
104# EOF
105...

debug.yml

Synopsis: Configure debug.

Description of the task.

[tasks/debug.yml]

 1---
 2
 3- name: "FreeBSD postinstall Debug"
 4  vars:
 5    _fp_qemu_install_varnames: "{{ query('varnames', '^fp_qemu_(.*)install$') }}"
 6    _fp_qemu_install_values: "{{ _fp_qemu_install_varnames|map('extract', vars)|list }}"
 7    _fp_qemu_install_dict: "{{ dict(_fp_qemu_install_varnames|zip(_fp_qemu_install_values)) }}"
 8    msg: |-
 9         ansible_architecture: {{ ansible_architecture }}
10         ansible_os_family: {{ ansible_os_family }}
11         ansible_distribution: {{ ansible_distribution }}
12         ansible_distribution_major_version: {{ ansible_distribution_major_version }}
13         ansible_distribution_version: {{ ansible_distribution_version }}
14         ansible_distribution_release: {{ ansible_distribution_release }}
15         ansible_python_version: {{ ansible_python_version }}
16
17         rc_conf_hostname: {{ rc_conf_hostname }}
18         fp_domain: {{ fp_domain }}
19         aws: {{ aws }}
20         digitalocean: {{ digitalocean }}
21         gcp: {{ gcp }}
22
23         freebsd_install_method: {{ freebsd_install_method }}
24         freebsd_use_packages: {{ freebsd_use_packages|default('UNDEFINED') }}
25         freebsd_install_retries: {{ freebsd_install_retries }}
26         freebsd_install_delay: {{ freebsd_install_delay }}
27
28         fp_install: {{ fp_install }}
29         fp_backup: {{ fp_backup }}
30         fp_vars: {{ fp_vars }} fp_vars_default_versions: {{ fp_vars_default_versions }}
31         fp_sanity: {{ fp_sanity }} fp_sanity_tags_fatal: {{ fp_sanity_tags_fatal }}
32
33         fp_aliases: {{ fp_aliases }}
34         fp_apcupsd: {{ fp_apcupsd }} fp_apcupsd_install: {{ fp_apcupsd_install }} fp_apcupsd_enabled: {{ fp_apcupsd_enabled }}
35         fp_authorized_key: {{ fp_authorized_key }}
36         fp_copy: {{ fp_copy }} fp_unarch_default: {{ fp_unarch_default }} fp_unarch_optional: {{ fp_unarch_optional }}
37         fp_cron: {{ fp_cron }}
38         fp_devfs: {{ fp_devfs }} fp_devfs_enabled: {{ fp_devfs_enabled }}
39         fp_dhclient: {{ fp_dhclient }}
40         fp_freebsd_update: {{ fp_freebsd_update }}
41         fp_fstab: {{ fp_fstab }}
42         fp_gitserver: {{ fp_gitserver }} fp_gitserver_install: {{ fp_gitserver_install }}
43         fp_groups: {{ fp_groups }}
44         fp_groupwrappers: {{ fp_groupwrappers }} fp_groupwrappers_install: {{ fp_groupwrappers_install }}
45         fp_hostapd: {{ fp_hostapd }} fp_hostapd_install: {{ fp_hostapd_install }} fp_hostapd_enabled: {{ fp_hostapd_enabled }}
46         fp_hostname: {{ fp_hostname }}
47         fp_hosts: {{ fp_hosts }}
48         fp_inetd: {{ fp_inetd }} fp_inetd_enabled: {{ fp_inetd_enabled }}
49         fp_libmap: {{ fp_libmap }}
50         fp_linux: {{ fp_linux }} fp_linux_install: {{ fp_linux_install }} fp_linux_enable: {{ fp_linux_enable }}
51         fp_loader: {{ fp_loader }} fp_loader_warning: {{ fp_loader_warning }}
52         fp_login: {{ fp_login }} fp_login_conf_global: {{ fp_login_conf_global }}
53         fp_make: {{ fp_make }}
54         fp_motd: {{ fp_motd }}
55         fp_mount_img: {{ fp_mount_img }}
56         fp_mount_iso: {{ fp_mount_iso }}
57         fp_nfs: {{ fp_nfs }} fp_nfs_enable: {{ fp_nfs_enable }}
58         fp_nfsd: {{ fp_nfsd }} fp_nfsd_enable: {{ fp_nfsd_enable }}
59         fp_ntp: {{ fp_ntp }} fp_ntp_enable: {{ fp_ntp_enable }}
60         fp_ntpdate: {{ fp_ntpdate }} fp_ntpdate_enable: {{ fp_ntpdate_enable }}
61         fp_passwords: {{ fp_passwords }}
62         fp_periodic: {{ fp_periodic }}
63         fp_procmail: {{ fp_procmail }} fp_procmail_install: {{ fp_procmail_install }}
64         fp_qemu: {{ fp_qemu }} fp_qemu_enabled: {{ fp_qemu_enabled }}{% for k,v in _fp_qemu_install_dict.items() %} {{ k }}: {{ v }}{% endfor %}
65
66         fp_resolvconf: {{ fp_resolvconf }}
67         fp_smartd: {{ fp_smartd }} fp_smartd_install: {{ fp_smartd_install }} fp_smartd_enabled: {{ fp_smartd_enabled }}
68         fp_snmpd: {{ fp_snmpd }} fp_snmpd_install: {{ fp_snmpd_install }} fp_snmpd_enabled: {{ fp_snmpd_enabled }}
69         fp_ssh: {{ fp_ssh }}
70         fp_sshd: {{ fp_sshd }} fp_sshd_enable: {{ fp_sshd_enable }}
71         fp_sudoers: {{ fp_sudoers }}
72         fp_swap: {{ fp_swap }} fp_swap_enable: {{ fp_swap_enable }}
73         fp_sysctl: {{ fp_sysctl }}
74         fp_syslogd: {{ fp_syslogd }} fp_syslogd_enabled: {{ fp_syslogd_enabled }}
75         fp_timezone: {{ fp_timezone }}
76         fp_tmpmfs: {{ fp_tmpmfs }}
77         fp_users: {{ fp_users }}
78         fp_wpasuppliant: {{ fp_wpasupplicant }} fp_wpasuppliant_install: {{ fp_wpasupplicant_install }}
79
80         fp_mountd_enable: {{ fp_mountd_enable }}
81         fp_rpcbind_enable: {{ fp_rpcbind_enable }}
82         fp_rpc_lockd_enable: {{ fp_rpc_lockd_enable }}
83         fp_rpc_statd_enable: {{ fp_rpc_statd_enable }}
84  ansible.builtin.debug:
85    msg: "{{ '{}'.format(msg) }}"
86
87# EOF
88...

devfs.yml

Synopsis: Configure devfs.

Description of the task.

[tasks/devfs.yml]

  1---
  2
  3- name: "devfs: Debug (fp_devfs_debug={{ fp_devfs_debug }})"
  4  vars:
  5    msg: |-
  6         fp_devfs_enabled: {{ fp_devfs_enabled }}
  7         fp_devfs_load_rulesets: {{ fp_devfs_load_rulesets }}
  8         fp_devfs_system_ruleset: {{ fp_devfs_system_ruleset }}
  9         fp_devfs_rulesets: {{ fp_devfs_rulesets }}
 10         fp_devfs_set_rulesets: {{ fp_devfs_set_rulesets }}
 11         fp_devfs_rcconf:
 12           {{ fp_devfs_rcconf|to_yaml(indent=2)|indent(2) }}
 13         fp_devfs_conf_path: {{ fp_devfs_conf_path }}
 14         fp_devfs_conf:
 15           {{ fp_devfs_conf|to_yaml(indent=2)|indent(2) }}
 16         fp_devfs_rules_path: {{ fp_devfs_rules_path }}
 17         fp_devfs_rules_mode: {{ fp_devfs_rules_mode }}
 18         fp_devfs_rules:
 19           {{ fp_devfs_rules|to_yaml(indent=2)|indent(2) }}
 20  ansible.builtin.debug:
 21    msg: "{{ '{}'.format(msg) }}"
 22  when: fp_devfs_debug|bool
 23  tags: fp_devfs_debug
 24
 25- name: "devfs: Shell: /etc/rc.d/devfs rcvar | grep ^devfs*"
 26  ansible.builtin.shell:
 27    cmd: >
 28      /etc/rc.d/devfs rcvar | grep ^devfs*
 29  register: result
 30  changed_when: false
 31  ignore_errors: true
 32  tags: fp_devfs_rcvar
 33
 34- name: "devfs: Test rcvar for system module"
 35  block:
 36    - name: "devfs: ERROR no rcvar"
 37      ansible.builtin.debug:
 38        msg: |
 39          [ERROR] unable to determine rcvar. End of play.
 40          Variable rcvar is missing in the file /etc/rc.d/devfs
 41          Put the following line into the file /etc/rc.d/devfs
 42          rcvar="devfs_load_rulesets"
 43    - name: "devfs: Block: End of play."
 44      ansible.builtin.meta: end_play
 45  when:
 46    - not ansible_check_mode
 47    - result|default({}) is failed
 48  tags: fp_devfs_rcvar
 49
 50- name: "devfs: Debug print rcvar"
 51  ansible.builtin.debug:
 52    var: result.stdout_lines|default('not defined')
 53  when: fp_devfs_debug|bool
 54  tags: fp_devfs_rcvar
 55
 56- name: "devfs: Enable and start devfs"
 57  ansible.builtin.lineinfile:
 58    dest: /etc/rc.conf
 59    regexp: '^\s*devfs_load_rulesets\s*=(.*)$'
 60    line: 'devfs_load_rulesets="YES"'
 61    backup: "{{ fp_backup }}"
 62  notify: enable and start devfs
 63  when: fp_devfs_enabled|bool
 64  tags: fp_devfs_rcconf
 65
 66- name: "devfs: Disable and stop devfs"
 67  ansible.builtin.lineinfile:
 68    dest: /etc/rc.conf
 69    regexp: '^\s*devfs_load_rulesets\s*=(.*)$'
 70    line: 'devfs_load_rulesets="NO"'
 71    backup: "{{ fp_backup }}"
 72  notify: disable and stop devfs
 73  when: not fp_devfs_enabled|bool
 74  tags: fp_devfs_rcconf
 75
 76- name: "devfs: Configure devfs in /etc/rc.conf"
 77  ansible.builtin.lineinfile:
 78    dest: /etc/rc.conf
 79    regexp: '^\s*{{ item.key }}\s*=(.*)$'
 80    line: '{{ item.key }}="{{ item.value }}"'
 81    backup: "{{ fp_backup }}"
 82  loop: "{{ fp_devfs_rcconf }}"
 83  notify: restart devfs
 84  tags: fp_devfs_rcconf
 85
 86- name: "devfs: Configure {{ fp_devfs_conf_path }}"
 87  ansible.builtin.lineinfile:
 88    dest: "{{ fp_devfs_conf_path }}"
 89    regexp: '^\s*{{ item.action }}\s+{{ item.devname }}\s+{{ item.arg }}'
 90    line: "{{ item.action }} {{ item.devname }} {{ item.arg }}"
 91    backup: "{{ fp_backup }}"
 92  loop: "{{ fp_devfs_conf }}"
 93  notify: restart devfs
 94  tags: fp_devfs_conf
 95
 96- name: "devfs: Configure {{ fp_devfs_rules_path }}"
 97  community.general.ini_file:
 98    path: "{{ fp_devfs_rules_path }}"
 99    create: true
100    mode: "{{ fp_devfs_rules_mode }}"
101    allow_no_value: true
102    owner: "{{ fp_devfs_owner }}"
103    group: "{{ fp_devfs_group }}"
104    section: "{{ item.section }}"
105    option: "{{ item.option }}"
106    value: "{{ item.value|default(omit) }}"
107    state: "{{ item.state|(default('present') }}"
108    backup: "{{ fp_backup }}"
109  loop: "{{ fp_devfs_rules }}"
110  notify: restart devfs
111  tags: fp_devfs_rules
112
113- name: "devfs: {{ state }} devfs"
114  ansible.builtin.service:
115    name: devfs
116    state: "{{ state }}"
117  vars:
118    state: "{{ fp_devfs_enabled|bool|ternary('started', 'stopped') }}"
119
120# EOF
121...

dhclient.yml

Synopsis: Configure dhclient.

Description of the task.

[tasks/dhclient.yml]

  1---
  2
  3- name: "dhclient: Debug (fp_dhclient_debug={{ fp_dhclient_debug }})"
  4  vars:
  5    msg: |-
  6         fp_dhclient_ifn: {{ fp_dhclient_ifn }}
  7         fp_dhclient_ifn_rcconf: {{ fp_dhclient_ifn_rcconf }}
  8         fp_dhclient_ifn_leases: {{ fp_dhclient_ifn_leases }}
  9         fp_dhclient_sanity: {{ fp_dhclient_sanity }}
 10         fp_dhclient_conf_path: {{ fp_dhclient_conf_path }}
 11
 12         fp_dhclient_conf_defaults:
 13           {{ fp_dhclient_conf_defaults|to_yaml(indent=2)|indent(2) }}
 14         fp_dhclient_conf_blocks:
 15           {{ fp_dhclient_conf_blocks|to_nice_yaml(indent=2)|indent(2) }}
 16  ansible.builtin.debug:
 17    msg: "{{ '{}'.format(msg) }}"
 18  when: fp_dhclient_debug|bool
 19  tags: fp_dhclient_debug
 20
 21- name: "dhclient: Sanity"
 22  block:
 23    - name: "dhclient: Sanity: List fp_dhclient_ifn empty"
 24      ansible.builtin.assert:
 25        that: (fp_dhclient_ifn|length == 0)|
 26              ternary(fp_dhclient_ifn_rcconf != fp_dhclient_ifn_leases, true)
 27        fail_msg: |-
 28          The list of interfaces fp_dhclient_ifn is empty. Either
 29          fp_dhclient_ifn_rcconf or fp_dhclient_ifn_leases must be True,
 30          but not both.
 31    - name: "dhclient: Sanity: List fp_dhclient_ifn not empty"
 32      ansible.builtin.assert:
 33        that: (fp_dhclient_ifn|length > 0)|
 34              ternary(not(fp_dhclient_ifn_rcconf or fp_dhclient_ifn_leases), true)
 35        fail_msg: |-
 36          The list of interfaces fp_dhclient_ifn is not empty. Both
 37          fp_dhclient_ifn_rcconf and fp_dhclient_ifn_leases must be
 38          False.
 39  when: fp_dhclient_sanity|bool
 40  tags: fp_dhclient_sanity
 41
 42- name: Get interfaces from /var/db/dhclient.leases.*
 43  block:
 44    - name: "dhclient: Get interfaces /var/db/dhclient.leases.*"
 45      ansible.builtin.shell:
 46        cmd: ls -1 /var/db/dhclient* | rev | cut -d . -f 1 | rev
 47      register: result
 48      changed_when: false
 49    - name: "dhclient: Debug interfaces /var/db/dhclient.leases.*"
 50      ansible.builtin.debug:
 51        var: result.stdout_lines
 52      when: fp_dhclient_debug|bool
 53    - name: "dhclient: Get status of dhclients"
 54      ansible.builtin.command:
 55        cmd: "/etc/rc.d/dhclient status {{ item }}"
 56      register: result
 57      failed_when: false
 58      changed_when: false
 59      loop: "{{ result.stdout_lines }}"
 60    - name: "dhclient: Set fp_dhclient_ifn"
 61      ansible.builtin.set_fact:
 62        fp_dhclient_ifn: "{{ result.results|
 63                             rejectattr('rc', 'gt', 0)|
 64                             map(attribute='item')|list }}"
 65    - name: "dhclient: Debug fp_dhclient_ifn"
 66      ansible.builtin.debug:
 67        var: fp_dhclient_ifn
 68      when: fp_dhclient_debug|bool
 69  when: fp_dhclient_ifn_leases|bool
 70  tags: fp_dhclient_ifn_leases
 71
 72- name: Get interfaces from /etc/rc.conf
 73  block:
 74    - name: "dhclient: Get interfaces from /etc/rc.conf"
 75      ansible.builtin.command:
 76        cmd: grep '^ifconfig_.*$' /etc/rc.conf
 77      register: result
 78      changed_when: false
 79    - name: "dhclient: Debug interfaces from /etc/rc.conf"
 80      ansible.builtin.debug:
 81        var: result.stdout_lines
 82      when: fp_dhclient_debug|bool
 83    - name: "dhclient: Set fp_dhclient_ifn"
 84      ansible.builtin.set_fact:
 85        fp_dhclient_ifn: "{{ _keys }}"
 86      vars:
 87        _regex: '^ifconfig_.*\s*=.*DHCP.*$'
 88        _arr: "{{ result.stdout_lines|
 89                  select('match', _regex)|
 90                  map('split', '=')|list }}"
 91        _keys: "{{ _arr|
 92                   map(attribute=0)|
 93                   map('split', '_')|
 94                   map(attribute=1)|list }}"
 95    - name: "dhclient: Debug fp_dhclient_ifn"
 96      ansible.builtin.debug:
 97        var: fp_dhclient_ifn
 98      when: fp_dhclient_debug|bool
 99  when: fp_dhclient_ifn_rcconf|bool
100  tags: fp_dhclient_ifn_rcconf
101
102- name: "dhclient: Change owner, group and permissions {{ fp_dhclient_conf_path }}"
103  ansible.builtin.file:
104    path: "{{ fp_dhclient_conf_path }}"
105    owner: root
106    group: wheel
107    mode: '0644'
108  tags: fp_dhclient_conf_create
109
110- name: "dhclient: Configure defaults in {{ fp_dhclient_conf_path }}"
111  ansible.builtin.lineinfile:
112    dest: "{{ fp_dhclient_conf_path }}"
113    insertbefore: BOF
114    regexp: '{{ item.key }}\s+(.*)$'
115    line: '{{ item.key }} {{ item.value }};'
116    backup: "{{ fp_backup }}"
117  loop: "{{ fp_dhclient_conf_defaults }}"
118  notify: restart dhclient all
119  tags: fp_dhclient_conf_defaults
120
121- name: "dhclient: Configure blocks in {{ fp_dhclient_conf_path }}"
122  ansible.builtin.blockinfile:
123    dest: "{{ fp_dhclient_conf_path }}"
124    insertafter: EOF
125    marker: "# {mark} {{ item.type }} {{ item.ifn }}"
126    block: "{{ item.block }}"
127    backup: "{{ fp_backup }}"
128  register: fp_dhclient_conf_changes
129  loop: "{{ fp_dhclient_conf_blocks }}"
130  loop_control:
131    label: "{{ item.type }} {{ item.ifn }}"
132  notify: restart dhclient blocks
133  tags: fp_dhclient_conf_blocks
134
135- name: "dhclient: Debug changed interfaces to be restarted"
136  ansible.builtin.debug:
137    msg: "{{ fp_dhclient_conf_changes.results|
138             selectattr('changed')|
139             map(attribute='item.ifn')|
140             unique }}"
141  when: fp_dhclient_debug|bool
142  tags: fp_dhclient_conf_blocks
143
144# EOF
145...

freebsd-update.yml

Synopsis: Configure freebsd-update.

Description of the task.

[tasks/freebsd-update.yml]

  1---
  2
  3- name: Get current config
  4  block:
  5
  6    - name: "freebsd-update: Read /etc/freebsd-update.conf"
  7      ansible.builtin.shell:
  8        cmd: 'freebsd-update showconfig | grep .*=.*'
  9      register: out
 10      changed_when: false
 11
 12    - name: "freebsd-update: Create fp_freebsd_update_conf"
 13      ansible.builtin.set_fact:
 14        fp_freebsd_update_conf: "{{ dict(out.stdout_lines |
 15                                         map('split', '=') |
 16                                         map('map', 'trim')) }}"
 17#       fp_freebsd_update_conf: "{{ out.stdout | community.general.jc('ini') }}"
 18
 19    - name: "freebsd-update: Debug fp_freebsd_update_conf"
 20      ansible.builtin.debug:
 21        var: fp_freebsd_update_conf
 22      when: fp_freebsd_update_debug|bool
 23
 24  tags:
 25    - fp_freebsd_update_getconf
 26    - fp_freebsd_update_debug
 27    - fp_freebsd_update_protect_keyprint
 28    - fp_freebsd_update_sanity
 29
 30- name: "freebsd-update: Debug"
 31  vars:
 32    msg: |-
 33      fp_freebsd_update_protect_KeyPrint: {{ fp_freebsd_update_protect_KeyPrint }}
 34      fp_freebsd_update_sanity: {{ fp_freebsd_update_sanity }}
 35      fp_freebsd_update_sanity_quiet: {{ fp_freebsd_update_sanity_quiet }}
 36      fp_freebsd_update_sanity_KeyPrint: {{ fp_freebsd_update_sanity_KeyPrint }}
 37      fp_freebsd_update_conf_orig: {{ fp_freebsd_update_conf_orig }}
 38
 39      fp_freebsd_update_conf_template: {{ fp_freebsd_update_conf_template }}
 40      fp_freebsd_update_KeyPrint: {{ fp_freebsd_update_KeyPrint }}
 41      fp_freebsd_update_Components:
 42        {{ fp_freebsd_update_Components|to_nice_yaml(indent=2)|indent(2) }}
 43      fp_freebsd_update_IgnorePaths: {{ fp_freebsd_update_IgnorePaths }}
 44      fp_freebsd_update_IDSIgnorePaths:
 45        {{ fp_freebsd_update_IDSIgnorePaths|to_nice_yaml(indent=2)|indent(2) }}
 46      fp_freebsd_update_UpdateIfUnmodified:
 47        {{ fp_freebsd_update_UpdateIfUnmodified|to_nice_yaml(indent=2)|indent(2) }}
 48      fp_freebsd_update_MergeChanges:
 49        {{ fp_freebsd_update_MergeChanges|to_nice_yaml(indent=2)|indent(2) }}
 50      fp_freebsd_update_WorkDir: {{ fp_freebsd_update_WorkDir|d('UNDEFINED') }}
 51      fp_freebsd_update_MailTo: {{ fp_freebsd_update_MailTo|d('UNDEFINED') }}
 52      fp_freebsd_update_AllowAdd: {{ fp_freebsd_update_AllowAdd|d('UNDEFINED') }}
 53      fp_freebsd_update_AllowDelete: {{ fp_freebsd_update_AllowDelete|d('UNDEFINED') }}
 54      fp_freebsd_update_KeepModifiedMetadata: {{ fp_freebsd_update_KeepModifiedMetadata|d('UNDEFINED') }}
 55      fp_freebsd_update_StrictComponents: {{ fp_freebsd_update_StrictComponents|d('UNDEFINED') }}
 56      fp_freebsd_update_BackupKernel: {{ fp_freebsd_update_BackupKernel|d('UNDEFINED') }}
 57      fp_freebsd_update_BackupKernelDir: {{ fp_freebsd_update_BackupKernelDir|d('UNDEFINED') }}
 58      fp_freebsd_update_BackupKernelSymbolFiles: {{ fp_freebsd_update_BackupKernelSymbolFiles|d('UNDEFINED') }}
 59      fp_freebsd_update_CreateBootEnv: {{ fp_freebsd_update_CreateBootEnv|d('UNDEFINED') }}
 60  ansible.builtin.debug:
 61    msg: "{{ '{}'.format(msg) }}"
 62  when: fp_freebsd_update_debug|bool
 63  tags: fp_freebsd_update_debug
 64
 65- name: "freebsd-update: Protect trusted keyprint"
 66  ansible.builtin.assert:
 67    quiet: "{{ fp_freebsd_update_sanity_quiet }}"
 68    that:
 69      fp_freebsd_update_conf.KEYPRINT == fp_freebsd_update_KeyPrint
 70    fail_msg: '[ERR] Changing KeyPrint not allowed.'
 71    success_msg: '[OK]  KeyPrint will not change.'
 72  when:
 73    - fp_freebsd_update_protect_KeyPrint|bool
 74    - not ansible_check_mode
 75  tags: fp_freebsd_update_protect_keyprint
 76
 77- name: Sanity
 78  block:
 79
 80    - name: "freebsd-update: Sanity trusted keyprint"
 81      ansible.builtin.assert:
 82        quiet: "{{ fp_freebsd_update_sanity_quiet }}"
 83        that:
 84          fp_freebsd_update_KeyPrint is regex('^[0-9a-fA-F]{64}$')
 85        fail_msg: '[ERR] KeyPrint not valid.'
 86        success_msg: '[OK]  KeyPrint is valid.'
 87      when: fp_freebsd_update_sanity_KeyPrint|bool
 88
 89  when: fp_freebsd_update_sanity|bool
 90  tags: fp_freebsd_update_sanity
 91
 92- name: "freebsd-update: Backup origin /etc/freebsd-update.conf"
 93  ansible.builtin.command:
 94    cmd: cp /etc/freebsd-update.conf /etc/freebsd-update.conf.orig
 95    creates: /etc/freebsd-update.conf.orig
 96  when: fp_freebsd_update_conf_orig|bool
 97  tags: fp_freebsd_update_conf_orig
 98
 99- name: "freebsd-update: Create /etc/freebsd-update.conf from template"
100  ansible.builtin.template:
101    src: "{{ fp_freebsd_update_conf_template }}"
102    dest: /etc/freebsd-update.conf
103    owner: root
104    group: wheel
105    mode: '0644'
106    backup: "{{ fp_backup }}"
107  tags: fp_freebsd_update_conf
108
109# EOF
110...

fstab.yml

Synopsis: Configure fstab.

Description of the task.

[tasks/fstab.yml]

 1---
 2
 3- name: "fstab: Configure fstab entries by mount"
 4  ansible.posix.mount:
 5    name: "{{ item.name }}"
 6    src: "{{ item.src }}"
 7    fstype: "{{ item.fstype }}"
 8    opts: "{{ item.opts }}"
 9    dump: "{{ item.dump|default('0') }}"
10    passno: "{{ item.passno|default('0') }}"
11    state: "{{ item.state|default('mounted') }}"
12    backup: "{{ fp_backup }}"
13  loop: "{{ fp_fstab_entries|
14            rejectattr('fstype', 'in', fp_fstab_fstype_blacklist) }}"
15
16- name: "fstab: Configure fstab swap entries."
17  ansible.builtin.lineinfile:
18    path: /etc/fstab
19    regexp: '^\s*{{ item.src }}\s+(.*)$'
20    line: "{{ item.src }} none swap {{ item.opts }} 0 0"
21    state: "{{ item.state|default('present') }}"
22    backup: "{{ fp_backup }}"
23  notify: mount swap
24  loop: "{{ fp_fstab_entries|
25            selectattr('fstype', 'eq', 'swap') }}"
26
27# NOTE:
28# The module ansible.posix.mount do not mount swap
29# SEE:
30# * Add support for swap management #106
31#   https://github.com/ansible-collections/ansible.posix/issues/106
32# * New module swap: manage ... swap partitions #49455
33#   https://github.com/ansible/ansible/pull/49455
34
35# EOF
36...

gitserver.yml

Synopsis: Configure gitserver.

Description of the task.

[tasks/gitserver.yml]

 1---
 2
 3- name: "gitserver: Add {{ fp_gitserver_group }} group"
 4  ansible.builtin.group:
 5    name: "{{ fp_gitserver_group }}"
 6    gid: "{{ fp_gitserver_group_gid|default(omit) }}"
 7  tags: fp_gitserver_group
 8
 9- name: "gitserver: Add {{ fp_gitserver_owner }} user"
10  ansible.builtin.user:
11    name: "{{ fp_gitserver_owner }}"
12    uid: "{{ fp_gitserver_owner_uid|default(omit) }}"
13    shell: "{{ fp_gitserver_owner_shell|default(omit) }}"
14    home: "{{ fp_gitserver_owner_home|default(omit) }}"
15  tags: fp_gitserver_owner
16
17- name: "gitserver: Add user {{ fp_gitserver_owner }} to {{ fp_gitserver_group }} group"
18  ansible.builtin.user:
19    name: "{{ fp_gitserver_owner }}"
20    groups: "{{ fp_gitserver_group }}"
21  tags: fp_gitserver_owner
22
23- name: "gitserver: Set ownership and permissions of {{ fp_gitserver_dir }}"
24  ansible.builtin.file:
25    state: directory
26    path: "{{ fp_gitserver_dir }}"
27    owner: "{{ fp_gitserver_owner }}"
28    group: "{{ fp_gitserver_group }}"
29    mode: "{{ fp_gitserver_dir_mode }}"
30  tags: fp_gitserver_dir
31
32# TODO: How do I Setup up a Multi-User Git Server
33# https://forums.freebsd.org/threads/how-do-i-setup-up-a-multi-user-git-server.50969/
34
35# EOF
36...

groups.yml

Synopsis: Configure groups.

Description of the task.

[tasks/groups.yml]

 1---
 2
 3- name: "groups: Debug (fp_groups_debug={{ fp_groups_debug }})"
 4  vars:
 5    msg: |-
 6      fp_groups_conf:
 7        {{ fp_groups_conf|to_nice_yaml(indent=2)|indent(2) }}
 8  ansible.builtin.debug:
 9    msg: "{{ '{}'.format(msg) }}"
10  when: fp_groups_debug|bool
11  tags: fp_groups_debug
12
13- name: "groups: Manage groups"
14  ansible.builtin.group:
15    name: "{{ item.name }}"
16    gid: "{{ item.gid|default(omit) }}"
17    local: "{{ item.local|default(omit) }}"
18    state: "{{ item.state|default(omit) }}"
19    system: "{{ item.system|default(omit) }}"
20  loop: "{{ fp_groups_conf }}"
21  tags: fp_groups_conf
22
23# EOF
24...

groupwrappers.yml

Synopsis: Configure groupwrappers.

Description of the task.

[tasks/groupwrappers.yml]

 1---
 2
 3# Ansible module users needs utilities groupadd, groupdel, groupmod. There are
 4# no such utililities in BSD. Let us create them.
 5
 6- name: "groupwrappers: Create directory for wrappers {{ fp_groupwrappers_dir }}"
 7  ansible.builtin.file:
 8    state: directory
 9    path: "{{ fp_groupwrappers_dir }}"
10    mode: "{{ fp_groupwrappers_dir_mode }}"
11    owner: "{{ fp_groupwrappers_owner }}"
12    group: "{{ fp_groupwrappers_group }}"
13  tags: fp_groupwrappers_dir
14
15- name: "groupwrappers: Create groupadd wrapper in {{ fp_groupwrappers_dir }}"
16  ansible.builtin.template:
17    src: "groupadd.j2"
18    dest: "{{ fp_groupwrappers_dir }}/groupadd"
19    owner: "{{ fp_groupwrappers_owner }}"
20    group: "{{ fp_groupwrappers_group }}"
21    mode: "{{ fp_groupwrappers_mode }}"
22    backup: "{{ fp_backup }}"
23  tags: fp_groupwrappers_groupadd
24
25- name: "groupwrappers: Create groupdel wrapper in {{ fp_groupwrappers_dir }}"
26  ansible.builtin.template:
27    src: "groupdel.j2"
28    dest: "{{ fp_groupwrappers_dir }}/groupdel"
29    owner: "{{ fp_groupwrappers_owner }}"
30    group: "{{ fp_groupwrappers_group }}"
31    mode: "{{ fp_groupwrappers_mode }}"
32    backup: "{{ fp_backup }}"
33  tags: fp_groupwrappers_groupdel
34
35- name: "groupwrappers: Create groupmod wrapper in {{ fp_groupwrappers_dir }}"
36  ansible.builtin.template:
37    src: "groupmod.j2"
38    dest: "{{ fp_groupwrappers_dir }}/groupmod"
39    owner: "{{ fp_groupwrappers_owner }}"
40    group: "{{ fp_groupwrappers_group }}"
41    mode: "{{ fp_groupwrappers_mode }}"
42    backup: "{{ fp_backup }}"
43  tags: fp_groupwrappers_groupmod
44
45# EOF
46...

hostapd.yml

Synopsis: Configure hostapd.

Description of the task.

[tasks/hostapd.yml]

 1---
 2
 3- name: "hostapd: Enable and start hostapd"
 4  ansible.builtin.lineinfile:
 5    dest: /etc/rc.conf
 6    regexp: '^\s*hostapd_enable\s*=(.*)$'
 7    line: 'hostapd_enable="YES"'
 8    backup: "{{ fp_backup }}"
 9  notify: enable and start hostapd
10  when: fp_hostapd_enabled|bool
11  tags: fp_hostapd_rcconf
12
13- name: "hostapd: Disable and stop hostapd"
14  ansible.builtin.lineinfile:
15    dest: /etc/rc.conf
16    regexp: '^\s*hostapd_enable\s*=(.*)$'
17    line: 'hostapd_enable="NO"'
18    backup: "{{ fp_backup }}"
19  notify: disable and stop hostapd
20  when: not fp_hostapd_enabled|bool
21  tags: fp_hostapd_rcconf
22
23- name: "hostapd: Configure interface for hostapd"
24  ansible.builtin.lineinfile:
25    dest: /etc/rc.conf
26    regexp: '^\s*{{ item.key }}\s*=(.*)$'
27    line: '{{ item.key }}="{{ item.value }}"'
28    backup: "{{ fp_backup }}"
29  loop: "{{ fp_hostapd_rcconf }}"
30  notify: restart hostapd
31  tags: fp_hostapd_rcconf
32
33- name: "hostapd: Configure {{ fp_hostapd_conf_file }}"
34  ansible.builtin.template:
35    src: "{{ fp_hostapd_conf_template }}"
36    dest: "{{ fp_hostapd_conf_file }}"
37    owner: "{{ fp_hostapd_conf_owner }}"
38    group: "{{ fp_hostapd_conf_group }}"
39    mode: "{{ fp_hostapd_conf_mode }}"
40    backup: "{{ fp_backup }}"
41  notify: restart hostapd
42  tags: fp_hostapd_conf
43
44- name: "hostapd: {{ state }} hostapd"
45  ansible.builtin.service:
46    name: hostapd
47    state: "{{ state }}"
48  vars:
49    state: "{{ fp_hostapd_enabled|bool|ternary('started', 'stopped') }}"
50
51# EOF
52...

hostname.yml

Synopsis: Configure hostname.

Description of the task.

[tasks/hostname.yml]

 1---
 2
 3- name: "hostname: Configure hostname in /etc/rc.conf"
 4  ansible.builtin.lineinfile:
 5    dest: /etc/rc.conf
 6    regexp: '^\s*{{ item.key }}\s*=(.*)$'
 7    line: '{{ item.key }}="{{ item.value }}"'
 8    backup: "{{ fp_backup }}"
 9  loop: "{{ fp_hostname_rcconf }}"
10  notify: set hostname
11
12# EOF
13...

hosts.yml

Synopsis: Configure hosts.

Description of the task.

[tasks/hosts.yml]

 1---
 2
 3- name: "hosts: Debug (fp_hosts_debug={{ fp_hosts_debug }})"
 4  vars:
 5    msg: |-
 6      fp_hosts_sanity: {{ fp_hosts_sanity }}
 7      fp_hosts_conf_file: {{ fp_hosts_conf_file }}
 8      fp_hosts_conf_template: {{ fp_hosts_conf_template }}
 9      fp_hosts_localhost_ipv4: {{ fp_hosts_localhost_ipv4 }}
10      fp_hosts_localhost_ipv6: {{ fp_hosts_localhost_ipv6 }}
11      fp_hosts_conf:
12        {{ fp_hosts_conf|to_yaml(indent=2)|indent(2) }}
13  ansible.builtin.debug:
14    msg: "{{ '{}'.format(msg) }}"
15  when: fp_hosts_debug|bool
16  tags: fp_hosts_debug
17
18- name: "Sanity"
19  block:
20    - name: "hosts: Sanity valid IP"
21      ansible.builtin.fail:
22        msg: "[ERROR] Invalid IP address"
23      when: (fp_hosts_conf|map(attribute='ip')|map('ipaddr')) is not all
24    - name: "hosts: Sanity unique FQDN"
25      ansible.builtin.fail:
26        msg: "[ERROR] FQDN not unique"
27      vars:
28        no_records: "{{ fp_hosts_conf|length }}"
29        no_hosts: "{{ fp_hosts_conf|map(attribute='fqdn')|list|unique|length }}"
30      when: no_records != no_hosts
31  when: fp_hosts_sanity|bool
32  tags: fp_hosts_sanity
33
34- name: "hosts: Configure hosts in {{ fp_hosts_conf_file }}"
35  ansible.builtin.template:
36    src: "{{ fp_hosts_conf_template }}"
37    dest: "{{ fp_hosts_conf_file }}"
38    owner: root
39    group: wheel
40    mode: "0644"
41    backup: "{{ fp_backup }}"
42  tags: fp_hosts_conf
43
44# EOF
45...

inetd.yml

Synopsis: Configure inetd.

Description of the task.

[tasks/inetd.yml]

  1---
  2
  3- name: "inetd: Debug"
  4  vars:
  5    msg: |-
  6      fp_inetd_enabled: {{ fp_inetd_enabled }}
  7      fp_inetd_rcconf:
  8        {{ fp_inetd_rcconf|to_nice_yaml(indent=2)|indent(2) }}
  9      fp_inetd_conf_orig: {{ fp_inetd_conf_orig }}
 10      fp_inetd_conf:
 11        {{ fp_inetd_conf|to_nice_yaml(indent=2)|indent(2) }}
 12      fp_inetd_hosts_allow_file: {{ fp_inetd_hosts_allow_file }}
 13      fp_inetd_hosts_allow_orig: {{ fp_inetd_hosts_allow_orig }}
 14      fp_inetd_hosts_allow_template: {{ fp_inetd_hosts_allow_template }}
 15      fp_inetd_hosts_allow_conf:
 16        {{ fp_inetd_hosts_allow_conf|to_yaml(indent=2)|indent(2) }}
 17      fp_inetd_syslogd_confd:
 18        {{ fp_inetd_syslogd_confd|to_nice_yaml(indent=2)|indent(2) }}
 19      fp_inetd_syslogd_newconfd:
 20        {{ fp_inetd_syslogd_newconfd|to_nice_yaml(indent=2)|indent(2) }}
 21  ansible.builtin.debug:
 22    msg: "{{ '{}'.format(msg) }}"
 23  when: fp_inetd_debug|bool
 24  tags: fp_inetd_debug
 25
 26# rc.conf
 27- name: "inetd: Configure /etc/rc.conf"
 28  ansible.builtin.lineinfile:
 29    dest: /etc/rc.conf
 30    regexp: '^\s*{{ item.key }}\s*=(.*)$'
 31    line: '{{ item.key }}="{{ item.value }}"'
 32    backup: "{{ fp_backup }}"
 33  loop: "{{ fp_inetd_rcconf }}"
 34  notify: restart inetd
 35  tags: fp_inetd_rcconf
 36
 37- name: "inetd: Enable and start inetd"
 38  ansible.builtin.lineinfile:
 39    dest: /etc/rc.conf
 40    regexp: '^\s*inetd_enable\s*=(.*)$'
 41    line: 'inetd_enable="YES"'
 42    backup: "{{ fp_backup }}"
 43  when: fp_inetd_enabled|bool
 44  notify: enable and start inetd
 45  tags: fp_inetd_rcconf
 46
 47- name: "inetd: Disable and stop inetd"
 48  ansible.builtin.lineinfile:
 49    dest: /etc/rc.conf
 50    regexp: '^\s*inetd_enable\s*=(.*)$'
 51    line: 'inetd_enable="NO"'
 52    backup: "{{ fp_backup }}"
 53  when: not fp_inetd_enabled|bool
 54  notify: disable and stop inetd
 55  tags: fp_inetd_rcconf
 56
 57# logfile
 58- name: "inetd: Create logfile {{ fp_inetd_logfile }}"
 59  ansible.builtin.file:
 60    state: touch
 61    access_time: preserve
 62    modification_time: preserve
 63    path: "{{ fp_inetd_logfile }}"
 64    owner: root
 65    group: wheel
 66    mode: '0644'
 67  when: fp_inetd_logfile|length > 0
 68  tags: fp_inetd_logfile
 69
 70- name: "inetd: Create files in /etc/syslog.d/"
 71  ansible.builtin.template:
 72    src: "{{ item.template }}"
 73    dest: "/etc/syslog.d/{{ item.path }}"
 74    owner: root
 75    group: wheel
 76    mode: '0644'
 77    backup: "{{ fp_backup }}"
 78  loop: "{{ fp_inetd_syslogd_confd }}"
 79  loop_control:
 80    label: "{{ item.path }}"
 81  vars:
 82    fp_syslogd_conf: "{{ item.conf }}"
 83  notify: reload syslogd
 84  tags: fp_inetd_syslogd
 85
 86- name: "inetd: Create files in /etc/newsyslog.conf.d/"
 87  ansible.builtin.template:
 88    src: "{{ item.template }}"
 89    dest: "/etc/newsyslog.conf.d/{{ item.path }}"
 90    owner: root
 91    group: wheel
 92    mode: '0644'
 93    backup: "{{ fp_backup }}"
 94  loop: "{{ fp_inetd_syslogd_newconfd }}"
 95  loop_control:
 96    label: "{{ item.path }}"
 97  vars:
 98    fp_syslogd_newconf: "{{ item.conf }}"
 99  notify: create newsyslog
100  tags: fp_inetd_syslogd_newconfd
101
102# inetd.conf
103- name: "inetd: Backup origin /etc/inetd.conf"
104  ansible.builtin.command:
105    cmd: "cp /etc/inetd.conf /etc/inetd.conf.orig"
106    creates: /etc/inetd.conf.orig
107  when: fp_inetd_conf_orig|bool
108  tags: fp_inetd_conf_orig
109
110# TODO:
111# - name: "inetd: Configure /etc/inetd.conf"
112#   ansible.builtin.template:
113#     src: inetd.conf.j2
114#     dest: /etc/inetd.conf
115#     owner: root
116#     group: wheel
117#     mode: '0644'
118#     backup: "{{ fp_backup }}"
119#   notify: reload inetd
120#   when: fp_inetd_conf|length > 0
121#   tags: fp_inetd_conf
122
123# hosts.allow
124- name: "inetd: Backup origin {{ fp_inetd_hosts_allow_file }}"
125  ansible.builtin.command:
126    cmd: "cp {{ fp_inetd_hosts_allow_file }} {{ fp_inetd_hosts_allow_file }}.orig"
127    creates: "{{ fp_inetd_hosts_allow_file }}.orig"
128  when: fp_inetd_hosts_allow_orig|bool
129  tags: fp_inetd_hosts_allow_orig
130
131- name: "inetd: Configure {{ fp_inetd_hosts_allow_file }}"
132  ansible.builtin.template:
133    src: "{{ fp_inetd_hosts_allow_template }}"
134    dest: "{{ fp_inetd_hosts_allow_file }}"
135    owner: root
136    group: wheel
137    mode: '0644'
138    backup: "{{ fp_backup }}"
139  notify: reload inetd
140  when: fp_inetd_hosts_allow_conf|length > 0
141  tags: fp_inetd_hosts_allow
142
143# service
144- name: "inetd: {{ state }} inetd"
145  ansible.builtin.service:
146    name: inetd
147    state: "{{ state }}"
148  vars:
149    state: "{{ fp_inetd_enabled|bool|ternary('started', 'stopped') }}"
150
151# EOF
152...

libmap.yml

Synopsis: Configure libmap.

Description of the task.

[tasks/libmap.yml]

 1---
 2
 3- name: "libmap: Configure {{ fp_libmap_conf_file }}"
 4  ansible.builtin.lineinfile:
 5    dest: "{{ fp_libmap_conf_file }}"
 6    regexp: '^\s*{{ item.origin }}\s+(.*)$'
 7    line: "{{ item.origin }} {{ item.target }}"
 8    backup: "{{ fp_backup }}"
 9  loop: "{{ fp_libmap_entries }}"
10
11# TODO: includedir /usr/local/etc/libmap.d
12
13# EOF
14...

linux.yml

Synopsis: Configure linux.

Description of the task.

[tasks/linux.yml]

 1---
 2
 3- name: "linux: Debug (fp_linux_debug={{ fp_linux_debug }})"
 4  vars:
 5    msg: |-
 6      fp_linux_install: {{ fp_linux_install }}
 7      fp_linux_enable: {{ fp_linux_enable }}
 8      fp_linux_fstab:
 9        {{ fp_linux_fstab|to_yaml(indent=2)|indent(2) }}
10      fp_linux_lib_dir: {{ fp_linux_lib_dir }}
11      fp_linux_lib:
12        {{ fp_linux_lib|to_yaml(indent=2)|indent(2) }}
13  ansible.builtin.debug:
14    msg: "{{ '{}'.format(msg) }}"
15  when: fp_linux_debug|bool
16  tags: fp_linux_debug
17
18- name: "linux: Enable linux"
19  ansible.builtin.lineinfile:
20    dest: /etc/rc.conf
21    regexp: '^\s*linux_enable\s*=(.*)$'
22    line: 'linux_enable="YES"'
23    backup: "{{ fp_backup }}"
24  when: fp_linux_enable|bool
25  tags: fp_linux_rcconf
26
27- name: "linux: Disable linux"
28  ansible.builtin.lineinfile:
29    dest: /etc/rc.conf
30    regexp: '^\s*linux_enable\s*=(.*)$'
31    line: 'linux_enable="NO"'
32    backup: "{{ fp_backup }}"
33  when: not fp_linux_enable|bool
34  tags: fp_linux_rcconf
35
36- name: "linux: Configure fstab"
37  ansible.posix.mount:
38    name: "{{ item.name }}"
39    src: "{{ item.src }}"
40    fstype: "{{ item.fstype }}"
41    opts: "{{ item.opts }}"
42    state: mounted
43  loop: "{{ fp_linux_fstab }}"
44  tags: fp_linux_fstab
45
46- name: "linux: Create dirs for libraries"
47  ansible.builtin.file:
48    state: directory
49    path: "/compat/linux{{ item.src|dirname }}"
50    mode: "{{ item.dirmode|default('0755') }}"
51  loop: "{{ fp_linux_lib }}"
52  tags: fp_linux_lib_dir
53
54- name: "linux: Copy libraries from {{ fp_linux_lib_dir }} to /compat/linux"
55  ansible.builtin.copy:
56    src: "{{ fp_linux_lib_dir }}{{ item.src }}"
57    dest: "/compat/linux{{ item.src }}"
58    mode: preserve
59  loop: "{{ fp_linux_lib }}"
60  tags: fp_linux_lib_copy
61
62- name: "linux: Link libraries"
63  ansible.builtin.file:
64    state: link
65    src: "/compat/linux{{ item.src }}"
66    dest: "/compat/linux{{ item.link }}"
67  loop: "{{ fp_linux_lib }}"
68  tags: fp_linux_lib_link
69
70# EOF
71...

loader.yml

Synopsis: Configure loader.

Description of the task.

[tasks/loader.yml]

 1---
 2
 3- name: "loader: Debug (fp_loader_debug={{ fp_loader_debug }})"
 4  vars:
 5    msg: |-
 6      fp_loader_warning: {{ fp_loader_warning }}
 7      fp_loader_conf_template_enable: {{ fp_loader_conf_template_enable }}
 8      fp_loader_load_modules: {{ fp_loader_load_modules }}
 9      fp_loader_conf_file: {{ fp_loader_conf_file }}
10      fp_loader_conf_template: {{ fp_loader_conf_template }}
11      fp_loader_conf:
12        {{ fp_loader_conf|to_yaml(indent=2)|indent(2) }}
13      fp_loader_conf_modules:
14        {{ fp_loader_conf_modules|to_yaml(indent=2)|indent(2) }}
15      fp_sysctl_conf:
16        {{ fp_sysctl_conf|to_yaml(indent=2)|indent(2) }}
17  ansible.builtin.debug:
18    msg: "{{ '{}'.format(msg) }}"
19  when: fp_loader_debug|bool
20  tags: fp_loader_debug
21
22- name: "loader: Register sysctl variables that are settable via loader"
23  ansible.builtin.command:
24    cmd: sysctl -aNT
25  register: tmp_loader_vars
26  changed_when: false
27
28- name: "loader: Create empty list fp_sysctl_loader_conf"
29  ansible.builtin.set_fact:
30    fp_sysctl_loader_conf: []
31
32- name: "loader: [WARNING] does not report changes in check mode because of empty tmp_loader_vars"
33  ansible.builtin.debug:
34    msg: "[WARNING] Next task does not report changes in check mode because of empty tmp_loader_vars"
35  when:
36    - ansible_check_mode|bool
37    - fp_loader_warning|bool
38    - fp_loader_debug|bool
39
40- name: "loader: Add items to fp_sysctl_loader_conf"
41  ansible.builtin.set_fact:
42    fp_sysctl_loader_conf: "{{ fp_sysctl_loader_conf + [item.name ~ '=' ~ item.value, ] }}"
43  loop: "{{ fp_sysctl_conf }}"
44  when:
45    - tmp_loader_vars.stdout_lines|default([])|length > 0
46    - item.name in tmp_loader_vars.stdout_lines
47
48- name: "loader: Debug fp_sysctl_loader_conf"
49  ansible.builtin.debug:
50    var: fp_sysctl_loader_conf|to_yaml
51  when: fp_loader_debug|bool
52
53- name: "loader: [WARNING] does not report changes in check mode because of empty fp_sysctl_loader_conf"
54  ansible.builtin.debug:
55    msg: "[WARNING] Next task does not report changes in check mode because of empty fp_sysctl_loader_conf"
56  when:
57    - ansible_check_mode|bool
58    - fp_loader_warning|bool
59    - fp_loader_debug|bool
60
61- name: "loader: Configure {{ fp_loader_conf_file }} from template {{ fp_loader_conf_template }}"
62  ansible.builtin.template:
63    src: "{{ fp_loader_conf_template }}"
64    dest: "{{ fp_loader_conf_file }}"
65    owner: root
66    group: wheel
67    mode: "0644"
68    backup: "{{ fp_backup }}"
69  when:
70    - not ansible_check_mode|bool
71    - fp_loader_conf_template_enable|bool
72  notify: loader message reboot
73
74- name: "loader: Load modules"
75  ansible.builtin.shell:
76    cmd: >
77      kldstat -q -n {{ item }} || kldload -n {{ item }}
78  loop: "{{ fp_loader_conf_modules }}"
79  changed_when: false
80  when: fp_loader_load_modules|bool
81
82# EOF
83...

login.yml

Synopsis: Configure login.

Description of the task.

[tasks/login.yml]

 1---
 2
 3- name: "login: Create {{ fp_login_conf_file }}"
 4  ansible.builtin.template:
 5    src: "{{ fp_login_conf_template }}"
 6    dest: "{{ fp_login_conf_file }}"
 7    owner: root
 8    group: wheel
 9    mode: "0644"
10    backup: "{{ fp_backup }}"
11  notify: rebuild login_conf
12  when: fp_login_conf_global|bool
13
14- name: "login: Create local .login_conf"
15  ansible.builtin.template:
16    src: "{{ fp_login_conf_template_local }}"
17    dest: "/home/{{ item.user }}/.login_conf"
18    owner: "{{ item.user }}"
19    group: "{{ item.group|default(item.user) }}"
20    mode: "0644"
21    backup: "{{ fp_backup }}"
22  loop: "{{ fp_login_conf_local }}"
23  loop_control:
24    label: "{{ item.user }}"
25
26# EOF
27...

make.yml

Synopsis: Configure make.

Description of the task.

[tasks/make.yml]

 1---
 2
 3- name: "make: Debug (fp_make_debug={{ fp_make_debug }})"
 4  vars:
 5    msg: |-
 6      fp_make_conf_template: {{ fp_make_conf_template }}
 7      fp_make_conf_file: {{ fp_make_conf_file }}
 8      fp_make_conf_owner: {{ fp_make_conf_owner }}
 9      fp_make_conf_group: {{ fp_make_conf_group }}
10      fp_make_conf_mode: {{ fp_make_conf_mode }}
11      fp_make_conf:
12        {{ fp_make_conf|to_nice_yaml(indent=2)|indent(2) }}
13  ansible.builtin.debug:
14    msg: "{{ '{}'.format(msg) }}"
15  when: fp_make_debug|bool
16  tags: fp_make_debug
17
18- name: "make: Configure {{ fp_make_conf_file }}"
19  ansible.builtin.template:
20    src: "{{ fp_make_conf_template }}"
21    dest: "{{ fp_make_conf_file }}"
22    owner: "{{ fp_make_conf_owner }}"
23    group: "{{ fp_make_conf_group }}"
24    mode: "{{ fp_make_conf_mode }}"
25    backup: "{{ fp_backup }}"
26  tags: fp_make_conf
27
28# EOF
29...

motd.yml

Synopsis: Configure motd.

Description of the task.

[tasks/motd.yml]

 1---
 2
 3- name: "motd: Configure /etc/motd"
 4  ansible.builtin.template:
 5    src: "{{ fp_motd_conf_template }}"
 6    dest: "{{ fp_motd_conf_file }}"
 7    mode: "{{ fp_motd_conf_mode }}"
 8    backup: "{{ fp_backup }}"
 9  tags: fp_motd_create
10
11- name: "motd: Set update_motd YES"
12  ansible.builtin.lineinfile:
13    dest: /etc/rc.conf
14    regexp: '^\s*update_motd\s*=(.*)$'
15    line: 'update_motd="YES"'
16    backup: "{{ fp_backup }}"
17  when: fp_update_motd|bool
18  tags: fp_motd_rcconf
19
20- name: "motd: Set update_motd NO"
21  ansible.builtin.lineinfile:
22    dest: /etc/rc.conf
23    regexp: '^\s*update_motd\s*=(.*)$'
24    line: 'update_motd="NO"'
25    backup: "{{ fp_backup }}"
26  when: not fp_update_motd|bool
27  tags: fp_motd_rcconf
28
29# NOTES
30# By default system info is added to the top of /etc/motd on reboot.
31# Set fp_update_motd=False to disable this update.
32
33# EOF
34...

mount-img.yml

Synopsis: Configure mount-img.

Description of the task.

[tasks/mount-img.yml]

 1---
 2
 3- name: "mount-img: Debug (fp_mount_img_debug={{ fp_mount_img_debug }})"
 4  vars:
 5    msg: |-
 6      fp_mount_img_points_create: {{ fp_mount_img_points_create }}
 7      fp_mount_img_entries:
 8        {{ fp_mount_img_entries|to_nice_yaml(indent=2)|indent(2) }}
 9  ansible.builtin.debug:
10    msg: "{{ '{}'.format(msg) }}"
11  when: fp_mount_img_debug|bool
12  tags: fp_mount_img_debug
13
14- name: "mount-img: Set variables"
15  ansible.builtin.set_fact:
16    _fp_mount_task: img
17    _fp_mount_fstype_default: ufs
18    _fp_mount_points_create: "{{ fp_mount_img_points_create }}"
19    _fp_mount_entries: "{{ fp_mount_img_entries }}"
20    _fp_mount_debug: "{{ fp_mount_img_debug }}"
21
22- name: "mount-iso: Import mount-vnode.yml"
23  ansible.builtin.import_tasks: mount-vnode.yml
24
25# EOF
26...

mount-iso.yml

Synopsis: Configure mount-iso.

Description of the task.

[tasks/mount-iso.yml]

 1---
 2
 3- name: "mount-iso: Debug (fp_mount_iso_debug={{ fp_mount_iso_debug }})"
 4  vars:
 5    msg: |-
 6      fp_mount_iso_points_create: {{ fp_mount_iso_points_create }}
 7      fp_mount_iso_entries:
 8        {{ fp_mount_iso_entries|to_nice_yaml(indent=2)|indent(2) }}
 9  ansible.builtin.debug:
10    msg: "{{ '{}'.format(msg) }}"
11  when: fp_mount_iso_debug|bool
12  tags: fp_mount_iso_debug
13
14- name: "mount-iso: Set variables"
15  ansible.builtin.set_fact:
16    _fp_mount_task: iso
17    _fp_mount_fstype_default: cd9660
18    _fp_mount_points_create: "{{ fp_mount_iso_points_create }}"
19    _fp_mount_entries: "{{ fp_mount_iso_entries }}"
20    _fp_mount_debug: "{{ fp_mount_iso_debug }}"
21
22- name: "mount-iso: Import mount-vnode.yml"
23  ansible.builtin.import_tasks: mount-vnode.yml
24
25# EOF
26...

mount-vnode.yml

Synopsis: Configure mount-vnode.

Description of the task.

[tasks/mount-vnode.yml]

 1---
 2
 3- name: "mount-{{ _fp_mount_task }}: Debug  (fp_mount_vnode_debug={{ fp_mount_vnode_debug }})"
 4  vars:
 5    msg: |-
 6      _fp_mount_task: {{ _fp_mount_task }}
 7      _fp_mount_fstype_default: {{ _fp_mount_fstype_default }}
 8      _fp_mount_points_create: {{ _fp_mount_points_create }}
 9      _fp_mount_entries:
10        {{ _fp_mount_entries|to_nice_yaml(indent=2)|indent(2) }}
11  ansible.builtin.debug:
12    msg: "{{ '{}'.format(msg) }}"
13  when: fp_mount_vnode_debug|default(false)|bool
14
15# mounted - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
16- name: "mount-{{ _fp_mount_task }}: Create mount points"
17  ansible.builtin.file:
18    state: directory
19    path: "{{ item.mount }}"
20    mode: "{{ item.dirmode|default('0755') }}"
21  loop: "{{ fp_mount_entries }}"
22  when:
23    - _fp_mount_points_create|bool  # Note 2.
24    - item.state|default("mounted") == "mounted"
25
26- name: "mount-{{ _fp_mount_task }}: Attach memory disks"
27  ansible.builtin.include_tasks:
28    file: fn/mdconfig-attach-disk.yml
29  loop: "{{ _fp_mount_entries }}"
30  when: item.state|default("mounted") == "mounted"
31
32- name: "mount-{{ _fp_mount_task }}: Debug attach memory disks"
33  ansible.builtin.debug:
34    var: al_mdconfig_devs
35  when: _fp_mount_debug|bool
36
37# TODO: Sanity al_mdconfig_devs[_vnode] is defined; not in check-mode
38
39- name: "mount-{{ _fp_mount_task }}: Mount"
40  ansible.posix.mount:
41    src: "/dev/md{{ al_mdconfig_devs[_vnode]['unit'] }}{{ item.partition|default('') }}"
42    path: "{{ item.mount }}"  # Note 2.
43    fstype: "{{ item.fstype|default(_fp_mount_fstype_default) }}"
44    state: mounted
45    fstab: /tmp/tmp.fstab  # Note 1.
46  loop: "{{ _fp_mount_entries }}"
47  register: result
48  when:
49    - al_mdconfig_devs[_vnode] is defined
50    - item.state|default("mounted") == "mounted"
51  vars:
52    _vnode: "{{ item[_fp_mount_task] }}"
53
54- name: "mount-{{ _fp_mount_task }}: Debug mount"
55  ansible.builtin.debug:
56    var: result
57  when: _fp_mount_debug|bool
58
59# unmounted - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
60- name: "mount-{{ _fp_mount_task }}: Unmount"
61  ansible.posix.mount:
62    path: "{{ item.mount }}"  # Note 2.
63    state: unmounted
64    fstab: /tmp/tmp.fstab  # Note 1.
65  loop: "{{ _fp_mount_entries }}"
66  register: result
67  when: item.state|default("mounted") == "unmounted"
68
69- name: "mount-{{ _fp_mount_task }}: Debug unmount"
70  ansible.builtin.debug:
71    var: result
72  when: _fp_mount_debug|bool
73
74- name: "mount-{{ _fp_mount_task }}: Detach memory disks"
75  ansible.builtin.include_tasks:
76    file: fn/mdconfig-detach-disk.yml
77  loop: "{{ _fp_mount_entries }}"
78  when: item.state|default("mounted") == "unmounted"
79
80- name: "mount-{{ _fp_mount_task }}: Debug detach memory disks"
81  ansible.builtin.debug:
82    var: al_mdconfig_devs
83  when: _fp_mount_debug|bool
84
85# NOTES
86# Note 1: It's not possible to mount a device without touching fstab. Temporary fstab is a
87# workaround.
88# https://github.com/ansible-collections/ansible.posix/issues/84#issuecomment-742420345
89# Note 2: Ansible module *mount* will create/remove non-existent mountpoint
90
91# TODO: Permanent mount entry in fstab
92# state: present, absent (See ansible.posix.mount parameter *state*)
93# See /etc/rc.d/mdconfig2
94# Ex: mdconfig_md0="-t vnode -f /usr/local/data/vdisks/devltd.net"
95# https://forums.freebsd.org/threads/mounting-vnode-backed-memory-disks-at-startup.21002/
96
97# EOF
98...

nfs.yml

Synopsis: Configure NFS client.

To display variables (3) enable fp_nfs_debug=true (27). Collect status of the services (31) stored in the list fp_nfs_service_paths. The module service_facts doesn’t work in FreeBSD. Instead, use the task al_bsd_service_facts (34) from the library (33). This task doesn’t support the check mode. This task will return the dictionary al_ansible_facts_services. Display this dictionary (42). This dictionary is used to select the handlers in the dictionary fp_nfs_handlers. There is no status option of the service nfsclient. Insteda of starting the service, restart it if there are any nfs mountpoints, i.e. the file /var/db/mounttab exists. Test the existence of the file var/db/nounttab (50) and display the result fp_var_db_mounttab.stat.exists (56). This variable will be used to select the handler in the dictionary fp_nfs_handlers. Display the dictionary fp_nfsd_handlers (62). The defaults are used in check mode because of empty dictionary al_ansible_facts_services. Configure and enable (68), or disable (89) services. If the configuration of a service changes the service will be reloaded or restarted when already running.

[tasks/nfs.yml]

  1---
  2
  3- name: "nfs: Debug (fp_nfs_debug={{ fp_nfs_debug }})"
  4  vars:
  5    msg: |-
  6         fp_nfs_enable: {{ fp_nfs_enable }}
  7         fp_nfs_enable_rcconf:
  8           {{ fp_nfs_enable_rcconf|to_yaml(indent=2)|indent(2) }}
  9         fp_nfs_disable_rcconf:
 10           {{ fp_nfs_disable_rcconf|to_yaml(indent=2)|indent(2) }}
 11         fp_rpc_lockd_enable: {{ fp_rpc_lockd_enable }}
 12         fp_rpc_lockd_flags: {{ fp_rpc_lockd_flags }}
 13         fp_rpc_lockd_enable_rcconf:
 14           {{ fp_rpc_lockd_enable_rcconf|to_yaml(indent=2)|indent(2) }}
 15         fp_rpc_lockd_disable_rcconf:
 16           {{ fp_rpc_lockd_disable_rcconf|to_yaml(indent=2)|indent(2) }}
 17         fp_rpc_statd_enable: {{ fp_rpc_statd_enable }}
 18         fp_rpc_statd_flags: {{ fp_rpc_statd_flags }}
 19         fp_rpc_statd_enable_rcconf:
 20           {{ fp_rpc_statd_enable_rcconf|to_yaml(indent=2)|indent(2) }}
 21         fp_rpc_statd_disable_rcconf:
 22           {{ fp_rpc_statd_disable_rcconf|to_yaml(indent=2)|indent(2) }}
 23         fp_nfs_service_paths:
 24           {{ fp_nfs_service_paths|to_nice_yaml(indent=2)|indent(2) }}
 25  ansible.builtin.debug:
 26    msg: "{{ '{}'.format(msg) }}"
 27  when: fp_nfs_debug|bool
 28  tags: fp_nfs_debug
 29
 30# Note: The module service_facts doesn't work in FreeBSD.
 31- name: "nfs: Service state info"
 32  ansible.builtin.include_role:
 33    name: vbotka.ansible_lib
 34    tasks_from: al_bsd_service_facts
 35    apply:
 36      tags: fp_nfs_services
 37  tags: always
 38  when: not ansible_check_mode
 39  vars:
 40    al_bsd_service_paths: "{{ fp_nfs_service_paths }}"
 41
 42- name: "nfs: Debug service state info"
 43  ansible.builtin.debug:
 44    var: al_ansible_facts_services|default({})
 45  when: fp_nfs_debug|bool
 46  tags: fp_nfs_services
 47
 48# Note: There is no status option of nfsclient. If needed, restart the
 49# service when /var/db/mounttab exists.
 50- name: "nfs: Stat /var/db/mounttab"
 51  ansible.builtin.stat:
 52    path: /var/db/mounttab
 53  register: fp_var_db_mounttab
 54  tags: fp_nfs_services
 55
 56- name: "nfs: Debug stat /var/db/mounttab"
 57  ansible.builtin.debug:
 58    var: fp_var_db_mounttab.stat.exists
 59  when: fp_nfs_debug|bool
 60  tags: fp_nfs_services
 61
 62- name: "nfs: Debug handlers"
 63  ansible.builtin.debug:
 64    var: fp_nfs_handlers
 65  when: fp_nfs_debug|bool
 66  tags: fp_nfs_services
 67
 68- name: "nfs: Enable services"
 69  ansible.builtin.include_tasks:
 70    file: fn/rcconf-item.yml
 71  loop:
 72    - label: "nfs: Enable and start nfs client"
 73      conf: "{{ fp_nfs_enable_rcconf }}"
 74      when: "{{ fp_nfs_enable|bool }}"
 75      notify: "{{ fp_nfs_handlers.nfsclient }}"
 76    - label: "nfs: Enable and start lockd"
 77      conf: "{{ fp_rpc_lockd_enable_rcconf }}"
 78      when: "{{ fp_rpc_lockd_enable|bool }}"
 79      notify: "{{ fp_nfs_handlers.lockd }}"
 80    - label: "nfs: Enable and start statd"
 81      conf: "{{ fp_rpc_statd_enable_rcconf }}"
 82      when: "{{ fp_rpc_statd_enable|bool }}"
 83      notify: "{{ fp_nfs_handlers.statd }}"
 84  loop_control:
 85    loop_var: oi
 86    label: "{{ oi.label }}"
 87  tags: fp_nfs_enable
 88
 89- name: "nfsd: Disable services"
 90  ansible.builtin.include_tasks:
 91    file: fn/rcconf-item.yml
 92  loop:
 93    - label: "nfs: Disable and stop nfs client"
 94      conf: "{{ fp_nfs_disable_rcconf }}"
 95      when: "{{ not fp_nfs_enable|bool }}"
 96      notify: disable and stop nfs client
 97    - label: "nfs: Disable and stop lockd"
 98      conf: "{{ fp_rpc_lockd_disable_rcconf }}"
 99      when: "{{ not fp_rpc_lockd_enable|bool }}"
100      notify: disable and stop lockd
101    - label: "nfs: Disable and stop statd"
102      conf: "{{ fp_rpc_statd_disable_rcconf }}"
103      when: "{{ not fp_rpc_statd_enable|bool }}"
104      notify: disable and stop statd
105  loop_control:
106    loop_var: oi
107    label: "{{ oi.label }}"
108  tags: fp_nfs_disable
109
110# EOF
111...

See also

Note

  • <TBD>

Hint

  • <TBD>

Warning

  • <TBD>

nfsd.yml

Synopsis: Configure NFS server.

To display variables (3) enable fp_nfsd_debug=true (51). Collect status of the services (55) stored in the list fp_nfsd_service_paths. The module service_facts doesn’t work in FreeBSD. Instead, use the task al_bsd_service_facts (58) from the library (57). This task doesn’t support the check mode. This task will return the dictionary al_ansible_facts_services. Display this dictionary (66). This dictionary is used to select the handlers in the dictionary fp_nfsd_handlers. Display the dictionary fp_nfsd_handlers (72). The defaults are used in check mode because of empty dictionary al_ansible_facts_services. Configure /etc/exports (78) and notify handler reload mountd. Configure and enable (87), or disable (116) services. If there are any changes the service will be reloaded or restarted when already running.

[tasks/nfsd.yml]

  1---
  2
  3- name: "nfsd: Debug (fp_nfsd_debug={{ fp_nfsd_debug }})"
  4  vars:
  5    msg: |-
  6         fp_nfsd_exports:
  7           {{ fp_nfsd_exports|to_yaml(indent=2)|indent(2) }}
  8         fp_nfsd_enable: {{ fp_nfsd_enable }}
  9         fp_nfs_server_flags: {{ fp_nfs_server_flags }}
 10         fp_nfs_server_managegids: {{ fp_nfs_server_managegids }}
 11         fp_nfs_reserved_port_only: {{ fp_nfs_reserved_port_only }}
 12         fp_nfs_bufpackets: {{ fp_nfs_bufpackets }}
 13         fp_weak_mountd_authentication: {{ fp_weak_mountd_authentication }}
 14         fp_nfsv4_server_enable: {{ fp_nfsv4_server_enable }}
 15         fp_nfscbd_enable: {{ fp_nfscbd_enable }}
 16         fp_nfscbd_flags: {{ fp_nfscbd_flags }}
 17         fp_nfsuserd_enable: {{ fp_nfsuserd_enable }}
 18         fp_nfsuserd_flags: {{ fp_nfsuserd_flags }}
 19         fp_nfsd_enable_rcconf:
 20           {{ fp_nfsd_enable_rcconf|to_yaml(indent=2)|indent(2) }}
 21         fp_nfsd_disable_rcconf:
 22           {{ fp_nfsd_disable_rcconf|to_yaml(indent=2)|indent(2) }}
 23         fp_mountd_enable: {{ fp_mountd_enable }}
 24         fp_mountd_flags: {{ fp_mountd_flags }}
 25         fp_mountd_enable_rcconf:
 26           {{ fp_mountd_enable_rcconf|to_yaml(indent=2)|indent(2) }}
 27         fp_mountd_disable_rcconf:
 28           {{ fp_mountd_disable_rcconf|to_yaml(indent=2)|indent(2) }}
 29         fp_rpcbind_enable: {{ fp_rpcbind_enable }}
 30         fp_rpcbind_flags: {{ fp_rpcbind_flags }}
 31         fp_rpcbind_enable_rcconf:
 32           {{ fp_rpcbind_enable_rcconf|to_yaml(indent=2)|indent(2) }}
 33         fp_rpcbind_disable_rcconf:
 34           {{ fp_rpcbind_disable_rcconf|to_yaml(indent=2)|indent(2) }}
 35         fp_rpc_lockd_enable: {{ fp_rpc_lockd_enable }}
 36         fp_rpc_lockd_flags: {{ fp_rpc_lockd_flags }}
 37         fp_rpc_lockd_enable_rcconf:
 38           {{ fp_rpc_lockd_enable_rcconf|to_yaml(indent=2)|indent(2) }}
 39         fp_rpc_lockd_disable_rcconf:
 40           {{ fp_rpc_lockd_disable_rcconf|to_yaml(indent=2)|indent(2) }}
 41         fp_rpc_statd_enable: {{ fp_rpc_statd_enable }}
 42         fp_rpc_statd_flags: {{ fp_rpc_statd_flags }}
 43         fp_rpc_statd_enable_rcconf:
 44           {{ fp_rpc_statd_enable_rcconf|to_yaml(indent=2)|indent(2) }}
 45         fp_rpc_statd_disable_rcconf:
 46           {{ fp_rpc_statd_disable_rcconf|to_yaml(indent=2)|indent(2) }}
 47         fp_nfsd_service_paths:
 48           {{ fp_nfsd_service_paths|to_nice_yaml(indent=2)|indent(2) }}
 49  ansible.builtin.debug:
 50    msg: "{{ '{}'.format(msg) }}"
 51  when: fp_nfsd_debug|bool
 52  tags: fp_nfsd_debug
 53
 54# Note: The module service_facts doesn't work in FreeBSD.
 55- name: "nfsd: Service state info"
 56  ansible.builtin.include_role:
 57    name: vbotka.ansible_lib
 58    tasks_from: al_bsd_service_facts
 59    apply:
 60      tags: fp_nfsd_services
 61  tags: always
 62  when: not ansible_check_mode
 63  vars:
 64    al_bsd_service_paths: "{{ fp_nfsd_service_paths }}"
 65
 66- name: "nfsd: Debug service state info"
 67  ansible.builtin.debug:
 68    var: al_ansible_facts_services|default({})
 69  when: fp_nfsd_debug|bool
 70  tags: fp_nfsd_services
 71
 72- name: "nfsd: Debug handlers"
 73  ansible.builtin.debug:
 74    var: fp_nfsd_handlers
 75  when: fp_nfsd_debug|bool
 76  tags: fp_nfsd_services
 77
 78- name: "nfsd: Configure /etc/exports"
 79  ansible.builtin.template:
 80    src: exports.j2
 81    dest: /etc/exports
 82    mode: '0644'
 83    backup: "{{ fp_backup }}"
 84  notify: reload mountd
 85  tags: fp_nfsd_exports
 86
 87- name: "nfsd: Enable services"
 88  ansible.builtin.include_tasks:
 89    file: fn/rcconf-item.yml
 90  loop:
 91    - label: "nfsd: Enable and start nfs server"
 92      conf: "{{ fp_nfsd_enable_rcconf }}"
 93      when: "{{ fp_nfsd_enable|bool }}"
 94      notify: "{{ fp_nfsd_handlers.nfsd }}"
 95    - label: "nfsd: Enable and start mountd"
 96      conf: "{{ fp_mountd_enable_rcconf }}"
 97      when: "{{ fp_mountd_enable|bool }}"
 98      notify: "{{ fp_nfsd_handlers.mountd }}"
 99    - label: "nfsd: Enable and start rpcbind"
100      conf: "{{ fp_rpcbind_enable_rcconf }}"
101      when: "{{ fp_rpcbind_enable|bool }}"
102      notify: "{{ fp_nfsd_handlers.rpcbind }}"
103    - label: "nfsd: Enable and start lockd"
104      conf: "{{ fp_rpc_lockd_enable_rcconf }}"
105      when: "{{ fp_rpc_lockd_enable|bool }}"
106      notify: "{{ fp_nfsd_handlers.lockd }}"
107    - label: "nfsd: Enable and start statd"
108      conf: "{{ fp_rpc_statd_enable_rcconf }}"
109      when: "{{ fp_rpc_statd_enable|bool }}"
110      notify: "{{ fp_nfsd_handlers.statd }}"
111  loop_control:
112    loop_var: oi
113    label: "{{ oi.label }}"
114  tags: fp_nfsd_enable
115
116- name: "nfsd: Disable services"
117  ansible.builtin.include_tasks:
118    file: fn/rcconf-item.yml
119  loop:
120    - label: "nfsd: Disable and stop nfs server"
121      conf: "{{ fp_nfsd_disable_rcconf }}"
122      when: "{{ not fp_nfsd_enable|bool }}"
123      notify: disable and stop nfs server
124    - label: "nfsd: Disable and stop mountd"
125      conf: "{{ fp_mountd_disable_rcconf }}"
126      when: "{{ not fp_mountd_enable|bool }}"
127      notify: disable and stop mountd
128    - label: "nfsd: Disable and stop rpcbind"
129      conf: "{{ fp_rpcbind_disable_rcconf }}"
130      when: "{{ not fp_rpcbind_enable|bool }}"
131      notify: disable and stop rpcbind
132    - label: "nfsd: Disable and stop lockd"
133      conf: "{{ fp_rpc_lockd_disable_rcconf }}"
134      when: "{{ not fp_rpc_lockd_enable|bool }}"
135      notify: disable and stop lockd
136    - label: "nfsd: Disable and stop statd"
137      conf: "{{ fp_rpc_statd_disable_rcconf }}"
138      when: "{{ not fp_rpc_statd_enable|bool }}"
139      notify: disable and stop statd
140  loop_control:
141    loop_var: oi
142    label: "{{ oi.label }}"
143  tags: fp_nfsd_disable
144
145# EOF
146...

See also

Note

  • <TBD>

Hint

  • <TBD>

Warning

  • <TBD>

ntp.yml

Synopsis: Configure ntp.

Description of the task.

[tasks/ntp.yml]

 1---
 2
 3- name: "ntp: Enable and start ntpd"
 4  ansible.builtin.lineinfile:
 5    dest: /etc/rc.conf
 6    regexp: '^\s*ntpd_enable\s*=(.*)$'
 7    line: 'ntpd_enable="YES"'
 8    backup: "{{ fp_backup }}"
 9  when: fp_ntp_enable|bool
10  notify: enable and start ntpd
11  tags: fp_ntp_rcconf
12
13- name: "ntp: Disable and stop ntpd"
14  ansible.builtin.lineinfile:
15    dest: /etc/rc.conf
16    regexp: '^\s*ntpd_enable\s*=(.*)$'
17    line: 'ntpd_enable="NO"'
18    backup: "{{ fp_backup }}"
19  when: not fp_ntp_enable|bool
20  notify: disable and stop ntpd
21  tags: fp_ntp_rcconf
22
23- name: "ntp: Create /etc/ntp.conf from template"
24  ansible.builtin.template:
25    src: "{{ fp_ntp_conf_template }}"
26    dest: "{{ fp_ntp_conf_file }}"
27    mode: "{{ fp_ntp_conf_mode }}"
28    backup: "{{ fp_backup }}"
29  notify: restart ntpd
30  tags: fp_ntp_conf
31
32- name: "ntp: {{ state }} ntpd"
33  ansible.builtin.service:
34    name: ntpd
35    state: "{{ state }}"
36  vars:
37    state: "{{ fp_ntp_enable|bool|ternary('started', 'stopped') }}"
38
39# EOF
40...

ntpdate.yml

Synopsis: Configure ntpdate.

Description of the task.

[tasks/ntpdate.yml]

 1---
 2
 3- name: "ntpdate: Configure ntpdate in /etc/rc.conf"
 4  ansible.builtin.lineinfile:
 5    dest: /etc/rc.conf
 6    regexp: '^\s*{{ item.key }}\s*=(.*)$'
 7    line: '{{ item.key }}="{{ item.value }}"'
 8    backup: "{{ fp_backup }}"
 9  loop: "{{ fp_ntpdate_rcconf }}"
10
11- name: "ntpdate: {{ state }} ntpdate"
12  ansible.builtin.service:
13    name: ntpdate
14    state: "{{ state }}"
15  vars:
16    state: "{{ fp_ntpdate_enable|bool|ternary('started', 'stopped') }}"
17
18# EOF
19...

packages-install.yml

Synopsis: Configure packages-install.

Description of the task.

[tasks/packages-install.yml]

 1---
 2
 3- name: "packages-install: Get list of packages for {{ item.list }}"
 4  ansible.builtin.set_fact:
 5    local_pkg_list: "{{ lookup('vars', 'pkg_dict_' ~ ansible_architecture)|json_query(query) }}"
 6  vars:
 7    query: "[?pkglist=='{{ item.list }}'].packages"
 8
 9- name: "packages-install: Install packages {{ item.list }}"
10  community.general.pkgng:
11    name: "{{ local_pkg }}"
12    autoremove: "{{ fp_pkg_autoremove|default(omit) }}"
13    cached: "{{ fp_pkg_cached|default(omit) }}"
14    chroot: "{{ fp_pkg_chroot|default(omit) }}"
15    jail: "{{ fp_pkg_jail|default(omit) }}"
16    pkgsite: "{{ fp_pkg_pkgsite|default(omit) }}"
17    rootdir: "{{ fp_pkg_rootdir|default(omit) }}"
18    state: "{{ fp_pkg_state|default(omit) }}"
19  loop: "{{ local_pkg_list }}"
20  loop_control:
21    loop_var: local_pkg
22    label: "{{ local_pkg }}"
23  register: result
24  retries: "{{ freebsd_install_retries }}"
25  until: result is succeeded
26  delay: "{{ freebsd_install_delay }}"
27  when: freebsd_install_method|lower == 'packages'
28
29- name: "packages-install: Install ports {{ item.list }}"
30  community.general.portinstall:
31    name: "{{ local_pkg }}"
32    use_packages: "{{ freebsd_use_packages }}"
33  loop: "{{ local_pkg_list }}"
34  loop_control:
35    loop_var: local_pkg
36  register: result
37  retries: "{{ freebsd_install_retries }}"
38  until: result is succeeded
39  delay: "{{ freebsd_install_delay }}"
40  when: freebsd_install_method|lower == 'ports'
41
42# EOF
43...

packages.yml

Synopsis: Configure packages.

Description of the task.

[tasks/packages.yml]

 1---
 2
 3- name: "packages: Debug (fp_packages_debug={{ fp_packages_debug }})"
 4  vars:
 5    msg: |-
 6         freebsd_install_method: {{ freebsd_install_method }}
 7         freebsd_use_packages: {{ freebsd_use_packages }}
 8         freebsd_install_retries: {{ freebsd_install_retries }}
 9         freebsd_install_delay: {{ freebsd_install_delay }}
10         fp_install: {{ fp_install }}
11         fp_pkg_autoremove: {{ fp_pkg_autoremove|default('UNDEFINED') }}
12         fp_pkg_cached: {{ fp_pkg_cached|default('UNDEFINED') }}
13         fp_pkg_chroot: {{ fp_pkg_chroot|default('UNDEFINED') }}
14         fp_pkg_jail: {{ fp_pkg_jail|default('UNDEFINED') }}
15         fp_pkg_pkgsite: {{ fp_pkg_pkgsite|default('UNDEFINED') }}
16         fp_pkg_rootdir: {{ fp_pkg_rootdir|default('UNDEFINED') }}
17         fp_pkg_state: {{ fp_pkg_state|default('UNDEFINED') }}
18
19         apache_version: {{ apache_version }}
20         apache_php_version: {{ apache_php_version }}
21         bsd_bind_version: {{ bsd_bind_version }}
22         bsd_dhcp_version: {{ bsd_dhcp_version }}
23         bsd_gcc_version: {{ bsd_gcc_version }}
24         bsd_linux_version: {{ bsd_linux_version }}
25         bsd_mysql_version: {{ bsd_mysql_version }}
26         bsd_perl_version: {{ bsd_perl_version }}
27         bsd_php_version: {{ bsd_php_version }}
28         bsd_python_version: {{ bsd_python_version }}
29         bsd_ssl_version: {{ bsd_ssl_version }}
30
31         fp_links:
32           {{ fp_links|to_yaml(indent=2)|indent(2) }}
33         fp_packages: (items2dict(key_name='list', value_name='enabled'))
34           {{ fp_packages|sort(attribute='list')|
35                          items2dict(key_name='list', value_name='enabled')|
36                          to_nice_yaml(indent=2)|indent(2) }}
37         ansible_architecture: {{ ansible_architecture }}
38         pkg_dict_{{ ansible_architecture }}: (items2dict(key_name='pkglist', value_name='packages'))
39           {{ lookup('vars', 'pkg_dict_' ~ ansible_architecture)|
40              sort(attribute='pkglist')|
41              items2dict(key_name='pkglist', value_name='packages')|
42              to_yaml(indent=2)|indent(2) }}
43  ansible.builtin.debug:
44    msg: "{{ '{}'.format(msg) }}"
45  when: fp_packages_debug|bool
46  tags: fp_packages_debug
47
48- name: "packages: Install packages"
49  ansible.builtin.include_tasks: packages-install.yml
50  loop: "{{ fp_packages }}"
51  when: item.enabled
52
53# links
54- name: "packages: Create symbolic links"
55  ansible.builtin.file:
56    src: "{{ item.target }}"
57    dest: "{{ item.link }}"
58    state: link
59    force: true
60  loop: "{{ fp_links }}"
61  tags: fp_packages_links
62
63# EOF
64...

passwords.yml

Synopsis: Configure passwords.

Description of the task.

[tasks/passwords.yml]

  1---
  2
  3- name: "passwords: Debug (fp_passwords_debug={{ fp_passwords_debug }})"
  4  vars:
  5    msg: |-
  6      fp_passwords_fail_gracefully: {{ fp_passwords_fail_gracefully }}
  7      fp_passwords_update_password: {{ fp_passwords_update_password }}
  8      fp_users_conf:
  9      {% if fp_passwords_debug_classified|bool %}
 10        {{ fp_users_conf|default([])|to_nice_yaml(indent=2)|indent(2) }}
 11      {% else %}
 12      {% for user in fp_users_conf|default([]) %}
 13        - userpass: ************
 14      {% for k,v in user.items() %}
 15      {% if k not in ['userpass'] %}
 16          {{ k }}: {{ v }}
 17      {% endif %}
 18      {% endfor %}
 19      {% endfor %}
 20      {% endif %}
 21      fp_passwordstore: {{ fp_passwordstore }}
 22      fp_passwordstore_install: {{ fp_passwordstore_install }}
 23      fp_passwordstore_debug: {{ fp_passwordstore_debug }}
 24      fp_passwordstore_backup: {{ fp_passwordstore_backup }}
 25      fp_passwordstore_create: {{ fp_passwordstore_create }}
 26      fp_passwordstore_length: {{ fp_passwordstore_length }}
 27      fp_passwordstore_nosymbols: {{ fp_passwordstore_nosymbols }}
 28      fp_passwordstore_overwrite: {{ fp_passwordstore_overwrite }}
 29      fp_passwordstore_passwordstore: {{ fp_passwordstore_passwordstore }}
 30      fp_passwordstore_returnall: {{ fp_passwordstore_returnall }}
 31      fp_passwordstore_subkey: {{ fp_passwordstore_subkey }}
 32      fp_passwordstore_idempotent_password_hash: {{ fp_passwordstore_idempotent_password_hash }}
 33      fp_passwordstore_hostname_var: {{ fp_passwordstore_hostname_var }}
 34      fp_passwordstore_packages:
 35        {{ fp_passwordstore_packages|to_nice_yaml(indent=2)|indent(2) }}
 36  ansible.builtin.debug:
 37    msg: "{{ '{}'.format(msg) }}"
 38  when: fp_passwords_debug|bool
 39  tags: fp_passwords_debug
 40
 41- name: "passwords: Passwordstore"
 42  block:
 43    - name: "passwords: Passwordstore: Install packages"
 44      ansible.builtin.include_tasks:
 45        file: packages-install.yml
 46      loop:
 47        - "{{ fp_passwordstore_packages }}"
 48        - "{{ fp_gpg_packages }}"
 49        - "{{ fp_gpg_packages_extra }}"
 50      vars:
 51        my_delegate_to_localhost: true
 52      run_once: true
 53      when: fp_passwordstore_install|bool
 54    - name: "passwords: Passwordstore: Retrieve, create, or update userpass"
 55      ansible.builtin.include_role:
 56        name: vbotka.ansible_lib
 57        tasks_from: al_pws_user_host.yml
 58      vars:
 59        al_pws_debug: "{{ fp_passwordstore_debug }}"
 60        al_pws_backup: "{{ fp_passwordstore_backup }}"
 61        al_pws_create: "{{ fp_passwordstore_create }}"
 62        al_pws_length: "{{ fp_passwordstore_length }}"
 63        al_pws_nosymbols: "{{ fp_passwordstore_nosymbols }}"
 64        al_pws_overwrite: "{{ fp_passwordstore_overwrite }}"
 65        al_pws_passwordstore: "{{ fp_passwordstore_passwordstore }}"
 66        al_pws_returnall: "{{ fp_passwordstore_returnall }}"
 67        al_pws_subkey: "{{ fp_passwordstore_subkey }}"
 68        al_pws_idempotent_password_hash: "{{ fp_passwordstore_idempotent_password_hash }}"
 69        al_pws_hostname_var: "{{ fp_passwordstore_hostname_var }}"
 70        al_pws_query: "{{ fp_users_conf }}"
 71      register: result
 72    - name: "passwords: Passwordstore: Create empty list my_passwords"
 73      ansible.builtin.set_fact:
 74        my_passwords: []  # noqa no-log-password
 75    - name: "passwords: Passwordstore: Create my_passwords"
 76      ansible.builtin.set_fact:
 77        my_passwords: "{{ my_passwords +
 78                          [item|dict2items|
 79                          rejectattr('key', 'equalto', 'userpass')|
 80                          list|items2dict|
 81                          combine({'update_password': fp_passwords_update_password})] }}"
 82      loop: "{{ al_pws_query_result }}"
 83      loop_control:
 84        label: "{{ item.name }}"
 85      no_log: "{{ not fp_passwords_debug_classified }}"
 86    - name: "passwords: Passwordstore: Debug my_passwords"
 87      ansible.builtin.debug:
 88        var: my_passwords
 89      when: fp_passwords_debug_classified|bool
 90    - name: "passwords:  Passwordstore: Include users"
 91      ansible.builtin.include_tasks:
 92        file: users.yml
 93      vars:
 94        fp_users: "{{ my_passwords }}"
 95  rescue:
 96    - name: "passwords: Passwordstore: Debug fail"
 97      ansible.builtin.debug:
 98        var: result
 99      when: fp_passwords_debug_classified|bool
100    - name: "passwords: Passwordstore: Fail"
101      ansible.builtin.fail:
102        msg: "[ERROR] Passwordstore failed."
103      when: not fp_passwords_fail_gracefully|bool
104  when: fp_passwordstore|bool
105  tags: fp_passwords_passwordstore
106
107#  EOF
108...

periodic.yml

Synopsis: Configure periodic.

Description of the task.

[tasks/periodic.yml]

 1---
 2
 3- name: "periodic: Debug (fp_periodic_debug={{ fp_periodic_debug }})"
 4  vars:
 5    msg: |-
 6      fp_periodic_conf_local_file: {{ fp_periodic_conf_local_file }}
 7      fp_periodic_conf_local:
 8        {{ fp_periodic_conf_local|to_yaml(indent=2)|indent(2) }}
 9  ansible.builtin.debug:
10    msg: "{{ '{}'.format(msg) }}"
11  when: fp_periodic_debug|bool
12  tags: fp_periodic_debug
13
14- name: "periodic: Configure {{ fp_periodic_conf_local_file }}"
15  ansible.builtin.lineinfile:
16    create: true
17    mode: "0644"
18    dest: "{{ fp_periodic_conf_local_file }}"
19    regexp: '^\s*{{ item.key }}\s*=(.*)$'
20    line: '{{ item.key }}="{{ item.value }}"'
21    backup: "{{ fp_backup }}"
22  loop: "{{ fp_periodic_conf_local }}"
23  tags: fp_periodic_conf_local
24
25# NOTES
26#
27# 13.10. Monitoring Third Party Security Issues
28# https://www.freebsd.org/doc/handbook/security-pkg.html
29#
30# Not Getting Security Reports
31# https://forums.freebsd.org/threads/not-getting-security-reports.21841/
32#
33# Daily security scripts: best practice for jails?
34# https://forums.freebsd.org/threads/daily-security-scripts-best-practice-for-jails.55868/
35
36# EOF
37...

procmail.yml

Synopsis: Configure procmail.

Description of the task.

[tasks/procmail.yml]

 1---
 2
 3- name: "procmail: Remove forwarders"
 4  ansible.builtin.file:
 5    state: absent
 6    dest: "/home/{{ item.user }}/.forward"
 7  loop: "{{ fp_procmail_forwarders }}"
 8  when: fp_procmail_forwarders_rebuild|bool
 9  tags: fp_procmail_forwarders
10
11- name: "procmail: Configure forwarders"
12  ansible.builtin.blockinfile:
13    create: true
14    dest: "/home/{{ item.user }}/.forward"
15    owner: "{{ item.user }}"
16    mode: '0644'
17    marker: '# {mark} ANSIBLE MANAGED BLOCK'
18    backup: "{{ fp_backup }}"
19    block: |
20      "{{ item.forward }}"
21  loop: "{{ fp_procmail_forwarders }}"
22  tags: fp_procmail_forwarders
23
24- name: "procmail: Configure .procmailrc"
25  ansible.builtin.blockinfile:
26    create: true
27    dest: "/home/{{ item.user }}/.procmailrc"
28    owner: "{{ item.user }}"
29    mode: '0644'
30    marker: '# {mark} ANSIBLE MANAGED BLOCK'
31    backup: "{{ fp_backup }}"
32    block: |
33      SHELL={{ fp_procmail_shell }}
34      VERBOSE={{ fp_procmail_verbose }}
35      PATH={{ fp_procmail_path }}
36      MAILDIR={{ fp_procmail_maildir }}
37      DEFAULT=/var/mail/{{ item.user }}
38      PMDIR={{ fp_procmail_pmdir }}
39      LOGFILE=$PMDIR/pm.log
40      LOCKFILE=$PMDIR/.lockfile
41      SENDMAIL=/usr/sbin/sendmail
42  loop: "{{ fp_procmail_forwarders }}"
43  tags: fp_procmail_procmailrc
44
45- name: "procmail: Create .procmail directory"
46  ansible.builtin.file:
47    state: directory
48    mode: '0755'
49    path: "/home/{{ item.user }}/.procmail"
50    owner: "{{ item.user }}"
51  loop: "{{ fp_procmail_forwarders }}"
52  tags: fp_procmail_dir
53
54- name: "procmail: Create includerc files"
55  ansible.builtin.template:
56    src: "procmailrc-includerc-{{ item.template }}.j2"
57    dest: "/home/{{ item.user }}/.procmail/{{ item.template }}.rc"
58    owner: "{{ item.user }}"
59    mode: '0644'
60    backup: "{{ fp_backup }}"
61  loop: "{{ fp_procmail_includerc }}"
62  loop_control:
63    label: "{{ item.user }} {{ item.template }}"
64  tags: fp_procmail_includerc
65
66- name: "procmail: Include rc files in .procmailrc"
67  ansible.builtin.lineinfile:
68    create: true
69    dest: "/home/{{ item.user }}/.procmailrc"
70    owner: "{{ item.user }}"
71    mode: '0644'
72    line: "INCLUDERC=$PMDIR/{{ item.template }}.rc"
73    insertafter: EOF
74    backup: "{{ fp_backup }}"
75  loop: "{{ fp_procmail_includerc }}"
76  loop_control:
77    label: "{{ item.user }} {{ item.template }}"
78  tags: fp_procmail_includerc
79
80- name: "procmail: Configure {{ fp_procmail_rc_file }}"
81  ansible.builtin.template:
82    dest: "{{ fp_procmail_rc_file }}"
83    owner: root
84    mode: '0644'
85    src: procmailrc.j2
86  vars:
87    config: "{{ fp_procmail_rc_conf }}"
88  when: fp_procmail_rc_conf|length > 0
89  tags: fp_procmail_rc
90
91# EOF
92...

qemu.yml

Synopsis: Configure qemu.

Description of the task.

[tasks/qemu.yml]

 1---
 2
 3- name: "qemu: Enable and start {{ fp_qemu_rcvar }}"
 4  ansible.builtin.lineinfile:
 5    dest: /etc/rc.conf
 6    regexp: '^\s*{{ fp_qemu_rcvar }}\s*=(.*)$'
 7    line: '{{ fp_qemu_rcvar }}="YES"'
 8    backup: "{{ fp_backup }}"
 9  when: fp_qemu_enabled|bool
10  notify: enable and start qemu
11  tags: fp_qemu_rcconf
12
13- name: "qemu: Disable and stop {{ fp_qemu_rcvar }}"
14  ansible.builtin.lineinfile:
15    dest: /etc/rc.conf
16    regexp: '^\s*{{ fp_qemu_rcvar }}\s*=(.*)$'
17    line: '{{ fp_qemu_rcvar }}="NO"'
18    backup: "{{ fp_backup }}"
19  when: not fp_qemu_enabled|bool
20  notify: disable and stop qemu
21  tags: fp_qemu_rcconf
22
23- name: "qemu: {{ state }} smartd"
24  ansible.builtin.service:
25    name: "{{ fp_qemu_rcvar }}"
26    state: "{{ state }}"
27  vars:
28    state: "{{ fp_qemu_enabled|bool|ternary('started', 'stopped') }}"
29
30# EOF
31...

resolvconf.yml

Synopsis: Configure resolvconf.

Description of the task.

[tasks/resolvconf.yml]

 1---
 2
 3# resolv.conf
 4- name: "resolvconf: Absent lines in {{ fp_resolv_conf_file }}"
 5  ansible.builtin.lineinfile:
 6    create: true
 7    state: absent
 8    dest: "{{ fp_resolv_conf_file }}"
 9    owner: "{{ fp_resolv_conf_owner }}"
10    group: "{{ fp_resolv_conf_group }}"
11    mode: "{{ fp_resolv_conf_mode }}"
12    regexp: '^\s*{{ item }}\s*$'
13    backup: "{{ fp_backup }}"
14  loop: "{{ fp_resolv_conf_absent }}"
15  tags: fp_resolv_conf_absent
16
17- name: "resolvconf: Present lines in {{ fp_resolv_conf_file }}"
18  ansible.builtin.lineinfile:
19    create: true
20    dest: "{{ fp_resolv_conf_file }}"
21    owner: "{{ fp_resolv_conf_owner }}"
22    group: "{{ fp_resolv_conf_group }}"
23    mode: "{{ fp_resolv_conf_mode }}"
24    regexp: '^\s*{{ item.key }}(.*)$'
25    line: '{{ item.key }} {{ item.value }}'
26    backup: "{{ fp_backup }}"
27  loop: "{{ fp_resolv_conf }}"
28  tags: fp_resolv_conf
29
30# resolvconf.conf
31- name: "resolvconf: Absent lines in {{ fp_resolvconf_conf_file }}"
32  ansible.builtin.lineinfile:
33    create: true
34    state: absent
35    dest: "{{ fp_resolvconf_conf_file }}"
36    owner: "{{ fp_resolvconf_conf_owner }}"
37    group: "{{ fp_resolvconf_conf_group }}"
38    mode: "{{ fp_resolvconf_conf_mode }}"
39    regexp: '^\s*{{ item }}\s*$'
40    backup: "{{ fp_backup }}"
41  loop: "{{ fp_resolvconf_conf_absent }}"
42  notify: resolvconf apply
43  tags: fp_resolvconf_conf_absent
44
45- name: "resolvconf: Present lines in {{ fp_resolvconf_conf_file }}"
46  ansible.builtin.lineinfile:
47    create: true
48    dest: "{{ fp_resolvconf_conf_file }}"
49    owner: "{{ fp_resolvconf_conf_owner }}"
50    group: "{{ fp_resolvconf_conf_group }}"
51    mode: "{{ fp_resolvconf_conf_mode }}"
52    regexp: '^\s*{{ item.key }}\s*=(.*)$'
53    line: '{{ item.key }}="{{ item.value }}"'
54    backup: "{{ fp_backup }}"
55  loop: "{{ fp_resolvconf_conf }}"
56  notify: resolvconf apply
57  tags: fp_resolvconf_conf
58
59# EOF
60...

sanity.yml

Synopsis: Configure sanity.

Description of the task.

[tasks/sanity.yml]

 1---
 2
 3- name: "sanity: Debug (fp_sanity_debug={{ fp_sanity_debug }})"
 4  ansible.builtin.debug:
 5    msg: |-
 6      ansible_run_tags:
 7        {{ ansible_run_tags|to_yaml(indent=2)|indent(2) }}
 8      ansible_skip_tags:
 9        {{ ansible_skip_tags|to_yaml(indent=2)|indent(2) }}
10      fp_sanity_tags:
11        {{ fp_sanity_tags|to_yaml(indent=2)|indent(2) }}
12  when: fp_sanity_debug|bool
13  tags: fp_sanity_debug
14
15- name: "sanity: Unknown run tags"
16  ansible.builtin.fail:
17    msg: "[ERROR] Unknown run tag(s): {{ _tags_unknown }}"
18  vars:
19    _tags_unknown: "{{ ansible_run_tags|difference(fp_sanity_tags) }}"
20  when:
21    - fp_sanity_tags_fatal|bool
22    - ansible_run_tags|length > 0
23    - _tags_unknown|length > 0
24
25- name: "sanity: Unknown skip tags"
26  ansible.builtin.fail:
27    msg: "[ERROR] Unknown skip tag(s): {{ _tags_unknown }}"
28  vars:
29    _tags_unknown: "{{ ansible_skip_tags|difference(fp_sanity_tags) }}"
30  when:
31    - fp_sanity_tags_fatal|bool
32    - ansible_skip_tags|length > 0
33    - _tags_unknown|length > 0
34
35# EOF
36...

smartd.yml

Synopsis: Configure smartd.

Description of the task.

[tasks/smartd.yml]

 1---
 2
 3- name: "smartd: Enable and start smartd"
 4  ansible.builtin.lineinfile:
 5    dest: /etc/rc.conf
 6    regexp: '^\s*smartd_enable\s*=(.*)$'
 7    line: 'smartd_enable="YES"'
 8    backup: "{{ fp_backup }}"
 9  when: fp_smartd_enabled|bool
10  notify: enable and start smartd
11  tags: fp_smartd_rcconf
12
13- name: "smartd: Disable and stop smartd"
14  ansible.builtin.lineinfile:
15    dest: /etc/rc.conf
16    regexp: '^\s*smartd_enable\s*=(.*)$'
17    line: 'smartd_enable="NO"'
18    backup: "{{ fp_backup }}"
19  when: not fp_smartd_enabled|bool
20  notify: disable and stop smartd
21  tags: fp_smartd_rcconf
22
23- name: "smartd: Configure smartd.conf"
24  ansible.builtin.lineinfile:
25    dest: "{{ fp_smartd_conf_file }}"
26    regexp: '^\s*DEVICESCAN(.*)$'
27    state: absent
28    backup: "{{ fp_backup }}"
29  notify: reload smartd
30  tags: fp_smartd_conf
31
32- name: "smartd: Configure devices in {{ fp_smartd_conf_file }}"
33  ansible.builtin.lineinfile:
34    create: true
35    dest: "{{ fp_smartd_conf_file }}"
36    regexp: "{{ item.regexp }}"
37    line: "{{ item.line }}"
38    state: "{{ item.state|default(omit) }}"
39    owner: "{{ fp_smartd_conf_owner }}"
40    group: "{{ fp_smartd_conf_group }}"
41    mode: "{{ fp_smartd_conf_mode }}"
42    backup: "{{ fp_backup }}"
43  loop: "{{ fp_smartd_devices }}"
44  notify: reload smartd
45  tags: fp_smartd_conf
46
47- name: "smartd: {{ state }} smartd"
48  ansible.builtin.service:
49    name: smartd
50    state: "{{ state }}"
51  vars:
52    state: "{{ fp_smartd_enabled|bool|ternary('started', 'stopped') }}"
53
54# EOF
55...

snmpd.yml

Synopsis: Configure snmpd.

Description of the task.

[tasks/snmpd.yml]

 1---
 2
 3- name: "snmpd: Enable and start snmpd"
 4  ansible.builtin.lineinfile:
 5    dest: /etc/rc.conf
 6    regexp: '^\s*snmpd_enable\s*=(.*)$'
 7    line: 'snmpd_enable="YES"'
 8    backup: "{{ fp_backup }}"
 9  when: fp_snmpd_enabled|bool
10  notify: enable and start snmpd
11  tags: fp_snmpd_rcconf
12
13- name: "snmpd: Disable and stop snmpd"
14  ansible.builtin.lineinfile:
15    dest: /etc/rc.conf
16    regexp: '^\s*snmpd_enable\s*=(.*)$'
17    line: 'snmpd_enable="NO"'
18    backup: "{{ fp_backup }}"
19  when: not fp_snmpd_enabled|bool
20  notify: disable and stop snmpd
21  tags: fp_snmpd_rcconf
22
23- name: "snmpd: Configure /etc/rc.conf"
24  ansible.builtin.lineinfile:
25    dest: /etc/rc.conf
26    regexp: '^\s*{{ item.key }}\s*=(.*)$'
27    line: '{{ item.key }}="{{ item.value }}"'
28    backup: "{{ fp_backup }}"
29  loop: "{{ fp_snmpd_rcconf }}"
30  notify: restart snmpd
31  tags: fp_snmpd_rcconf
32
33- name: "snmpd: Copy snmpd.conf.example to snmpd.conf if not exist"
34  ansible.builtin.copy:
35    force: false
36    remote_src: true
37    src: /usr/local/share/snmp/snmpd.conf.example
38    dest: /usr/local/etc/snmpd.conf
39    owner: root
40    group: wheel
41    mode: '0644'
42  notify: restart snmpd
43  tags: fp_snmpd_conf_copy
44
45- name: "snmpd: Configure /usr/local/etc/snmpd.conf"
46  ansible.builtin.lineinfile:
47    path: /usr/local/etc/snmpd.conf
48    regexp: '^\s*{{ item.key }}\s*=(.*)$'
49    line: "{{ item.key }} {{ item.value }}"
50    state: "{{ item.state|default(omit) }}"
51    backup: "{{ fp_backup }}"
52  loop: "{{ fp_snmpd_conf }}"
53  notify: restart snmpd
54  tags: fp_snmpd_conf
55
56- name: "snmpd: {{ state }} snmpd"
57  ansible.builtin.service:
58    name: snmpd
59    state: "{{ state }}"
60  vars:
61    state: "{{ fp_snmpd_enabled|bool|ternary('started', 'stopped') }}"
62
63# EOF
64...

ssh.yml

Synopsis: Configure ssh.

Description of the task.

[tasks/ssh.yml]

 1---
 2
 3- name: "ssh: Debug (fp_ssh_debug={{ fp_ssh_debug }})"
 4  vars:
 5    msg: |-
 6      fp_ssh_conf_file: {{ fp_ssh_conf_file }}
 7      fp_ssh_conf:
 8        {{ fp_ssh_conf|to_yaml(indent=2)|indent(2) }}
 9  ansible.builtin.debug:
10    msg: "{{ '{}'.format(msg) }}"
11  when: fp_ssh_debug|bool
12  tags: fp_ssh_debug
13
14- name: "ssh: Configure {{ fp_ssh_conf_file }}"
15  ansible.builtin.template:
16    src: "{{ fp_ssh_conf_template }}"
17    dest: "{{ fp_ssh_conf_file }}"
18    owner: "{{ fp_ssh_conf_owner }}"
19    group: "{{ fp_ssh_conf_group }}"
20    mode: "{{ fp_ssh_conf_mode }}"
21    backup: "{{ fp_backup }}"
22  tags: fp_ssh_config
23
24# EOF
25...

sshd.yml

Synopsis: Configure sshd.

Description of the task.

[tasks/sshd.yml]

 1---
 2
 3- name: "sshd: Debug (fp_sshd_debug={{ fp_sshd_debug }})"
 4  vars:
 5    msg: |-
 6      fp_sshd_bin: {{ fp_sshd_bin }}
 7      fp_sshd_conf_file: {{ fp_sshd_conf_file }}
 8      fp_sshd_conf:
 9        {{ fp_sshd_conf|to_yaml(indent=2)|indent(2) }}
10  ansible.builtin.debug:
11    msg: "{{ '{}'.format(msg) }}"
12  when: fp_sshd_debug|bool
13  tags: fp_sshd_debug
14
15- name: "sshd: Enable and start sshd"
16  ansible.builtin.lineinfile:
17    dest: /etc/rc.conf
18    regexp: '^\s*sshd_enable\s*=(.*)$'
19    line: 'sshd_enable="YES"'
20    backup: "{{ fp_backup }}"
21  notify: enable and start sshd
22  when: fp_sshd_enable|bool
23  tags: fp_sshd_rcconf
24
25- name: "sshd: Disable and stop sshd"
26  ansible.builtin.lineinfile:
27    dest: /etc/rc.conf
28    regexp: '^\s*sshd_enable\s*=(.*)$'
29    line: 'sshd_enable="NO"'
30    backup: "{{ fp_backup }}"
31  notify: disable and stop sshd
32  when: not fp_sshd_enable|bool
33  tags: fp_sshd_rcconf
34
35- name: "sshd: Configure {{ fp_sshd_conf_file }}"
36  ansible.builtin.lineinfile:
37    dest: "{{ fp_sshd_conf_file }}"
38    regexp: '^\s*{{ item.key }}\s+(.*)$'
39    insertbefore: '^\s*#\s*{{ item.key }}'
40    line: "{{ item.key }} {{ item.value }}"
41    backup: "{{ fp_backup }}"
42    validate: "{{ fp_sshd_bin }} -t -f %s"
43  loop: "{{ fp_sshd_conf }}"
44  notify: reload sshd
45  tags: fp_sshd_config
46
47- name: "sshd: {{ state }} sshd"
48  ansible.builtin.service:
49    name: sshd
50    state: "{{ state }}"
51  vars:
52    state: "{{ fp_sshd_enable|bool|ternary('started', 'stopped') }}"
53
54# EOF
55...

sudoers.yml

Synopsis: Configure sudoers.

Description of the task.

[tasks/sudoers.yml]

 1---
 2
 3- name: "sudoers: Configure {{ fp_sudoers_conf_file }}"
 4  ansible.builtin.lineinfile:
 5    dest: "{{ fp_sudoers_conf_file }}"
 6    regexp: '^\s*{{ item.key }}\s+(.*)$'
 7    line: "{{ item.key }} {{ item.value }}"
 8    state: "{{ item.state|default(omit) }}"
 9    insertafter: EOF
10    owner: "{{ fp_sudoers_conf_owner }}"
11    group: "{{ fp_sudoers_conf_group }}"
12    mode: "{{ fp_sudoers_conf_mode }}"
13    backup: "{{ fp_backup }}"
14  loop: "{{ fp_sudoers_conf }}"
15
16# TODO:
17# (1) configure /usr/local/etc/sudoers.d
18# (2) configure /usr/local/etc/sudoers.dist
19
20# EOF
21...

swap.yml

Synopsis: Configure swap.

Description of the task.

[tasks/swap.yml]

 1---
 2
 3- name: "swap: Debug (fp_swap_debug={{ fp_swap_debug }})"
 4  vars:
 5    msg: |-
 6      fp_swap_enable: {{ fp_swap_enable }}
 7      fp_swap_file: {{ fp_swap_file|default('UNDEFINED') }}
 8      fp_swap_md: {{ fp_swap_md|default('UNDEFINED') }}
 9      fp_swap_size: {{ fp_swap_size|default('UNDEFINED') }}
10      fp_swap_stsize: {{ fp_swap_stsize|default('UNDEFINED') }}
11  ansible.builtin.debug:
12    msg: "{{ '{}'.format(msg) }}"
13  when: fp_swap_debug|bool
14  tags: fp_swap_debug
15
16- name: "swap: Enable swap and add entry in /etc/fstab"
17  block:
18
19    - name: "swap: Create swapfile {{ fp_swap_file }}"
20      ansible.builtin.shell:
21        cmd: >
22          sh -c
23          'if [ ! -e {{ fp_swap_file }} ]; then
24             printf "create";
25          fi'
26      register: command_result
27      changed_when: command_result.stdout|default('none') == 'create'
28      notify: create swap
29
30    - name: "swap: Create swap entry in /etc/fstab"
31      ansible.builtin.lineinfile:
32        path: /etc/fstab
33        regexp: '^\s*{{ fp_swap_md }}\s+(.*)$'
34        line: "{{ fp_swap_md }} none swap sw,file={{ fp_swap_file }},late 0 0"
35        backup: "{{ fp_backup }}"
36      notify: mount swap
37
38#   - ansible.posix.mount:
39#       name: 'none'
40#       src: "{{ fp_swap_md }}"
41#       fstype: swap
42#       opts: "sw,file={{ fp_swap_file }},late"
43#       passno: '0'
44#       dump: '0'
45#       state: mounted
46#       backup: true
47#
48# Note: ansible.posix.mount module can't mount fstype swap
49# https://github.com/ansible/ansible/pull/49390
50# https://github.com/ansible-collections/ansible.posix/issues/106
51
52    - name: "swap: Change swapfile {{ fp_swap_file }}"
53      ansible.builtin.shell:
54        cmd: >
55          sh -c
56          'if [ -e {{ fp_swap_file }} ] &&
57          [ "`stat -f %z {{ fp_swap_file }}`" -ne "{{ fp_swap_stsize }}" ]; then
58             printf "change";
59          fi'
60      register: command_result
61      changed_when: command_result.stdout|default('none') == 'change'
62      notify: change and mount swap
63  when: fp_swap_enable|bool
64
65- name: "swap: Disable swap and remove entry from /etc/fstab"
66  ansible.builtin.lineinfile:
67    path: /etc/fstab
68    regexp: '^\s*{{ fp_swap_md }}\s+(.*)$'
69    state: absent
70    backup: "{{ fp_backup }}"
71  notify: umount and delete swap
72  when:
73    - not fp_swap_enable|bool
74    - fp_swap_md is defined
75
76# EOF
77...

sysctl.yml

Synopsis: Configure sysctl.

Description of the task.

[tasks/sysctl.yml]

 1---
 2
 3- name: "sysctl: Debug (fp_sysctl_debug={{ fp_sysctl_debug }})"
 4  vars:
 5    msg: |-
 6      fp_sysctl_warning_loader_needed: {{ fp_sysctl_warning_loader_needed }}
 7      fp_sysctl_conf_file: {{ fp_sysctl_conf_file }}
 8      fp_sysctl_ignoreerrors: {{ fp_sysctl_ignoreerrors }}
 9      fp_sysctl_conf:
10        {{ fp_sysctl_conf|to_yaml(indent=2)|indent(2) }}
11  ansible.builtin.debug:
12    msg: "{{ '{}'.format(msg) }}"
13  when: fp_sysctl_debug|bool
14
15- name: "sysctl: Register sysctl variables that are settable via loader"
16  ansible.builtin.command:
17    cmd: sysctl -aNT
18  register: tmp_loader_vars
19  changed_when: false
20
21- name: "sysctl: Create empty list fp_sysctl_noloader_conf"
22  ansible.builtin.set_fact:
23    fp_sysctl_noloader_conf: []
24
25- name: "sysctl: [WARNING] Does not report changes in check mode because of empty tmp_loader_vars"
26  ansible.builtin.debug:
27    msg: "[WARNING] Next task does not report changes in check mode because of empty tmp_loader_vars"
28  when:
29    - ansible_check_mode|bool
30    - fp_sysctl_debug|bool
31
32- name: "sysctl: Add items to fp_sysctl_noloader_conf"
33  ansible.builtin.set_fact:
34    fp_sysctl_noloader_conf: "{{ fp_sysctl_noloader_conf + [item] }}"
35  loop: "{{ fp_sysctl_conf }}"
36  when:
37    - tmp_loader_vars.stdout_lines|default([])|length > 0
38    - item.name not in tmp_loader_vars.stdout_lines
39
40- name: "sysctl: Debug fp_sysctl_noloader_conf"
41  ansible.builtin.debug:
42    var: fp_sysctl_noloader_conf|to_yaml
43  when: fp_sysctl_debug|bool
44
45- name: "sysctl: [WARNING] Does not report changes in check mode because of empty fp_sysctl_noloader_conf"
46  ansible.builtin.debug:
47    msg: "[WARNING] Next task does not report changes in check mode because of empty fp_sysctl_noloader_conf"
48  when:
49    - ansible_check_mode|bool
50    - fp_sysctl_debug|bool
51
52- name: "sysctl: Configure {{ fp_sysctl_conf_file }}"
53  ansible.posix.sysctl:
54    sysctl_file: "{{ fp_sysctl_conf_file }}"
55    name: "{{ item.name }}"
56    value: "{{ item.value }}"
57    state: "{{ item.state|default(omit) }}"
58    reload: "{{ item.reload|default(omit) }}"
59    sysctl_set: "{{ item.set|default(omit) }}"
60    ignoreerrors: "{{ fp_sysctl_ignoreerrors|default(omit) }}"
61  loop: "{{ fp_sysctl_noloader_conf }}"
62
63
64- name: "sysctl: [WARNING] Tuneables present in fp_sysctl_conf but fp_loader not enabled"
65  ansible.builtin.debug:
66    msg: "[WARNING] Tuneables present in fp_sysctl_conf but fp_loader not enabled"
67  when:
68    - not ansible_check_mode|bool
69    - fp_sysctl_debug|bool
70    - fp_sysctl_warning_loader_needed|bool
71    - fp_sysctl_conf|length > fp_sysctl_noloader_conf|length
72    - not fp_loader|bool
73
74# NOTES
75# 1) As of v2.6 module sysctl 'optionally performs a /sbin/sysctl -p'
76# http://ansible-manual.readthedocs.io/en/latest/sysctl_module.html
77# 2) freebsd doesn't support -p, so reload the sysctl service
78# rc,out,err = self.module.run_command('/etc/rc.d/sysctl reload')
79# https://github.com/ansible/ansible-modules-core/blob/devel/system/sysctl.py
80# 3) See loader.yml how tuneables are settable via loader.
81# https://forums.freebsd.org/threads/reload-loader-conf.72010/
82
83# EOF
84...

syslogd.yml

Synopsis: Configure syslogd.

Description of the task.

[tasks/syslogd.yml]

  1---
  2
  3- name: "syslogd: Debug"
  4  vars:
  5    msg: |-
  6      fp_syslogd_enabled: {{ fp_syslogd_enabled }}
  7      fp_syslogd_rcconf:
  8        {{ fp_syslogd_rcconf|to_yaml(indent=2)|indent(2) }}
  9      fp_syslogd_conf_orig: {{ fp_syslogd_conf_orig }}
 10      fp_syslogd_conf:
 11        {{ fp_syslogd_conf|to_yaml(indent=2)|indent(2) }}
 12      fp_syslogd_confd:
 13        {{ fp_syslogd_confd|to_yaml(indent=2)|indent(2) }}
 14      fp_syslogd_newconf_orig: {{ fp_syslogd_newconf_orig }}
 15      fp_syslogd_newconf:
 16        {{ fp_syslogd_newconf|to_yaml(indent=2)|indent(2) }}
 17      fp_syslogd_newconfd:
 18        {{ fp_syslogd_newconfd|to_yaml(indent=2)|indent(2) }}
 19  ansible.builtin.debug:
 20    msg: "{{ '{}'.format(msg) }}"
 21  when: fp_syslogd_debug|bool
 22  tags: fp_syslogd_debug
 23
 24# rc.conf
 25- name: "syslogd: Configure /etc/rc.conf"
 26  ansible.builtin.lineinfile:
 27    dest: /etc/rc.conf
 28    regexp: '^\s*{{ item.key }}\s*=(.*)$'
 29    line: '{{ item.key }}="{{ item.value }}"'
 30    backup: "{{ fp_backup }}"
 31  loop: "{{ fp_syslogd_rcconf }}"
 32  notify: restart syslogd
 33  tags: fp_syslogd_rcconf
 34
 35- name: "syslogd: Enable and start syslogd"
 36  ansible.builtin.lineinfile:
 37    dest: /etc/rc.conf
 38    regexp: '^\s*syslogd_enable\s*=(.*)$'
 39    line: 'syslogd_enable="YES"'
 40    backup: "{{ fp_backup }}"
 41  when: fp_syslogd_enabled|bool
 42  notify: enable and start syslogd
 43  tags: fp_syslogd_rcconf
 44
 45- name: "syslogd: Disable and stop syslogd"
 46  ansible.builtin.lineinfile:
 47    dest: /etc/rc.conf
 48    regexp: '^\s*syslogd_enable\s*=(.*)$'
 49    line: 'syslogd_enable="NO"'
 50    backup: "{{ fp_backup }}"
 51  when: not fp_syslogd_enabled|bool
 52  notify: disable and stop syslogd
 53  tags: fp_syslogd_rcconf
 54
 55# syslog.conf
 56- name: "syslogd: Backup origin /etc/syslog.conf"
 57  ansible.builtin.command:
 58    cmd: "cp /etc/syslog.conf /etc/syslog.conf.orig"
 59    creates: /etc/syslog.conf.orig
 60  when: fp_syslogd_conf_orig|bool
 61  tags: fp_syslogd_conf_orig
 62
 63- name: "syslogd: Configure /etc/syslog.conf"
 64  ansible.builtin.template:
 65    src: syslog.conf.j2
 66    dest: /etc/syslog.conf
 67    owner: root
 68    group: wheel
 69    mode: '0644'
 70    backup: "{{ fp_backup }}"
 71  notify: reload syslogd
 72  when: fp_syslogd_conf|length > 0
 73  tags: fp_syslogd_conf
 74
 75- name: "syslogd: Create files in /etc/syslog.d/"
 76  ansible.builtin.template:
 77    src: "{{ item.template }}"
 78    dest: "/etc/syslog.d/{{ item.path }}"
 79    owner: root
 80    group: wheel
 81    mode: '0644'
 82    backup: "{{ fp_backup }}"
 83  loop: "{{ fp_syslogd_confd }}"
 84  loop_control:
 85    label: "{{ item.path }}"
 86  vars:
 87    fp_syslogd_conf: "{{ item.conf }}"
 88  notify: reload syslogd
 89  tags: fp_syslogd_confd
 90
 91# newsyslog.conf
 92- name: "syslogd: Backup origin /etc/newsyslog.conf"
 93  ansible.builtin.command:
 94    cmd: "cp /etc/newsyslog.conf /etc/newsyslog.conf.orig"
 95    creates: /etc/newsyslog.conf.orig
 96  when: fp_syslogd_newconf_orig|bool
 97  tags: fp_syslogd_newconf_orig
 98
 99- name: "syslogd: Configure /etc/newsyslog.conf"
100  ansible.builtin.template:
101    src: newsyslog.conf.j2
102    dest: /etc/newsyslog.conf
103    owner: root
104    group: wheel
105    mode: '0644'
106    backup: "{{ fp_backup }}"
107  notify: create newsyslog
108  when: fp_syslogd_newconf|length > 0
109  tags: fp_syslogd_newconf
110
111- name: "syslogd: Create files in /etc/newsyslog.conf.d/"
112  ansible.builtin.template:
113    src: "{{ item.template }}"
114    dest: "/etc/newsyslog.conf.d/{{ item.path }}"
115    owner: root
116    group: wheel
117    mode: '0644'
118    backup: "{{ fp_backup }}"
119  loop: "{{ fp_syslogd_newconfd }}"
120  loop_control:
121    label: "{{ item.path }}"
122  vars:
123    fp_syslogd_newconf: "{{ item.conf }}"
124  notify: create newsyslog
125  tags: fp_syslogd_newconfd
126
127# service
128- name: "syslogd: {{ state }} syslogd"
129  ansible.builtin.service:
130    name: syslogd
131    state: "{{ state }}"
132  vars:
133    state: "{{ fp_syslogd_enabled|bool|ternary('started', 'stopped') }}"
134
135# EOF
136...

timezone.yml

Synopsis: Configure timezone.

Description of the task.

[tasks/timezone.yml]

 1---
 2
 3- name: "timezone: Debug (fp_timezone_debug={{ fp_timezone_debug }})"
 4  ansible.builtin.debug:
 5    msg: |-
 6      fp_zoneinfo: {{ fp_zoneinfo }}
 7  when: fp_timezone_debug|bool
 8  tags: fp_timezone_debug
 9
10- name: "timezone: set timezone to {{ fp_zoneinfo }}"
11  community.general.timezone:
12    name: "{{ fp_zoneinfo }}"
13  notify: adjust CMOS
14
15# EOF
16...

tmpmfs.yml

Synopsis: Configure tmpmfs.

Description of the task.

[tasks/tmpmfs.yml]

 1---
 2
 3- name: "tmpmfs: Debug (fp_tmpmfs_debug={{ fp_tmpmfs_debug }})"
 4  vars:
 5    msg: |-
 6      fp_tmpmfs_rcconf:
 7        {{ fp_tmpmfs_rcconf|to_yaml(indent=2)|indent(2) }}
 8  ansible.builtin.debug:
 9    msg: "{{ '{}'.format(msg) }}"
10  when: fp_tmpmfs_debug|bool
11  tags: fp_tmpmfs_debug
12
13- name: "tmpmfs: Configure tmpmfs"
14  ansible.builtin.lineinfile:
15    dest: /etc/rc.conf
16    regexp: '^\s*{{ item.key }}\s*=(.*)$'
17    line: '{{ item.key }}="{{ item.value }}"'
18    backup: "{{ fp_backup }}"
19  loop: "{{ fp_tmpmfs_rcconf }}"
20  tags: fp_tmpmfs_rcconf
21
22# EOF
23...

users.yml

Synopsis: Configure users.

Description of the task.

[tasks/users.yml]

 1---
 2
 3- name: "users: Debug (fp_users_debug={{ fp_users_debug }})"
 4  vars:
 5    msg: |-
 6      fp_users_debug_classified: {{ fp_users_debug_classified }}
 7      fp_users_conf:
 8        {{ fp_users_conf|to_nice_yaml(indent=2)|indent(2) }}
 9  ansible.builtin.debug:
10    msg: "{{ '{}'.format(msg) }}"
11  when: fp_users_debug|bool
12  tags: fp_users_debug
13
14- name: "users: Manage user accounts"
15  ansible.builtin.user:
16    name: "{{ item.name }}"
17    append: "{{ item.append|default(omit) }}"
18    authorization: "{{ item.authorization|default(omit) }}"
19    comment: "{{ item.comment|default(omit) }}"
20    create_home: "{{ item.create_home|default(omit) }}"
21    expires: "{{ item.expires|default(omit) }}"
22    force: "{{ item.force|default(omit) }}"
23    generate_ssh_key: "{{ item.generate_ssh_key|default(omit) }}"
24    group: "{{ item.group|default(omit) }}"
25    groups: "{{ item.groups|default(omit) }}"
26    hidden: "{{ item.hidden|default(omit) }}"
27    home: "{{ item.home|default(omit) }}"
28    local: "{{ item.local|default(omit) }}"
29    login_class: "{{ item.login_class|default(omit) }}"
30    move_home: "{{ item.move_home|default(omit) }}"
31    non_unique: "{{ item.non_unique|default(omit) }}"
32    password: "{{ item.password|default(omit) }}"
33    password_lock: "{{ item.password_lock|default(omit) }}"
34    profile: "{{ item.profile|default(omit) }}"
35    remove: "{{ item.remove|default(omit) }}"
36    role: "{{ item.role|default(omit) }}"
37    seuser: "{{  item.seuser|default(omit) }}"
38    shell: "{{ item.shell|default(omit) }}"
39    skeleton: "{{ item.skeleton|default(omit) }}"
40    ssh_key_bits: "{{ item.ssh_key_bits|default(omit) }}"
41    ssh_key_comment: "{{ item.ssh_key_comment|default(omit) }}"
42    ssh_key_file: "{{ item.ssh_key_file|default(omit) }}"
43    ssh_key_passphrase: "{{ item.ssh_key_passphrase|default(omit) }}"
44    ssh_key_type: "{{ item.ssh_key_type|default(omit) }}"
45    state: "{{ item.state|default(omit) }}"
46    system: "{{ item.system|default(omit) }}"
47    uid: "{{ item.uid|default(omit) }}"
48    update_password: "{{ item.update_password|default(omit) }}"
49  loop: "{{ fp_users_conf }}"
50  loop_control:
51    label: "{{ item.name }}"
52  no_log: "{{ not fp_users_debug_classified }}"
53
54# EOF
55...

vars.yml

Synopsis: Configure vars.

Description of the task.

[tasks/vars.yml]

 1---
 2
 3- name: Get default versions
 4  block:
 5
 6    - name: "vars: Copy Makefile"
 7      ansible.builtin.copy:
 8        src: Makefile.default-versions
 9        dest: Makefile
10
11    - name: "vars: Get default versions"
12      ansible.builtin.command:
13        cmd: make default-versions
14      register: result
15      changed_when: false
16
17    - name: "vars: Create dictionary pf_default_versions"
18      ansible.builtin.set_fact:
19        pf_default_versions: "{{ result.stdout|from_yaml }}"
20
21    - name: "vars: Debug default versions (fp_vars_debug={{ fp_vars_debug }})"
22      ansible.builtin.debug:
23        var: pf_default_versions
24      when: fp_vars_debug|bool
25
26  when: fp_vars_default_versions|bool
27  tags: fp_vars_default_versions

wpasupplicant.yml

Synopsis: Configure wpasupplicant.

Description of the task.

[tasks/wpasupplicant.yml]

 1---
 2
 3- name: "wpasupplicant: Debug (fp_wpasupplicant_debug={{ fp_wpasupplicant_debug }})"
 4  vars:
 5    msg: |-
 6      fp_wpasupplicant_backup: {{ fp_wpasupplicant_backup }}
 7      fp_wpasupplicant_program: {{ fp_wpasupplicant_program }}
 8      fp_wpasupplicant_flags: {{ fp_wpasupplicant_flags }}
 9      fp_wpasupplicant_rcconf:
10        {{ fp_wpasupplicant_rcconf|to_yaml(indent=2)|indent(2) }}
11      fp_wpasupplicant_conf_rc: {{ fp_wpasupplicant_conf_rc }}
12      fp_wpasupplicant_conf_file_link: {{ fp_wpasupplicant_conf_file_link }}
13      fp_wpasupplicant_conf_owner: {{ fp_wpasupplicant_conf_owner }}
14      fp_wpasupplicant_conf_group: {{ fp_wpasupplicant_conf_group }}
15      fp_wpasupplicant_conf_mode: {{ fp_wpasupplicant_conf_mode }}
16      fp_wpasupplicant_conf_dir: {{ fp_wpasupplicant_conf_dir }}
17      fp_wpasupplicant_conf_file: {{ fp_wpasupplicant_conf_file }}
18      fp_wpasupplicant_conf_template: {{ fp_wpasupplicant_conf_template }}
19      fp_wpasupplicant_conf_ctrl_interface: {{ fp_wpasupplicant_conf_ctrl_interface }}
20      fp_wpasupplicant_conf_global:
21        {{ fp_wpasupplicant_conf_global|to_yaml(indent=2)|indent(2) }}
22      {% if fp_wpasupplicant_debug_classified %}
23      fp_wpasupplicant_conf:
24        {{ fp_wpasupplicant_conf|to_yaml(indent=2)|indent(2) }}
25      {% endif %}
26  ansible.builtin.debug:
27    msg: "{{ '{}'.format(msg) }}"
28  when: fp_wpasupplicant_debug|bool
29  tags: fp_wpasupplicant_debug
30
31- name: "wpasupplicant: Configure /etc/rc.conf"
32  ansible.builtin.lineinfile:
33    dest: /etc/rc.conf
34    regexp: '^\s*{{ item.key }}\s*=(.*)$'
35    line: '{{ item.key }}="{{ item.value }}"'
36    backup: "{{ fp_wpasupplicant_backup }}"
37  loop: "{{ fp_wpasupplicant_rcconf }}"
38  notify: restart netif
39  tags: fp_wpasupplicant_rcconf
40
41- name: "wpasupplicant: Configure {{ fp_wpasupplicant_conf_file }}.DEV"
42  ansible.builtin.template:
43    src: "{{ fp_wpasupplicant_conf_template }}"
44    dest: "{{ fp_wpasupplicant_conf_file }}.{{ item.dev }}"
45    owner: "{{ fp_wpasupplicant_conf_owner }}"
46    group: "{{ fp_wpasupplicant_conf_group }}"
47    mode: "{{ fp_wpasupplicant_conf_mode }}"
48    backup: "{{ fp_wpasupplicant_backup }}"
49  register: fp_wpa_supplicant_conf_changes
50  loop: "{{ fp_wpasupplicant_conf }}"
51  loop_control:
52    label: "{{ item.dev }}"
53  no_log: "{{ not fp_wpasupplicant_debug_classified }}"
54  tags: fp_wpasupplicant_conf
55
56- name: "wpasupplicant: Debug: registered to fp_wpa_supplicant_conf_changes"
57  ansible.builtin.debug:
58    msg: "{{ fp_wpa_supplicant_conf_changes }}"
59  no_log: "{{ not fp_wpasupplicant_debug_classified }}"
60  when: fp_wpasupplicant_debug|bool
61
62- name: "wpasupplicant: Link {{ fp_wpasupplicant_conf_file }}"
63  ansible.builtin.file:
64    state: link
65    src: "{{ fp_wpasupplicant_conf_file }}.{{ fp_wpasupplicant_conf_file_link }}"
66    dest: "{{ fp_wpasupplicant_conf_file }}"
67    force: true
68  when: fp_wpasupplicant_conf_file_link|length > 0
69  tags: fp_wpasupplicant_conf_file_link
70
71# Use device specific configuration. Example:
72# /usr/local/sbin/wpa_supplicant -s -B -i wlan1 -c /etc/wpa_supplicant.conf.wlan1
73- name: "wpasupplicant: Configure /etc/rc.d/wpa_supplicant"
74  ansible.builtin.lineinfile:
75    dest: /etc/rc.d/wpa_supplicant
76    regexp: '^\s*{{ item.key }}\s*=(.*)$'
77    line: '{{ item.key }}={{ item.value }}'
78    backup: "{{ fp_wpasupplicant_backup }}"
79  loop:
80    - {key: "conf_file", value: "${wpa_supplicant_conf_file}.${ifn}"}
81  when: fp_wpasupplicant_conf_rc|bool
82  tags: fp_wpasupplicant_conf_rc
83
84# EOF
85...

digitalocean.yml

Synopsis: Configure digitalocean.

Description of the task.

[tasks/cloud-providers/digitalocean.yml]

 1---
 2
 3- name: "digitalocean: Debug"
 4  vars:
 5    msg: |-
 6      ansible_distribution_major_version: {{ ansible_distribution_major_version }}
 7      fp_do_default_user: {{ fp_do_default_user }}
 8      fp_do_default_user_remove: {{ fp_do_default_user_remove }}
 9      fp_do_default_user_remove_home: {{ fp_do_default_user_remove_home }}
10      fp_do_rcconf_cloudinit_enable: {{ fp_do_rcconf_cloudinit_enable }}
11      fp_do_rcconf_digitaloceanpre_enable: {{ fp_do_rcconf_digitaloceanpre_enable }}
12      fp_do_rcconf_digitalocean_enable: {{ fp_do_rcconf_digitalocean_enable }}
13      fp_do_rcconf:
14        {{ fp_do_rcconf|to_yaml|indent(2) }}
15  ansible.builtin.debug:
16    msg: "{{ '{}'.format(msg) }}"
17  when: fp_do_debug|bool
18  tags: fp_do_debug
19
20- name: "digitalocean: Configure /etc/rc.conf"
21  ansible.builtin.lineinfile:
22    dest: /etc/rc.conf
23    regexp: '^\s*{{ item.key }}\s*=(.*)$'
24    line: '{{ item.key }}="{{ item.value }}"'
25    backup: "{{ fp_backup }}"
26  loop: "{{ fp_do_rcconf }}"
27  tags: fp_do_rcconf
28
29- name: "digitalocean: Remove default user"
30  ansible.builtin.user:
31    name: "{{ fp_do_default_user }}"
32    state: absent
33    remove: "{{ fp_do_default_user_remove_home }}"
34  when: fp_do_default_user_remove|bool
35  tags: fp_do_defaul_user_remove
36
37# DO overwrites hostname from rc.conf
38- name: "hostname: Configure hostname in /etc/rc.digitalocean.d/droplet.conf"
39  ansible.builtin.lineinfile:
40    dest: /etc/rc.digitalocean.d/droplet.conf
41    regexp: '^\s*{{ item.key }}\s*=(.*)$'
42    line: '{{ item.key }}="{{ item.value }}"'
43    backup: "{{ fp_backup }}"
44  loop: "{{ fp_do_legacy_rcconf }}"
45  when: ansible_distribution_major_version|int < 11
46  tags: fp_do_hostname_rcconf
47
48# EOF
49...

sync-default.yml

Synopsis: Configure sync-default.

Description of the task.

[tasks/copy/sync-default.yml]

 1---
 2# Sync default
 3
 4- name: "copy:sync-default: Debug default directory exists"
 5  ansible.builtin.debug:
 6    msg: "Directory {{ mypath }} exists: {{ mystat }}"
 7  vars:
 8    mypath: "{{ fp_copy_dir }}/{{ fp_copy_dir_default }}"
 9    mystat: "{{ mypath is exists }}"
10  when: fp_copy_debug|bool
11
12- name: "copy:sync-default: Synchronize default files {{ fp_copy_dir }}/{{ fp_copy_dir_default }}"
13  ansible.posix.synchronize:
14    src: "{{ mypath_src }}"
15    dest: "{{ item.dest }}"
16    archive: "{{ item.archive|default(fp_synchronize_archive) }}"
17    checksum: "{{ item.checksum|default(fp_synchronize_checksum) }}"
18    compress: "{{ item.compress|default(fp_synchronize_compress) }}"
19    copy_links: "{{ item.copy_links|default(fp_synchronize_copy_links) }}"
20    delete: "{{ item.delete|default(fp_synchronize_delete) }}"
21    dirs: "{{ item.dirs|default(fp_synchronize_dirs) }}"
22    existing_only: "{{ item.existing_only|default(fp_synchronize_existing_only) }}"
23    mode: "{{ item.mode|default(fp_synchronize_mode) }}"
24    group: "{{ item.group|default(omit) }}"
25    owner: "{{ item.owner|default(omit) }}"
26    perms: "{{ item.synchronize_perms|default(omit) }}"
27    times: "{{ item.synchronize_times|default(omit) }}"
28    recursive: "{{ item.recursive|default(omit) }}"
29    verify_host: "{{ item.verify_host|default(fp_synchronize_verify_host) }}"
30  register: result
31  loop: "{{ fp_synchronize_default }}"
32  loop_control:
33    label: "{{ item.dest }}"
34  vars:
35    mypath: "{{ fp_copy_dir }}/{{ fp_copy_dir_default }}/{{ item.src }}"
36  when: mypath is exists
37
38- name: "copy:sync-optional: Debug synchronize default files result"
39  ansible.builtin.debug:
40    var: result
41  when: fp_copy_debug|bool
42
43# EOF
44...

sync-optional.yml

Synopsis: Configure sync-optional.

Description of the task.

[tasks/copy/sync-optional.yml]

 1---
 2# Sync optional
 3
 4- name: "copy:sync-optional: Debug optional directory exists"
 5  ansible.builtin.debug:
 6    msg: "Directory {{ mypath }} exists: {{ mystat }}"
 7  vars:
 8    mypath: "{{ fp_copy_dir }}/{{ fp_copy_dir_optional }}"
 9    mystat: "{{ mypath is exists }}"
10  when: fp_copy_debug|bool
11
12- name: "copy:sync-optional: Synchronize optional files {{ fp_copy_dir }}/{{ fp_copy_dir_optional }}"
13  ansible.posix.synchronize:
14    src: "{{ mypath }}"
15    dest: "{{ item.dest }}"
16    archive: "{{ item.archive|default(fp_synchronize_archive) }}"
17    checksum: "{{ item.checksum|default(fp_synchronize_checksum) }}"
18    compress: "{{ item.compress|default(fp_synchronize_compress) }}"
19    copy_links: "{{ item.copy_links|default(fp_synchronize_copy_links) }}"
20    delete: "{{ item.delete|default(fp_synchronize_delete) }}"
21    dirs: "{{ item.dirs|default(fp_synchronize_dirs) }}"
22    existing_only: "{{ item.existing_only|default(fp_synchronize_existing_only) }}"
23    mode: "{{ item.mode|default(fp_synchronize_mode) }}"
24    group: "{{ item.group|default(omit) }}"
25    owner: "{{ item.owner|default(omit) }}"
26    perms: "{{ item.synchronize_perms|default(omit) }}"
27    times: "{{ item.synchronize_times|default(omit) }}"
28    recursive: "{{ item.recursive|default(omit) }}"
29    verify_host: "{{ item.verify_host|default(fp_synchronize_verify_host) }}"
30  register: result
31  loop: "{{ fp_synchronize_optional }}"
32  loop_control:
33    label: "{{ item.dest }}"
34  vars:
35    mypath: "{{ fp_copy_dir }}/{{ fp_copy_dir_optional }}/{{ item.src }}"
36  when: mypath is exists
37
38- name: "copy:sync-optional: Debug synchronize optional files result"
39  ansible.builtin.debug:
40    var: result
41  when: fp_copy_debug|bool
42
43# EOF
44...

unarch-default.yml

Synopsis: Configure unarch-default.

Description of the task.

[tasks/copy/unarch-default.yml]

 1---
 2# Unarch default
 3
 4- name: "copy:unarch-default: Debug default archive exists"
 5  ansible.builtin.debug:
 6    msg: "Archive {{ mypath }} exists: {{ mystat }}"
 7  vars:
 8    mypath: "{{ fp_copy_dir }}/{{ fp_copy_arch_default }}"
 9    mystat: "{{ mypath is exists }}"
10  when: fp_copy_debug|bool
11
12- name: "copy:unarch-default: Extract default archive {{ fp_copy_dir }}/{{ fp_copy_arch_default }}"
13  ansible.builtin.unarchive:
14    src: "{{ fp_copy_dir }}/{{ fp_copy_arch_default }}"
15    dest: "/"
16    keep_newer: "{{ fp_unarchive_keep_newer }}"
17  vars:
18    mypath: "{{ fp_copy_dir }}/{{ fp_copy_arch_default }}"
19  when: mypath is exists
20
21# EOF
22...

unarch-optional.yml

Synopsis: Configure unarch-optional.

Description of the task.

[tasks/copy/unarch-optional.yml]

 1---
 2# Unarch optional
 3
 4- name: "copy:unarch-optional: Debug optional archive exists"
 5  ansible.builtin.debug:
 6    msg: "Archive {{ mypath }} exists: {{ mystat }}"
 7  vars:
 8    mypath: "{{ fp_copy_dir }}/{{ fp_copy_arch_optional }}"
 9    mystat: "{{ mypath is exists }}"
10  when: fp_debug|bool
11
12- name: "copy:unarch-optional: Extract optional archive {{ fp_copy_dir }}/{{ fp_copy_arch_optional }}"
13  ansible.builtin.unarchive:
14    src: "{{ fp_copy_dir }}/{{ fp_copy_arch_optional }}"
15    dest: "/"
16    keep_newer: "{{ fp_unarchive_keep_newer }}"
17  vars:
18    mypath: "{{ fp_copy_dir }}/{{ fp_copy_arch_optional }}"
19  when: mypath is exists
20
21# EOF
22...

cron-rename-entry.yml

Synopsis: Configure cron-rename-entry.

Description of the task.

[tasks/fn/cron-rename-entry.yml]

 1---
 2
 3- name: "cron-rename-entry: Stat {{ fp_cron_dir }}/{{ item.user }}"
 4  ansible.builtin.stat:
 5    path: "{{ fp_cron_dir }}/{{ item.user }}"
 6  register: result
 7
 8- name: "cron-rename-entry: Rename present crontab entry"
 9  ansible.builtin.replace:
10    path: "{{ fp_cron_dir }}/{{ item.user }}"
11    regexp: '^\s*#\s*{{ item.name }}$'
12    replace: "#Ansible: {{ item.name }}"
13    backup: "{{ fp_backup }}"
14  when: result.stat.exists
15
16# EOF
17...

mdconfig-attach-disk.yml

Synopsis: Configure mdconfig-attach-disk.

Description of the task.

[tasks/fn/mdconfig-attach-disk.yml]

 1---
 2
 3- name: "mdconfig-attach-disk: Attach memory disk"
 4  ansible.builtin.include_role:
 5    name: vbotka.ansible_lib
 6    tasks_from: al_mdconfig.yml
 7  vars:
 8    al_mdconfig_file: "{{ item[_fp_mount_task] }}"
 9
10# EOF
11...

mdconfig-detach-disk.yml

Synopsis: Configure mdconfig-detach-disk.

Description of the task.

[tasks/fn/mdconfig-detach-disk.yml]

 1---
 2
 3- name: "mdconfig-detach-disk: Detach memory disk"
 4  ansible.builtin.include_role:
 5    name: vbotka.ansible_lib
 6    tasks_from: al_mdconfig.yml
 7  vars:
 8    al_mdconfig_file: "{{ item[_fp_mount_task] }}"
 9    al_mdconfig_state: absent
10
11# EOF
12...

rcconf-item.yml

Synopsis: Configure rcconf-item.

Description of the task.

[tasks/fn/rcconf-item.yml]

 1---
 2
 3- name: "{{ oi.label }}"
 4  ansible.builtin.lineinfile:
 5    dest: "{{ oi.dest|default('/etc/rc.conf') }}"
 6    regexp: '^\s*{{ item.key }}\s*=(.*)$'
 7    line: '{{ item.key }}="{{ item.value }}"'
 8    backup: "{{ fp_backup }}"
 9  loop: "{{ oi.conf }}"
10  when: oi.when
11  notify: "{{ oi.notify }}"
12
13# EOF
14...