340 Role vbotka.freebsd.config_light

Use case

Use the role vbotka.freebsd.config_light to install and configure lighttpd.

Tree

shell> tree .
.
├── ansible.cfg
├── conf-light
│   ├── files.d
│   │   ├── lighttpd-index.yml
│   │   ├── lighttpd-lighttpd-annotated-conf.yml
│   │   └── lighttpd-lighttpd-conf.yml
│   ├── handlers.d
│   │   └── lighttpd-freebsd.yml
│   ├── packages.d
│   │   └── lighttpd.yml
│   ├── services.d
│   │   └── lighttpd.yml
│   └── states.d
│       └── lighttpd-server-document-root.yml
├── group_vars
│   └── all
│       ├── ansible-client.yml
│       ├── cl-common.yml
│       ├── cl-lighttpd.yml
│       └── common.yml
├── hosts
│   ├── 04_iocage.yml
│   └── 99_constructed.yml
├── host_vars
│   └── iocage_04
│       └── iocage.yml
├── iocage.ini
└── pb.yml

Synopsis

In the playbook:

Requirements

Notes

  • Jail name doesn’t work in the parameter name of the module community.general.pkgng if the jail was created by iocage. Use JID instead

    freebsd_pkgng_jail: "{{ iocage_jid }}"
    
  • The play pb.yml` runs in the jails. The inventory ``iocage.ini is needed when a task is delegated to an iocage host

    freebsd_pkgng_delegate: "{{ iocage_tags.vmm }}"
    
  • Disable use_globs

    freebsd_pkgng_use_globs: false
    

    to use the packages in the form pkg-origin

    lighttpd:
      module: pkgng
      name:
        - www/lighttpd
    
  • The playbook vbotka.freebsd.pb_iocage_update_repos.yml updates the repositories. Then, use the cached local package base instead of fetching an updated one

    freebsd_pkgng_cached: true
    
  • The directories handlers, setup, and files are group-writable

    cl_dird_group: adm
    cl_dird_dmode: "0770"
    cl_dira_group: adm
    cl_dira_dmode: "0770"
    cl_dira_fmode: "0660"
    cl_handlers_dir_group: adm
    

    The user running the plays must be a member of the group adm

    shell> > groups admin
    admin : admin adm dialout
    

    Fit the ownership and permissions in cl-common.yml to your needs.

See also

ansible.cfg

Do not display skipped hosts. See the option display_skipped_hosts

[defaults]
gathering = explicit
callback_result_format = yaml
display_skipped_hosts = false
host_key_checking = false

[connection]
pipelining = true

Inventory iocage.ini

iocage_04 ansible_host=10.1.0.29

[iocage]
iocage_04

[iocage:vars]
ansible_user=admin
ansible_become=true
ansible_python_interpreter=auto_silent

group_vars

group_vars/all/ansible-client.yml
properties:
  notes: "vmm={{ inventory_hostname }}"

swarms:
  sw_01:
    count: 3
    template: ansible_client
    properties:
      bpf: 1
      dhcp: 1
      vnet: 1
group_vars/all/cl-common.yml
cl_dird_group: adm
cl_dird_dmode: "0770"
cl_dird: "{{ playbook_dir }}/conf-light"

cl_dira_group: adm
cl_dira_dmode: "0770"
cl_dira_fmode: "0660"

cl_handlers_dir_group: adm

install_delay: "{{ freebsd_install_delay }}"
install_retries: "{{ freebsd_install_retries }}"
group_vars/all/cl-lighttpd.yml
cl_service_lighttpd_enable: true
cl_service_lighttpd_state: start

# /usr/local/etc/lighttpd/lighttpd.conf
cl_lighttpd_server_port: '80'
cl_lighttpd_server_useipv6: disable
cl_lighttpd_server_username: www
cl_lighttpd_server_groupname: www
cl_lighttpd_server_document_root: /usr/local/www/lighttpd
cl_lighttpd_lighttpdconf_dict:
  - {key: server.port, value: '"{{ cl_lighttpd_server_port }}"'}
  - {key: server.use-ipv6, value: '"{{ cl_lighttpd_server_useipv6 }}"'}
  - {key: server.username, value: '"{{ cl_lighttpd_server_username }}"'}
  - {key: server.groupname, value: '"{{ cl_lighttpd_server_groupname }}"'}
  - {key: server.document-root, value: '"{{ cl_lighttpd_server_document_root }}"'}

# /etc/rc.conf
cl_lighttpd_rcconf_lighttpd_enable: 'YES'
cl_lighttpd_rcconf_dict:
  - {key: lighttpd_enable, value: '"{{ cl_lighttpd_rcconf_lighttpd_enable }}"'}
group_vars/all/common.yml
ansible_python_interpreter: auto_silent

freebsd_install_method: packages
freebsd_install_retries: 3
freebsd_install_delay: 5

freebsd_pkgng_cached: true
freebsd_pkgng_use_globs: false
freebsd_pkgng_delegate: "{{ iocage_tags.vmm }}"
freebsd_pkgng_jail: "{{ iocage_jid }}"

host_vars

host_vars/iocage_04/iocage.yml
iocage_env:
  CRYPTOGRAPHY_OPENSSL_NO_LEGACY: 1

Create and start jails

(env) > ansible-playbook vbotka.freebsd.pb_iocage_ansible_clients.yml \
                         -i iocage.ini \
                         -t swarm \
                         -e swarm=true
PLAY [Create and start jails. Optionally stop and destroy jails.] **************

TASK [Get iocage facts] ********************************************************
ok: [iocage_04]

TASK [Create swarms] ***********************************************************
changed: [iocage_04] => (item=sw_01)

TASK [Get iocage facts] ********************************************************
ok: [iocage_04]

TASK [Start swarms] ************************************************************
changed: [iocage_04] => (item=sw_01)

PLAY RECAP *********************************************************************
iocage_04                  : ok=4    changed=2    unreachable=0    failed=0    skipped=6    rescued=0    ignored=0   

Jails at iocage_04

[iocage_04]# iocage list -l
+-----+----------+------+-------+------+-----------------+--------------------+-----+----------------+----------+
| JID |   NAME   | BOOT | STATE | TYPE |     RELEASE     |        IP4         | IP6 |    TEMPLATE    | BASEJAIL |
+=====+==========+======+=======+======+=================+====================+=====+================+==========+
| 86  | 8ff2f325 | off  | up    | jail | 15.0-RELEASE-p3 | epair0b|10.1.0.218 | -   | ansible_client | no       |
+-----+----------+------+-------+------+-----------------+--------------------+-----+----------------+----------+
| 85  | a99a6436 | off  | up    | jail | 15.0-RELEASE-p3 | epair0b|10.1.0.138 | -   | ansible_client | no       |
+-----+----------+------+-------+------+-----------------+--------------------+-----+----------------+----------+
| 87  | ba2fcc3a | off  | up    | jail | 15.0-RELEASE-p3 | epair0b|10.1.0.114 | -   | ansible_client | no       |
+-----+----------+------+-------+------+-----------------+--------------------+-----+----------------+----------+

Inventory hosts

hosts/04_iocage.yml
plugin: vbotka.freebsd.iocage
host: 10.1.0.29
user: admin
env:
  CRYPTOGRAPHY_OPENSSL_NO_LEGACY: 1
get_properties: True
hooks_results:
  - /var/db/dhclient-hook.address.epair0b
compose:
  ansible_host: (iocage_hooks.0 == '-') | ternary(iocage_ip4, iocage_hooks.0)
  iocage_tags: dict(iocage_properties.notes | regex_findall('(\w+)=([\w\-]+)'))
hosts/99_constructed.yml
plugin: ansible.builtin.constructed
groups:
    up: iocage_state == 'up'

Display inventory

(env) > ansible-inventory -i hosts -i iocage.ini --graph
@all:
  |--@ungrouped:
  |--@up:
  |  |--8ff2f325
  |  |--a99a6436
  |  |--ba2fcc3a
  |--@iocage:
  |  |--iocage_04

Update repos

ansible-playbook vbotka.freebsd.pb_iocage_update_repos.yml -i iocage.ini
PLAY [Update repos.] ***********************************************************

TASK [Get iocage list of jails.] ***********************************************
ok: [iocage_04]

TASK [Set dictionary iocage_jails] *********************************************
ok: [iocage_04]

TASK [Update repos.] ***********************************************************
ok: [iocage_04] => (item=86)
ok: [iocage_04] => (item=85)
ok: [iocage_04] => (item=87)

PLAY RECAP *********************************************************************
iocage_04                  : ok=3    changed=0    unreachable=0    failed=0    skipped=2    rescued=0    ignored=0   

Configuration conf-light

conf-light/files.d/lighttpd-index.yml
lighttpd_index:
  path: "{{ cl_lighttpd_server_document_root }}/index.html"
  owner: "{{ cl_lighttpd_server_username }}"
  group: "{{ cl_lighttpd_server_groupname }}"
  create: true
  mode: "0644"
  lines:
    - line: <html><body><h1>Lighttpd works!</h1></body></html>
conf-light/files.d/lighttpd-lighttpd-annotated-conf.yml
lighttpd_lighttpd_annotated_conf:
  path: /usr/local/etc/lighttpd/lighttpd.annotated.conf
  lines:
    - {regexp: '^\s*server.document-root\s*=.*$', state: absent}
    - {regexp: '^\s*server.username\s*=.*$', state: absent}
    - {regexp: '^\s*server.groupname\s*=.*$', state: absent}
  handlers:
    - reload lighttpd
conf-light/files.d/lighttpd-lighttpd-conf.yml
lighttpd_lighttpd_conf:
  path: /usr/local/etc/lighttpd/lighttpd.conf
  create: true
  owner: root
  group: wheel
  mode: '0644'
  assignment: ' = '
  dict: "{{ cl_lighttpd_lighttpdconf_dict }}"
  handlers:
    - reload lighttpd
conf-light/handlers.d/lighttpd-freebsd.yml
lighttpd_freebsd:

  template: handlers-auto3.yml.j2
  handlers:

    - handler: Start lighttpd
      listen: start lighttpd
      module: vbotka.freebsd.service
      params:
        - 'script: lighttpd'
        - 'command: start'

    - handler: Stop lighttpd
      listen: stop lighttpd
      module: vbotka.freebsd.service
      params:
        - 'script: lighttpd'
        - 'command: stop'

    - handler: Reload lighttpd
      listen: reload lighttpd
      module: vbotka.freebsd.service
      params:
        - 'script: lighttpd'
        - 'command: reload'
      conditions:
        - '- cl_service_lighttpd_enable | bool'

    - handler: Restart lighttpd
      listen: restart lighttpd
      module: vbotka.freebsd.service
      params:
        - 'script: lighttpd'
        - 'command: restart'
      conditions:
        - '- cl_service_lighttpd_enable | bool'

    - handler: Lighttpd check
      listen: lighttpd check
      module: ansible.builtin.command
      params:
        - 'cmd: /usr/local/sbin/lighttpd -t'
conf-light/packages.d/lighttpd.yml
lighttpd:
  module: pkgng
  name:
    - www/lighttpd
conf-light/services.d/lighttpd.yml
lighttpd:
  name: lighttpd
  state: "{{ cl_service_lighttpd_state }}"
  enabled: "{{ cl_service_lighttpd_enable }}"
conf-light/states.d/lighttpd-server-document-root.yml
lighttpd_server_document_root:
  state: directory
  path: "{{ cl_lighttpd_server_document_root }}"
  owner: "{{ cl_lighttpd_server_username }}"
  group: "{{ cl_lighttpd_server_groupname }}"
  mode: '0750'

Playbook pb.yml

- name: Test role vbotka.freebsd.config_light
  hosts: up
  gather_facts: true
  remote_user: admin
  become: true

  roles:
    - vbotka.freebsd.config_light

Playbook output - Setup

Assemble data and create handlers.

(env) > ansible-playbook pb.yml -i hosts -t cl_setup -e cl_setup=true
PLAY [Test role vbotka.freebsd.config_light] ***********************************

TASK [Gathering Facts] *********************************************************
ok: [a99a6436]
ok: [8ff2f325]
ok: [ba2fcc3a]

TASK [vbotka.freebsd.config_light : Setup: Create directories in /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light] ***
ok: [8ff2f325 -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light)
ok: [8ff2f325 -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/handlers.d)
ok: [8ff2f325 -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/packages.d)
ok: [8ff2f325 -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/services.d)
ok: [8ff2f325 -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/files.d)
ok: [8ff2f325 -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/states.d)

TASK [vbotka.freebsd.config_light : Setup: Create directory /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble] ***
ok: [8ff2f325 -> localhost]

TASK [vbotka.freebsd.config_light : Setup: Create directory /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/handlers] ***
ok: [8ff2f325 -> localhost]

TASK [vbotka.freebsd.config_light : Setup: Create handlers/main.yml] ***********
changed: [8ff2f325 -> localhost]

TASK [vbotka.freebsd.config_light : Vars-handlers: Assemble handlers to /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble/handlersd] ***
changed: [8ff2f325 -> localhost]

TASK [vbotka.freebsd.config_light : Vars-handlers: Include files from /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble/handlersd to cl_handlersd_items] ***
ok: [8ff2f325 -> localhost]

TASK [vbotka.freebsd.config_light : Vars-handlers: Combine cl_handlers with cl_handlersd_items.] ***
ok: [8ff2f325 -> localhost]

TASK [vbotka.freebsd.config_light : Setup: Create handlers listed in cl_handlers.] ***
changed: [8ff2f325 -> localhost] => (item=handlers-auto-lighttpd_freebsd.yml)

TASK [vbotka.freebsd.config_light : Setup: Include handlers in handlers/main.yml] ***
changed: [8ff2f325 -> localhost] => (item=handlers-auto-lighttpd_freebsd.yml)

TASK [vbotka.freebsd.config_light : Vars-packages: Assemble packages to /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble/packagesd.8ff2f325] ***
changed: [ba2fcc3a -> localhost]
changed: [8ff2f325 -> localhost]
changed: [a99a6436 -> localhost]

TASK [vbotka.freebsd.config_light : Vars-packages: Include files from /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble/packagesd.8ff2f325 to cl_packagesd_items] ***
ok: [8ff2f325]
ok: [a99a6436]
ok: [ba2fcc3a]

TASK [vbotka.freebsd.config_light : Vars-packages: Combine cl_packages with cl_packagesd_items.] ***
ok: [8ff2f325]
ok: [a99a6436]
ok: [ba2fcc3a]

TASK [vbotka.freebsd.config_light : Vars-states: Assemble states to /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble/statesd.8ff2f325] ***
changed: [a99a6436 -> localhost]
changed: [8ff2f325 -> localhost]
changed: [ba2fcc3a -> localhost]

TASK [vbotka.freebsd.config_light : Vars-states: Include files from /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble/statesd.8ff2f325 to cl_statesd_items] ***
ok: [8ff2f325]
ok: [a99a6436]
ok: [ba2fcc3a]

TASK [vbotka.freebsd.config_light : Vars-states: Combine cl_statess with cl_statesd_items.] ***
ok: [8ff2f325]
ok: [a99a6436]
ok: [ba2fcc3a]

TASK [vbotka.freebsd.config_light : Vars-services: Assemble services to /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble/servicesd.8ff2f325] ***
changed: [ba2fcc3a -> localhost]
changed: [a99a6436 -> localhost]
changed: [8ff2f325 -> localhost]

TASK [vbotka.freebsd.config_light : Vars-services: Include files from /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble/servicesd.8ff2f325 to cl_cervicesd_items] ***
ok: [8ff2f325]
ok: [a99a6436]
ok: [ba2fcc3a]

TASK [vbotka.freebsd.config_light : Vars-services: Combine cl_services with cl_servicesd_items.] ***
ok: [a99a6436]
ok: [8ff2f325]
ok: [ba2fcc3a]

TASK [vbotka.freebsd.config_light : Vars-files: Assemble files to /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble/filesd.8ff2f325] ***
changed: [a99a6436 -> localhost]
changed: [ba2fcc3a -> localhost]
changed: [8ff2f325 -> localhost]

TASK [vbotka.freebsd.config_light : Vars-files: Include files from /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble/filesd.8ff2f325 to cl_filesd_items] ***
ok: [a99a6436]
ok: [8ff2f325]
ok: [ba2fcc3a]

TASK [vbotka.freebsd.config_light : Vars-files: Combine cl_files with cl_filesd_items.] ***
ok: [8ff2f325]
ok: [a99a6436]
ok: [ba2fcc3a]

PLAY RECAP *********************************************************************
8ff2f325                   : ok=22   changed=8    unreachable=0    failed=0    skipped=17   rescued=0    ignored=0   
a99a6436                   : ok=13   changed=4    unreachable=0    failed=0    skipped=9    rescued=0    ignored=0   
ba2fcc3a                   : ok=13   changed=4    unreachable=0    failed=0    skipped=9    rescued=0    ignored=0   

Playbook output - Install and configure lighttpd

The inventory iocage.ini is needed to delegate the tasks ‘Manage FreeBSD packages’ from the jails to their iocage hosts.

(env) > ansible-playbook pb.yml -i hosts -i iocage.ini
PLAY [Test role vbotka.freebsd.config_light] ***********************************

TASK [Gathering Facts] *********************************************************
ok: [a99a6436]
ok: [ba2fcc3a]
ok: [8ff2f325]

TASK [vbotka.freebsd.config_light : Setup: Create directories in /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light] ***
ok: [8ff2f325 -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light)
ok: [8ff2f325 -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/handlers.d)
ok: [8ff2f325 -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/packages.d)
ok: [8ff2f325 -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/services.d)
ok: [8ff2f325 -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/files.d)
ok: [8ff2f325 -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/states.d)

TASK [vbotka.freebsd.config_light : Setup: Create directory /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble] ***
ok: [8ff2f325 -> localhost]

TASK [vbotka.freebsd.config_light : Setup: Create directory /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/handlers] ***
ok: [8ff2f325 -> localhost]

TASK [vbotka.freebsd.config_light : Setup: Create handlers/main.yml] ***********
ok: [8ff2f325 -> localhost]

TASK [vbotka.freebsd.config_light : Vars-handlers: Assemble handlers to /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble/handlersd] ***
ok: [8ff2f325 -> localhost]

TASK [vbotka.freebsd.config_light : Vars-handlers: Include files from /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble/handlersd to cl_handlersd_items] ***
ok: [8ff2f325 -> localhost]

TASK [vbotka.freebsd.config_light : Vars-handlers: Combine cl_handlers with cl_handlersd_items.] ***
ok: [8ff2f325 -> localhost]

TASK [vbotka.freebsd.config_light : Setup: Create handlers listed in cl_handlers.] ***
ok: [8ff2f325 -> localhost] => (item=handlers-auto-lighttpd_freebsd.yml)

TASK [vbotka.freebsd.config_light : Setup: Include handlers in handlers/main.yml] ***
ok: [8ff2f325 -> localhost] => (item=handlers-auto-lighttpd_freebsd.yml)

TASK [vbotka.freebsd.config_light : Vars-packages: Assemble packages to /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble/packagesd.8ff2f325] ***
ok: [a99a6436 -> localhost]
ok: [ba2fcc3a -> localhost]
ok: [8ff2f325 -> localhost]

TASK [vbotka.freebsd.config_light : Vars-packages: Include files from /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble/packagesd.8ff2f325 to cl_packagesd_items] ***
ok: [8ff2f325]
ok: [a99a6436]
ok: [ba2fcc3a]

TASK [vbotka.freebsd.config_light : Vars-packages: Combine cl_packages with cl_packagesd_items.] ***
ok: [8ff2f325]
ok: [a99a6436]
ok: [ba2fcc3a]

TASK [vbotka.freebsd.config_light : Vars-states: Assemble states to /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble/statesd.8ff2f325] ***
ok: [8ff2f325 -> localhost]
ok: [ba2fcc3a -> localhost]
ok: [a99a6436 -> localhost]

TASK [vbotka.freebsd.config_light : Vars-states: Include files from /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble/statesd.8ff2f325 to cl_statesd_items] ***
ok: [8ff2f325]
ok: [a99a6436]
ok: [ba2fcc3a]

TASK [vbotka.freebsd.config_light : Vars-states: Combine cl_statess with cl_statesd_items.] ***
ok: [8ff2f325]
ok: [a99a6436]
ok: [ba2fcc3a]

TASK [vbotka.freebsd.config_light : Vars-services: Assemble services to /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble/servicesd.8ff2f325] ***
ok: [8ff2f325 -> localhost]
ok: [a99a6436 -> localhost]
ok: [ba2fcc3a -> localhost]

TASK [vbotka.freebsd.config_light : Vars-services: Include files from /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble/servicesd.8ff2f325 to cl_cervicesd_items] ***
ok: [8ff2f325]
ok: [a99a6436]
ok: [ba2fcc3a]

TASK [vbotka.freebsd.config_light : Vars-services: Combine cl_services with cl_servicesd_items.] ***
ok: [8ff2f325]
ok: [a99a6436]
ok: [ba2fcc3a]

TASK [vbotka.freebsd.config_light : Vars-files: Assemble files to /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble/filesd.8ff2f325] ***
ok: [8ff2f325 -> localhost]
ok: [a99a6436 -> localhost]
ok: [ba2fcc3a -> localhost]

TASK [vbotka.freebsd.config_light : Vars-files: Include files from /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/340/conf-light/assemble/filesd.8ff2f325 to cl_filesd_items] ***
ok: [8ff2f325]
ok: [a99a6436]
ok: [ba2fcc3a]

TASK [vbotka.freebsd.config_light : Vars-files: Combine cl_files with cl_filesd_items.] ***
ok: [8ff2f325]
ok: [a99a6436]
ok: [ba2fcc3a]

TASK [vbotka.freebsd.config_light : Sanity: Data directories must exist.] ******
ok: [8ff2f325 -> localhost]

TASK [vbotka.freebsd.config_light : Sanity: Supported modules for packages.] ***
ok: [8ff2f325 -> localhost]

TASK [vbotka.freebsd.config_light : Packages: Select lists.] *******************
ok: [8ff2f325]
ok: [a99a6436]
ok: [ba2fcc3a]

TASK [vbotka.freebsd.config_light : Packages: Create list defaulted to module package.] ***
ok: [8ff2f325]
ok: [a99a6436]
ok: [ba2fcc3a]

TASK [vbotka.freebsd.config_light : Packages: Manage FreeBSD packages.] ********
changed: [a99a6436 -> iocage_04(10.1.0.29)] => (item=['www/lighttpd'])
changed: [8ff2f325 -> iocage_04(10.1.0.29)] => (item=['www/lighttpd'])
changed: [ba2fcc3a -> iocage_04(10.1.0.29)] => (item=['www/lighttpd'])

TASK [vbotka.freebsd.config_light : States: Apply file states.] ****************
changed: [a99a6436] => (item=/usr/local/www/lighttpd)
changed: [8ff2f325] => (item=/usr/local/www/lighttpd)
changed: [ba2fcc3a] => (item=/usr/local/www/lighttpd)

TASK [vbotka.freebsd.config_light : Files: Manage files.] **********************
included: /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/tasks/files-copy.yml for 8ff2f325, ba2fcc3a, a99a6436 => (item=copy)
included: /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/tasks/files-template.yml for 8ff2f325, ba2fcc3a, a99a6436 => (item=template)
included: /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/tasks/files-markers.yml for 8ff2f325, ba2fcc3a, a99a6436 => (item=markers)
included: /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/tasks/files-create-backup.yml for 8ff2f325, ba2fcc3a, a99a6436 => (item=create-backup)
included: /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/tasks/files-patch.yml for 8ff2f325, ba2fcc3a, a99a6436 => (item=patch)
included: /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/tasks/files-lineinfile.yml for 8ff2f325, ba2fcc3a, a99a6436 => (item=lineinfile)
included: /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/tasks/files-blockinfile.yml for 8ff2f325, ba2fcc3a, a99a6436 => (item=blockinfile)
included: /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/tasks/files-inifile.yml for 8ff2f325, ba2fcc3a, a99a6436 => (item=inifile)
included: /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/tasks/files-ucl.yml for 8ff2f325, ba2fcc3a, a99a6436 => (item=ucl)
included: /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/tasks/files-sysrc.yml for 8ff2f325, ba2fcc3a, a99a6436 => (item=sysrc)
included: /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/tasks/files-delete-backup.yml for 8ff2f325, ba2fcc3a, a99a6436 => (item=delete-backup)

TASK [vbotka.freebsd.config_light : File-create-backup: Create time-stamp.] ****
ok: [8ff2f325]
ok: [a99a6436]
ok: [ba2fcc3a]

TASK [vbotka.freebsd.config_light : File-create-backup: Stat cl_files.] ********
ok: [a99a6436] => (item=/usr/local/www/lighttpd/index.html)
ok: [8ff2f325] => (item=/usr/local/www/lighttpd/index.html)
ok: [ba2fcc3a] => (item=/usr/local/www/lighttpd/index.html)
ok: [a99a6436] => (item=/usr/local/etc/lighttpd/lighttpd.annotated.conf)
ok: [8ff2f325] => (item=/usr/local/etc/lighttpd/lighttpd.annotated.conf)
ok: [ba2fcc3a] => (item=/usr/local/etc/lighttpd/lighttpd.annotated.conf)
ok: [a99a6436] => (item=/usr/local/etc/lighttpd/lighttpd.conf)
ok: [8ff2f325] => (item=/usr/local/etc/lighttpd/lighttpd.conf)
ok: [ba2fcc3a] => (item=/usr/local/etc/lighttpd/lighttpd.conf)

TASK [vbotka.freebsd.config_light : File-create-backup: Create backup files.] ***
ok: [8ff2f325] => (item=/usr/local/etc/lighttpd/lighttpd.annotated.conf)
ok: [ba2fcc3a] => (item=/usr/local/etc/lighttpd/lighttpd.annotated.conf)
ok: [a99a6436] => (item=/usr/local/etc/lighttpd/lighttpd.annotated.conf)
ok: [8ff2f325] => (item=/usr/local/etc/lighttpd/lighttpd.conf)
ok: [ba2fcc3a] => (item=/usr/local/etc/lighttpd/lighttpd.conf)
ok: [a99a6436] => (item=/usr/local/etc/lighttpd/lighttpd.conf)

TASK [vbotka.freebsd.config_light : Files-lineinfile: Lineinfile lines.] *******
changed: [8ff2f325] => (item=/usr/local/www/lighttpd/index.html <html><body><h1>Lighttpd works!</h1></body></html>)
changed: [a99a6436] => (item=/usr/local/www/lighttpd/index.html <html><body><h1>Lighttpd works!</h1></body></html>)
changed: [ba2fcc3a] => (item=/usr/local/www/lighttpd/index.html <html><body><h1>Lighttpd works!</h1></body></html>)
changed: [8ff2f325] => (item=/usr/local/etc/lighttpd/lighttpd.annotated.conf UNDEFINED)
changed: [ba2fcc3a] => (item=/usr/local/etc/lighttpd/lighttpd.annotated.conf UNDEFINED)
changed: [a99a6436] => (item=/usr/local/etc/lighttpd/lighttpd.annotated.conf UNDEFINED)
changed: [8ff2f325] => (item=/usr/local/etc/lighttpd/lighttpd.annotated.conf UNDEFINED)
changed: [ba2fcc3a] => (item=/usr/local/etc/lighttpd/lighttpd.annotated.conf UNDEFINED)
changed: [a99a6436] => (item=/usr/local/etc/lighttpd/lighttpd.annotated.conf UNDEFINED)
changed: [8ff2f325] => (item=/usr/local/etc/lighttpd/lighttpd.annotated.conf UNDEFINED)
changed: [ba2fcc3a] => (item=/usr/local/etc/lighttpd/lighttpd.annotated.conf UNDEFINED)
changed: [a99a6436] => (item=/usr/local/etc/lighttpd/lighttpd.annotated.conf UNDEFINED)

TASK [vbotka.freebsd.config_light : Files-lineinfile: Lineinfile dict.] ********
changed: [8ff2f325] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.port)
changed: [ba2fcc3a] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.port)
changed: [a99a6436] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.port)
changed: [8ff2f325] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.use-ipv6)
changed: [ba2fcc3a] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.use-ipv6)
changed: [a99a6436] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.use-ipv6)
changed: [8ff2f325] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.username)
changed: [ba2fcc3a] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.username)
changed: [a99a6436] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.username)
changed: [8ff2f325] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.groupname)
changed: [ba2fcc3a] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.groupname)
changed: [a99a6436] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.groupname)
changed: [8ff2f325] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.document-root)
changed: [ba2fcc3a] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.document-root)
changed: [a99a6436] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.document-root)

TASK [vbotka.freebsd.config_light : Services: Enable FreeBSD services.] ********
changed: [8ff2f325] => (item=lighttpd)
changed: [ba2fcc3a] => (item=lighttpd)
changed: [a99a6436] => (item=lighttpd)

TASK [vbotka.freebsd.config_light : Services: Manage FreeBSD service.] *********
changed: [a99a6436] => (item=lighttpd)
changed: [8ff2f325] => (item=lighttpd)
changed: [ba2fcc3a] => (item=lighttpd)

RUNNING HANDLER [vbotka.freebsd.config_light : Reload lighttpd] ****************
ok: [8ff2f325]
ok: [ba2fcc3a]
ok: [a99a6436]

PLAY RECAP *********************************************************************
8ff2f325                   : ok=47   changed=6    unreachable=0    failed=0    skipped=82   rescued=0    ignored=0   
a99a6436                   : ok=36   changed=6    unreachable=0    failed=0    skipped=71   rescued=0    ignored=0   
ba2fcc3a                   : ok=36   changed=6    unreachable=0    failed=0    skipped=71   rescued=0    ignored=0   

Results

Open the page in a browser. For example, http://10.1.0.111/. The content should be

Lighttpd works!

Note

The role and the configuration data in the examples are idempotent. Once the application is installed and configured, ansible-playbook shouldn’t report any changes. To speedup the playbook, disable setup, sanity, debug, and install. This way, the role will audit the required infrastructure

(env) > ansible-playbook pb.yml -i hosts

Optionally, do not display OK hosts. See display_ok_hosts

(env) > ANSIBLE_DISPLAY_OK_HOSTS=false ansible-playbook pb.yml -i hosts

PLAY [Test role vbotka.freebsd.config_light] **************************************************

TASK [vbotka.config_light : Files: Manage files.] *********************************************

    ...

PLAY RECAP ************************************************************************************
0ed0d0ca: ok=32   changed=0    unreachable=0    failed=0    skipped=91   rescued=0    ignored=0
59a3f932: ok=32   changed=0    unreachable=0    failed=0    skipped=69   rescued=0    ignored=0
test_111: ok=32   changed=0    unreachable=0    failed=0    skipped=69   rescued=0    ignored=0