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
│ ├── 02_iocage.yml
│ └── 99_constructed.yml
├── host_vars
│ ├── iocage_01
│ │ └── iocage.yml
│ └── iocage_02
│ └── iocage.yml
├── iocage.ini
└── pb.yml
Synopsis¶
In the playbook:
vbotka.freebsd.pb_iocage_ansible_clients.yml create and start jails.
vbotka.freebsd.pb_iocage_update_repos.yml update repositories.
pb.ymlat the jails, install and configure lighttpd.
Requirements¶
Templates created in 202 Create iocage templates. Clone DHCP jails.
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 insteadfreebsd_pkgng_jail: "{{ iocage_jid }}"
The play
pb.yml` runs in the jails. The inventory ``iocage.iniis needed when a task is delegated to an iocage hostfreebsd_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, andfilesare group-writablecl_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
admshell> > groups admin admin : admin adm dialout
Fit the ownership and permissions in
cl-common.ymlto your needs.
See also
documentation Ansible role Config Light
module community.general.pkgng
ansible.cfg¶
Do not display skipped hosts. See the option display_skipped_hosts
[defaults]
gathering = explicit
callback_result_format = yaml
display_skipped_hosts = false
[connection]
pipelining = true
Inventory iocage.ini¶
iocage_01 ansible_host=10.1.0.18
iocage_02 ansible_host=10.1.0.73
[iocage]
iocage_01
iocage_02
[iocage:vars]
ansible_user=admin
ansible_become=true
ansible_python_interpreter=auto_silent
group_vars¶
properties:
notes: "vmm={{ inventory_hostname }}"
swarms:
sw_01:
count: 3
template: ansible_client
properties:
bpf: 1
dhcp: 1
vnet: 1
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 }}"
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 }}"'}
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¶
# In production, put the password into the vault.
ansible_become_password: admin
iocage_env:
CRYPTOGRAPHY_OPENSSL_NO_LEGACY: 1
Create and start jails¶
(env) > ansible-playbook vbotka.freebsd.pb_iocage_ansible_clients.yml \
-i iocage.ini \
-l iocage_02 \
-t swarm \
-e swarm=true
PLAY [Create and start jails. Optionally stop and destroy jails.] **************
TASK [Get iocage facts] ********************************************************
ok: [iocage_02]
TASK [Create swarms] ***********************************************************
changed: [iocage_02] => (item=sw_01)
TASK [Get iocage facts] ********************************************************
ok: [iocage_02]
TASK [Start swarms] ************************************************************
changed: [iocage_02] => (item=sw_01)
PLAY RECAP *********************************************************************
iocage_02 : ok=4 changed=2 unreachable=0 failed=0 skipped=6 rescued=0 ignored=0
Jails at iocage_02¶
[iocage_02]# iocage list -l
+-----+----------+------+-------+------+-----------------+--------------------+-----+----------------+----------+
| JID | NAME | BOOT | STATE | TYPE | RELEASE | IP4 | IP6 | TEMPLATE | BASEJAIL |
+=====+==========+======+=======+======+=================+====================+=====+================+==========+
| 71 | 57edfb2b | off | up | jail | 14.2-RELEASE-p3 | epair0b|10.1.0.140 | - | ansible_client | no |
+-----+----------+------+-------+------+-----------------+--------------------+-----+----------------+----------+
| 72 | 85c5a3f0 | off | up | jail | 14.2-RELEASE-p3 | epair0b|10.1.0.179 | - | ansible_client | no |
+-----+----------+------+-------+------+-----------------+--------------------+-----+----------------+----------+
| 73 | 9ab17c3d | off | up | jail | 14.2-RELEASE-p3 | epair0b|10.1.0.218 | - | ansible_client | no |
+-----+----------+------+-------+------+-----------------+--------------------+-----+----------------+----------+
Inventory hosts¶
plugin: vbotka.freebsd.iocage
host: 10.1.0.73
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 | split | map('split', '='))
plugin: ansible.builtin.constructed
groups:
up: iocage_state == 'up'
Display inventory¶
(env) > ansible-inventory -i hosts -i iocage.ini --graph
@all:
|--@ungrouped:
|--@up:
| |--57edfb2b
| |--85c5a3f0
| |--9ab17c3d
|--@iocage:
| |--iocage_01
| |--iocage_02
Update repos¶
ansible-playbook vbotka.freebsd.pb_iocage_update_repos.yml -i iocage.ini -l iocage_02
PLAY [Update repos.] ***********************************************************
TASK [Get iocage list of jails.] ***********************************************
ok: [iocage_02]
TASK [Set dictionary iocage_jails] *********************************************
ok: [iocage_02]
TASK [Update repos.] ***********************************************************
ok: [iocage_02] => (item=71)
ok: [iocage_02] => (item=72)
ok: [iocage_02] => (item=73)
PLAY RECAP *********************************************************************
iocage_02 : ok=3 changed=0 unreachable=0 failed=0 skipped=2 rescued=0 ignored=0
Configuration conf-light¶
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>
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
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
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'
lighttpd:
module: pkgng
name:
- www/lighttpd
lighttpd:
name: lighttpd
state: "{{ cl_service_lighttpd_state }}"
enabled: "{{ cl_service_lighttpd_enable }}"
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: [85c5a3f0]
ok: [9ab17c3d]
ok: [57edfb2b]
TASK [vbotka.freebsd.config_light : Setup: Create directories in /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light] ***
ok: [57edfb2b -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light)
ok: [57edfb2b -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/handlers.d)
ok: [57edfb2b -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/packages.d)
ok: [57edfb2b -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/services.d)
ok: [57edfb2b -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/files.d)
ok: [57edfb2b -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/states.d)
TASK [vbotka.freebsd.config_light : Setup: Create directory /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/assemble] ***
ok: [57edfb2b -> localhost]
TASK [vbotka.freebsd.config_light : Setup: Create directory /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/handlers] ***
ok: [57edfb2b -> localhost]
TASK [vbotka.freebsd.config_light : Setup: Create handlers/main.yml] ***********
changed: [57edfb2b -> localhost]
TASK [vbotka.freebsd.config_light : Vars-handlers: Assemble handlers to /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/assemble/handlersd] ***
changed: [57edfb2b -> localhost]
TASK [vbotka.freebsd.config_light : Vars-handlers: Include files from /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/assemble/handlersd to cl_handlersd_items] ***
ok: [57edfb2b -> localhost]
TASK [vbotka.freebsd.config_light : Vars-handlers: Combine cl_handlers with cl_handlersd_items.] ***
ok: [57edfb2b -> localhost]
TASK [vbotka.freebsd.config_light : Setup: Create handlers listed in cl_handlers.] ***
ok: [57edfb2b -> localhost] => (item=handlers-auto-lighttpd_freebsd.yml)
TASK [vbotka.freebsd.config_light : Setup: Include handlers in handlers/main.yml] ***
changed: [57edfb2b -> 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/313/conf-light/assemble/packagesd.57edfb2b] ***
ok: [9ab17c3d -> localhost]
ok: [57edfb2b -> localhost]
ok: [85c5a3f0 -> localhost]
TASK [vbotka.freebsd.config_light : Vars-packages: Include files from /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/assemble/packagesd.57edfb2b to cl_packagesd_items] ***
ok: [57edfb2b]
ok: [9ab17c3d]
ok: [85c5a3f0]
TASK [vbotka.freebsd.config_light : Vars-packages: Combine cl_packages with cl_packagesd_items.] ***
ok: [57edfb2b]
ok: [9ab17c3d]
ok: [85c5a3f0]
TASK [vbotka.freebsd.config_light : Vars-states: Assemble states to /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/assemble/statesd.57edfb2b] ***
changed: [57edfb2b -> localhost]
changed: [9ab17c3d -> localhost]
changed: [85c5a3f0 -> localhost]
TASK [vbotka.freebsd.config_light : Vars-states: Include files from /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/assemble/statesd.57edfb2b to cl_statessd_items] ***
ok: [57edfb2b]
ok: [9ab17c3d]
ok: [85c5a3f0]
TASK [vbotka.freebsd.config_light : Vars-states: Combine cl_statess with cl_statesd_items.] ***
ok: [57edfb2b]
ok: [9ab17c3d]
ok: [85c5a3f0]
TASK [vbotka.freebsd.config_light : Vars-services: Assemble services to /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/assemble/servicesd.57edfb2b] ***
changed: [57edfb2b -> localhost]
changed: [9ab17c3d -> localhost]
changed: [85c5a3f0 -> localhost]
TASK [vbotka.freebsd.config_light : Vars-services: Include files from /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/assemble/servicesd.57edfb2b to cl_cervicesd_items] ***
ok: [57edfb2b]
ok: [9ab17c3d]
ok: [85c5a3f0]
TASK [vbotka.freebsd.config_light : Vars-services: Combine cl_services with cl_servicesd_items.] ***
ok: [57edfb2b]
ok: [9ab17c3d]
ok: [85c5a3f0]
TASK [vbotka.freebsd.config_light : Vars-files: Assemble files to /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/assemble/filesd.57edfb2b] ***
changed: [85c5a3f0 -> localhost]
changed: [57edfb2b -> localhost]
changed: [9ab17c3d -> localhost]
TASK [vbotka.freebsd.config_light : Vars-files: Include files from /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/assemble/filesd.57edfb2b to cl_filesd_items] ***
ok: [57edfb2b]
ok: [9ab17c3d]
ok: [85c5a3f0]
TASK [vbotka.freebsd.config_light : Vars-files: Combine cl_files with cl_filesd_items.] ***
ok: [57edfb2b]
ok: [9ab17c3d]
ok: [85c5a3f0]
PLAY RECAP *********************************************************************
57edfb2b : ok=22 changed=6 unreachable=0 failed=0 skipped=17 rescued=0 ignored=0
9ab17c3d : ok=13 changed=6 unreachable=0 failed=0 skipped=9 rescued=0 ignored=0
85c5a3f0 : ok=13 changed=6 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: [85c5a3f0]
ok: [9ab17c3d]
ok: [57edfb2b]
TASK [vbotka.freebsd.config_light : Setup: Create directories in /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light] ***
ok: [57edfb2b -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light)
ok: [57edfb2b -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/handlers.d)
ok: [57edfb2b -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/packages.d)
ok: [57edfb2b -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/services.d)
ok: [57edfb2b -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/files.d)
ok: [57edfb2b -> localhost] => (item=/export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/states.d)
TASK [vbotka.freebsd.config_light : Setup: Create directory /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/assemble] ***
ok: [57edfb2b -> localhost]
TASK [vbotka.freebsd.config_light : Setup: Create directory /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/handlers] ***
ok: [57edfb2b -> localhost]
TASK [vbotka.freebsd.config_light : Setup: Create handlers/main.yml] ***********
ok: [57edfb2b -> localhost]
TASK [vbotka.freebsd.config_light : Vars-handlers: Assemble handlers to /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/assemble/handlersd] ***
ok: [57edfb2b -> localhost]
TASK [vbotka.freebsd.config_light : Vars-handlers: Include files from /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/assemble/handlersd to cl_handlersd_items] ***
ok: [57edfb2b -> localhost]
TASK [vbotka.freebsd.config_light : Vars-handlers: Combine cl_handlers with cl_handlersd_items.] ***
ok: [57edfb2b -> localhost]
TASK [vbotka.freebsd.config_light : Setup: Create handlers listed in cl_handlers.] ***
ok: [57edfb2b -> localhost] => (item=handlers-auto-lighttpd_freebsd.yml)
TASK [vbotka.freebsd.config_light : Setup: Include handlers in handlers/main.yml] ***
ok: [57edfb2b -> 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/313/conf-light/assemble/packagesd.57edfb2b] ***
changed: [85c5a3f0 -> localhost]
changed: [9ab17c3d -> localhost]
changed: [57edfb2b -> localhost]
TASK [vbotka.freebsd.config_light : Vars-packages: Include files from /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/assemble/packagesd.57edfb2b to cl_packagesd_items] ***
ok: [57edfb2b]
ok: [85c5a3f0]
ok: [9ab17c3d]
TASK [vbotka.freebsd.config_light : Vars-packages: Combine cl_packages with cl_packagesd_items.] ***
ok: [57edfb2b]
ok: [85c5a3f0]
ok: [9ab17c3d]
TASK [vbotka.freebsd.config_light : Vars-states: Assemble states to /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/assemble/statesd.57edfb2b] ***
changed: [85c5a3f0 -> localhost]
changed: [57edfb2b -> localhost]
changed: [9ab17c3d -> localhost]
TASK [vbotka.freebsd.config_light : Vars-states: Include files from /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/assemble/statesd.57edfb2b to cl_statessd_items] ***
ok: [57edfb2b]
ok: [85c5a3f0]
ok: [9ab17c3d]
TASK [vbotka.freebsd.config_light : Vars-states: Combine cl_statess with cl_statesd_items.] ***
ok: [57edfb2b]
ok: [85c5a3f0]
ok: [9ab17c3d]
TASK [vbotka.freebsd.config_light : Vars-services: Assemble services to /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/assemble/servicesd.57edfb2b] ***
changed: [85c5a3f0 -> localhost]
changed: [57edfb2b -> localhost]
changed: [9ab17c3d -> localhost]
TASK [vbotka.freebsd.config_light : Vars-services: Include files from /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/assemble/servicesd.57edfb2b to cl_cervicesd_items] ***
ok: [57edfb2b]
ok: [85c5a3f0]
ok: [9ab17c3d]
TASK [vbotka.freebsd.config_light : Vars-services: Combine cl_services with cl_servicesd_items.] ***
ok: [57edfb2b]
ok: [85c5a3f0]
ok: [9ab17c3d]
TASK [vbotka.freebsd.config_light : Vars-files: Assemble files to /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/assemble/filesd.57edfb2b] ***
changed: [57edfb2b -> localhost]
changed: [85c5a3f0 -> localhost]
changed: [9ab17c3d -> localhost]
TASK [vbotka.freebsd.config_light : Vars-files: Include files from /export/scratch/collections/ansible_collections/vbotka/freebsd/docs/source/examples/313/conf-light/assemble/filesd.57edfb2b to cl_filesd_items] ***
ok: [57edfb2b]
ok: [85c5a3f0]
ok: [9ab17c3d]
TASK [vbotka.freebsd.config_light : Vars-files: Combine cl_files with cl_filesd_items.] ***
ok: [57edfb2b]
ok: [85c5a3f0]
ok: [9ab17c3d]
TASK [vbotka.freebsd.config_light : Sanity: Data directories must exist.] ******
ok: [57edfb2b -> localhost]
TASK [vbotka.freebsd.config_light : Sanity: Supported modules for packages.] ***
ok: [57edfb2b -> localhost]
TASK [vbotka.freebsd.config_light : Packages: Select lists.] *******************
ok: [85c5a3f0]
ok: [57edfb2b]
ok: [9ab17c3d]
TASK [vbotka.freebsd.config_light : Packages: Create list defaulted to module package.] ***
ok: [57edfb2b]
ok: [85c5a3f0]
ok: [9ab17c3d]
TASK [vbotka.freebsd.config_light : Packages: Manage FreeBSD packages.] ********
changed: [85c5a3f0 -> iocage_02(10.1.0.73)] => (item=['www/lighttpd'])
changed: [9ab17c3d -> iocage_02(10.1.0.73)] => (item=['www/lighttpd'])
changed: [57edfb2b -> iocage_02(10.1.0.73)] => (item=['www/lighttpd'])
TASK [vbotka.freebsd.config_light : States: Apply file states.] ****************
changed: [57edfb2b] => (item=/usr/local/www/lighttpd)
changed: [9ab17c3d] => (item=/usr/local/www/lighttpd)
changed: [85c5a3f0] => (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 57edfb2b, 85c5a3f0, 9ab17c3d => (item=copy)
included: /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/tasks/files-template.yml for 57edfb2b, 85c5a3f0, 9ab17c3d => (item=template)
included: /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/tasks/files-markers.yml for 57edfb2b, 85c5a3f0, 9ab17c3d => (item=markers)
included: /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/tasks/files-create-backup.yml for 57edfb2b, 85c5a3f0, 9ab17c3d => (item=create-backup)
included: /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/tasks/files-patch.yml for 57edfb2b, 85c5a3f0, 9ab17c3d => (item=patch)
included: /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/tasks/files-lineinfile.yml for 57edfb2b, 85c5a3f0, 9ab17c3d => (item=lineinfile)
included: /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/tasks/files-blockinfile.yml for 57edfb2b, 85c5a3f0, 9ab17c3d => (item=blockinfile)
included: /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/tasks/files-inifile.yml for 57edfb2b, 85c5a3f0, 9ab17c3d => (item=inifile)
included: /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/tasks/files-ucl.yml for 57edfb2b, 85c5a3f0, 9ab17c3d => (item=ucl)
included: /scratch/collections/ansible_collections/vbotka/freebsd/roles/config_light/tasks/files-delete-backup.yml for 57edfb2b, 85c5a3f0, 9ab17c3d => (item=delete-backup)
TASK [vbotka.freebsd.config_light : File-create-backup: Create time-stamp.] ****
ok: [57edfb2b]
ok: [85c5a3f0]
ok: [9ab17c3d]
TASK [vbotka.freebsd.config_light : File-create-backup: Stat cl_files.] ********
ok: [57edfb2b] => (item=/usr/local/www/lighttpd/index.html)
ok: [9ab17c3d] => (item=/usr/local/www/lighttpd/index.html)
ok: [85c5a3f0] => (item=/usr/local/www/lighttpd/index.html)
ok: [57edfb2b] => (item=/usr/local/etc/lighttpd/lighttpd.conf)
ok: [9ab17c3d] => (item=/usr/local/etc/lighttpd/lighttpd.conf)
ok: [85c5a3f0] => (item=/usr/local/etc/lighttpd/lighttpd.conf)
TASK [vbotka.freebsd.config_light : File-create-backup: Create backup files.] ***
ok: [57edfb2b] => (item=/usr/local/etc/lighttpd/lighttpd.conf)
ok: [9ab17c3d] => (item=/usr/local/etc/lighttpd/lighttpd.conf)
ok: [85c5a3f0] => (item=/usr/local/etc/lighttpd/lighttpd.conf)
TASK [vbotka.freebsd.config_light : Files-lineinfile: Lineinfile lines.] *******
changed: [57edfb2b] => (item=/usr/local/www/lighttpd/index.html <html><body><h1>Lighttpd works!</h1></body></html>)
changed: [85c5a3f0] => (item=/usr/local/www/lighttpd/index.html <html><body><h1>Lighttpd works!</h1></body></html>)
changed: [9ab17c3d] => (item=/usr/local/www/lighttpd/index.html <html><body><h1>Lighttpd works!</h1></body></html>)
TASK [vbotka.freebsd.config_light : Files-lineinfile: Lineinfile dict.] ********
changed: [85c5a3f0] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.port)
changed: [57edfb2b] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.port)
changed: [9ab17c3d] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.port)
changed: [57edfb2b] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.use-ipv6)
changed: [9ab17c3d] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.use-ipv6)
changed: [85c5a3f0] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.use-ipv6)
changed: [57edfb2b] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.username)
changed: [9ab17c3d] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.username)
changed: [85c5a3f0] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.username)
changed: [57edfb2b] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.groupname)
changed: [85c5a3f0] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.groupname)
changed: [9ab17c3d] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.groupname)
changed: [57edfb2b] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.document-root)
changed: [85c5a3f0] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.document-root)
changed: [9ab17c3d] => (item=/usr/local/etc/lighttpd/lighttpd.conf server.document-root)
TASK [vbotka.freebsd.config_light : Services: Enable FreeBSD services.] ********
changed: [85c5a3f0] => (item=lighttpd)
changed: [9ab17c3d] => (item=lighttpd)
changed: [57edfb2b] => (item=lighttpd)
TASK [vbotka.freebsd.config_light : debug] *************************************
ok: [57edfb2b] =>
out:
changed: true
msg: All items completed
results:
- ansible_loop_var: item
changed: true
delim: ' '
failed: false
gid: 0
group: wheel
invocation:
module_args: {}
item:
key: lighttpd
value:
enabled: true
name: lighttpd
state: start
jail: null
mode: '0644'
name: lighttpd_enable
owner: root
path: /etc/rc.conf
size: 354
state: file
uid: 0
value: 'YES'
skipped: false
ok: [85c5a3f0] =>
out:
changed: true
msg: All items completed
results:
- ansible_loop_var: item
changed: true
delim: ' '
failed: false
gid: 0
group: wheel
invocation:
module_args: {}
item:
key: lighttpd
value:
enabled: true
name: lighttpd
state: start
jail: null
mode: '0644'
name: lighttpd_enable
owner: root
path: /etc/rc.conf
size: 354
state: file
uid: 0
value: 'YES'
skipped: false
ok: [9ab17c3d] =>
out:
changed: true
msg: All items completed
results:
- ansible_loop_var: item
changed: true
delim: ' '
failed: false
gid: 0
group: wheel
invocation:
module_args: {}
item:
key: lighttpd
value:
enabled: true
name: lighttpd
state: start
jail: null
mode: '0644'
name: lighttpd_enable
owner: root
path: /etc/rc.conf
size: 354
state: file
uid: 0
value: 'YES'
skipped: false
TASK [vbotka.freebsd.config_light : Services: Manage FreeBSD service.] *********
changed: [85c5a3f0] => (item=lighttpd)
changed: [57edfb2b] => (item=lighttpd)
changed: [9ab17c3d] => (item=lighttpd)
RUNNING HANDLER [vbotka.freebsd.config_light : Reload lighttpd] ****************
ok: [57edfb2b]
ok: [85c5a3f0]
ok: [9ab17c3d]
PLAY RECAP *********************************************************************
57edfb2b : ok=47 changed=9 unreachable=0 failed=0 skipped=78 rescued=0 ignored=0
85c5a3f0 : ok=36 changed=9 unreachable=0 failed=0 skipped=67 rescued=0 ignored=0
9ab17c3d : ok=36 changed=9 unreachable=0 failed=0 skipped=67 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