Default variables

Default variables are stored in the directory defaults.

Most of the variables are self-explaining. There are five very important variables cl_handlers, cl_packages, cl_states, cl_services, and cl_files (27-31). These dictionaries, which comprise the configuration data of handlers, packages, services, and files, will be explained in details. By default, these dictionaries are empty.

The best practice is to provide the data either in host_vars and group_vars, or as a files in the directories cl_handlersd_dir, cl_packagesd_dir, cl_statesd_dir, cl_servicesd_dir, and cl_filesd_dir (38-42). Both methods can be applied at the same time. The variables will be assembled and combined by the tasks vars_handlers.yml, vars_packages.yml, vars_states.yml, vars_services.yml, and vars_files.yml. The assembled dictionaries, customized for each host in the play, will be stored in the host-specific files cl_packagesd, cl_statesd, cl_servicesd, and cl_filesd (61-64). The variable cl_handlers is not host-specific because the handlers will be created at the controller (localhost) only. Assembled dictionary cl_handlers will be stored in the file cl_handlersd (60). Take a look at the assembled data in the directory cl_dira (59).

By default, the base of the directories is role_path (37). The user is expected to put the configuration data to a more suitable directory, for example, to playbook_dir directory.

[defaults/main.yml]

  1---
  2# defaults for config_light
  3cl_role_version: 2.8.3
  4
  5cl_setup: true                # Import tasks/setup.yml
  6cl_install: true              # Install packages or ports
  7cl_debug: false               # Display debug output
  8cl_backup: false              # Backup files
  9cl_copyfile_delete: false     # Delete dest then copy samples and defaults
 10cl_template_delete: false     # Delete dest then create from templates
 11
 12# Sanity
 13cl_sanity: true               # Import tasks/sanity.yml
 14cl_sanity_quiet: true         # Module assert, parameter quiet
 15cl_sanity_collections: false  # Test required collections
 16cl_sanity_modules_pkg: true   # Test modules in cl_packages are supported
 17cl_sanity_yamllint: false     # Test yamllint is installed
 18
 19# Supported
 20cl_supported_linux_family: [Debian, RedHat]
 21cl_supported_modules_pkg: [apt, package, pkgng, snap, yum]
 22
 23# Required collections
 24cl_collections: [ansible.posix, community.general, vbotka.freebsd]
 25
 26# Combine assembled data with these variables
 27cl_handlers: {}
 28cl_packages: {}
 29cl_services: {}
 30cl_files: {}
 31cl_states: {}
 32
 33# Assemble data from these directories
 34# cl_dird_owner: root        # no default
 35# cl_dird_group: adm         # no default
 36cl_dird_dmode: "0775" # default very permissive, restrict if necessary
 37cl_dird: "{{ role_path }}/files"
 38cl_handlersd_dir: "{{ cl_dird }}/handlers.d"
 39cl_packagesd_dir: "{{ cl_dird }}/packages.d"
 40cl_servicesd_dir: "{{ cl_dird }}/services.d"
 41cl_filesd_dir: "{{ cl_dird }}/files.d"
 42cl_statesd_dir: "{{ cl_dird }}/states.d"
 43
 44# Lint
 45cl_yamllint: yamllint
 46cl_yamllint_rules:
 47  extends: default
 48  rules:
 49    line-length:
 50      level: warning
 51cl_assemble_validate: "{{ cl_yamllint }} -d '{{ cl_yamllint_rules | to_json }}' %s"
 52cl_handlers_validate: "{{ cl_yamllint }} -d '{{ cl_yamllint_rules | to_json }}' %s"
 53
 54# Assemble inventory_hostname data into these files
 55# cl_dira_owner: root        # no default
 56# cl_dira_group: adm         # no default
 57cl_dira_dmode: "0775" # default very permissive, restrict if necessary
 58cl_dira_fmode: "0664" # default very permissive, restrict if necessary
 59cl_dira: "{{ cl_dird }}/assemble"
 60cl_handlersd: "{{ cl_dira }}/handlersd" # localhost; not inventory_hostname specific
 61cl_packagesd: "{{ cl_dira }}/packagesd.{{ inventory_hostname }}"
 62cl_servicesd: "{{ cl_dira }}/servicesd.{{ inventory_hostname }}"
 63cl_filesd: "{{ cl_dira }}/filesd.{{ inventory_hostname }}"
 64cl_statesd: "{{ cl_dira }}/statesd.{{ inventory_hostname }}"
 65cl_assemble_regexp: ^(.*)[^~]$ # Any string but terminated by ~
 66# Delete packagesd, servicesd, filesd, and statesd before assembling
 67cl_all_delete: false # Delete packagesd, servicesd, filesd, and statesd
 68cl_packagesd_delete: false # Delete packagesd
 69cl_servicesd_delete: false # Delete servicesd
 70cl_filesd_delete: false # Delete filesd
 71cl_statesd_delete: false # Delete statesd
 72
 73# Role handlers directory
 74# cl_handlers_dir_owner: admin   # no default
 75# cl_handlers_dir_group: admin   # no default
 76# cl_handlers_dir_dmode: '0775'  # no default
 77# cl_handlers_main_mode: '0644'  # no default
 78cl_handlers_delete_all: false
 79cl_handlers_delete: false
 80cl_handlers_create: true
 81cl_handlers_dir_become: false
 82
 83# Snap
 84cl_snap_paths:
 85  - /usr/local/sbin
 86  - /usr/local/bin
 87  - /usr/sbin
 88  - /usr/bin
 89  - /sbin
 90  - /bin
 91# - /snap/bin
 92cl_snap_patterns:
 93  - snap
 94
 95# States
 96cl_states_unmount: [absent, unmounted]
 97cl_states_mount: [present, mounted, remounted]
 98cl_states_file: [absent, directory, file, hard, link, touch]
 99
100# Files
101cl_files_collections:
102  copy: ansible.builtin
103  template: ansible.builtin
104  markers: ansible.builtin
105  create-backup: ansible.builtin
106  patch: ansible.posix
107  lineinfile: ansible.builtin
108  blockinfile: ansible.builtin
109  inifile: ansible.builtin
110  ucl: vbotka.freebsd
111  sysrc: community.general
112  delete-backup: ansible.builtin
113cl_files_order: "{{ cl_files_collections |
114                    dict2items |
115                    selectattr('value', 'in', ['ansible.builtin'] + cl_collections) |
116                    map(attribute='key') }}"
117
118# OS common
119install_retries: 10
120install_delay: 5
121
122# FreeBSD
123freebsd_install_method: packages
124# freebsd_install_method: ports
125freebsd_use_packages: true
126
127# rc.conf and rc.conf.d
128cl_rcconfd: false
129cl_rcconfd_dir: /etc/rc.conf.d
130cl_rcconfd_path:
131  default: "{{ cl_rcconfd_dir }}/{{ _service }}"
132cl_rcconf_rcvar:
133  default: "{{ _service }}_enable"
134  devfs: devfs_load_rulesets
135
136# EOF

Warning

The defaults of the variables cl_dird_dmode (36), cl_dira_dmode (57) and cl_dira_fmode (58) to access the configuration data and the assembled dictionaries are very permissive. Restrict the permissions if these dictionaries might comprise classified data.