526 Log server and clients (ansible_init)

Use case

Use the iocage template ansible-init created in 524 iocage template ansible-init. Configure the repository ansible-conf-init to pull the jails’ configuration from the repositories ansible-conf-syslogng-server and ansible-conf-syslogng-client. Create jails from the template. Use class=log-server and class=log-client to select the configuration. Run ansible-pull asynchronously.

Tree

shell > tree .
.
├── ansible.cfg
├── group_vars
│   └── all
│       ├── common.yml
│       ├── project-hosts.yml
│       └── project.yml
├── hosts
│   └── 05_iocage.yml
├── iocage.ini
├── pb-logclient-test.yml
└── pb-logserver-test.yml

Synopsis

Requirements

Note

Hint

Update the configuration repositories to your needs. Synchronize the dictionary project_hosts in the files group_vars/all/project-hosts.yml in this example and in the repositories.

ansible.cfg

[defaults]
callback_result_format = yaml
deprecation_warnings = false
display_skipped_hosts = false
gathering = explicit
interpreter_python = auto_silent
log_path = /var/log/ansible.log

[connection]
pipelining = true

Inventory iocage.ini

iocage_05

[iocage]
iocage_05

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

hosts

hosts/05_iocage.yml
plugin: vbotka.freebsd.iocage
host: iocage_05
user: admin
sudo: true
get_properties: true
inventory_hostname_tag: alias

compose:
  iocage_tags: dict(iocage_properties.notes | regex_findall('(\w+)=([\w\-]+)'))
  iocage_classes: iocage_properties.notes | regex_findall('(?<=class=)[\w\-]+|(?<=,)[\w\-]+')
# connection plugin vbotka.freebsd.jailexec
  ansible_connection: "'vbotka.freebsd.jailexec'"
  ansible_jail_host: dict(iocage_properties.notes | regex_findall('(\w+)=([\w\-]+)')).vmm | d('none')
  ansible_jail_name: iocage_jid
  ansible_jail_privilege_escalation: "'sudo'"

groups:
  log_servers: iocage_classes is contains('log-server')
  log_clients: iocage_classes is contains('log-client')

keyed_groups:
  - prefix: state
    key: iocage_state
  - prefix: vmm
    key: iocage_tags.vmm

group_vars

group_vars/all/common.yml
ansible_python_interpreter: auto_silent
group_vars/all/project-hosts.yml
project_hosts:
  iocage_05:
    defaultrouter: 172.16.99.1 
    log_server: 172.16.99.10
    # repositories
    repos: 172.16.99.21
    repos_devel: 172.16.99.22
    # plugins
    ansible_pull_syslogng_server: 172.16.99.31
group_vars/all/project.yml
project:
  log-server:
    notes: alias=log_server
    vmm: iocage_05
    template: ansible-init
    class: [log-server]
    custom_facts: class.fact.j2
    properties:
      ip4: disable
      ip6: disable
      ip6_addr: none
      boot: 1
      defaultrouter: "{{ project_hosts[inventory_hostname]['defaultrouter'] }}"
      ip4_addr: "vnet0|{{ project_hosts[inventory_hostname]['log_server'] }}/24"
      vnet: 1
  www-01:
    notes: alias=www_01
    vmm: iocage_05
    template: ansible-init
    class: [log-client]
    custom_facts: class.fact.j2
  www-02:
    notes: alias=www_02
    vmm: iocage_05
    template: ansible-init
    class: [log-client]
    custom_facts: class.fact.j2

properties:
  ip4: disable
  ip6: disable
  ip6_addr: none
  bpf: 1
  dhcp: 1
  vnet: 1
  boot: 1

vmm_groups: "{{ dict(project | dict2items | groupby('value.vmm')) }}"
vmm: "{{ dict(vmm_groups.keys() | zip(vmm_groups.values() | map('items2dict'))) }}"

Playbook output - Create project jails from iocage templates

(env) > ansible-playbook vbotka.freebsd.pb_iocage_project_create_from_templates.yml -i iocage.ini -i hosts
PLAY [Create and start project jails from iocage templates.] *******************

TASK [Setup: Get activated pool.] **********************************************
ok: [iocage_05]

TASK [Create: Create jails.] ***************************************************
ok: [iocage_05] => (item=log-server)
ok: [iocage_05] => (item=www-02)
ok: [iocage_05] => (item=www-01)

TASK [Facts: Create custom facts dirs.] ****************************************
changed: [iocage_05] => (item=log-server)
changed: [iocage_05] => (item=www-01)
changed: [iocage_05] => (item=www-02)

TASK [Facts: Create custom facts files.] ***************************************
changed: [iocage_05] => (item=log-server)
changed: [iocage_05] => (item=www-01)
changed: [iocage_05] => (item=www-02)

TASK [Properties: Set properties.] *********************************************
ok: [iocage_05] => (item=log-server)
ok: [iocage_05] => (item=www-01)
ok: [iocage_05] => (item=www-02)

TASK [Start: Start jails.] *****************************************************
ok: [iocage_05]

PLAY RECAP *********************************************************************
iocage_05                  : ok=6    changed=2    unreachable=0    failed=0    skipped=7    rescued=0    ignored=0   

Inventory graph

shell > ansible-inventory -i hosts --graph
@all:
  |--@ungrouped:
  |--@state_down:
  |  |--ansible-pull-syslogng-client
  |  |--ansible-pull-syslogng-server
  |  |--ansible-pull-test
  |--@state_up:
  |  |--bar
  |  |--baz
  |  |--foo
  |  |--qux
  |  |--repos
  |  |--log_server
  |  |--repos_devel
  |  |--www_01
  |  |--www_02
  |--@vmm_iocage_05:
  |  |--bar
  |  |--baz
  |  |--foo
  |  |--qux
  |  |--repos
  |  |--log_server
  |  |--repos_devel
  |  |--www_01
  |  |--www_02
  |--@log_servers:
  |  |--log_server
  |--@log_clients:
  |  |--www_01
  |  |--www_02

List jails

shell > ssh admin@iocage_05 sudo iocage list -l
+------+------------------------------+------+-------+----------+--------------+-----------------------+-----+---------------+----------+
| JID  |             NAME             | BOOT | STATE |   TYPE   |   RELEASE    |          IP4          | IP6 |   TEMPLATE    | BASEJAIL |
+======+==============================+======+=======+==========+==============+=======================+=====+===============+==========+
| None | ansible-pull-syslogng-client | off  | down  | pluginv2 | 15.0-RELEASE | DHCP (not running)    | -   | -             | yes      |
+------+------------------------------+------+-------+----------+--------------+-----------------------+-----+---------------+----------+
| None | ansible-pull-syslogng-server | off  | down  | pluginv2 | 15.0-RELEASE | vnet0|172.16.99.31/24 | -   | -             | yes      |
+------+------------------------------+------+-------+----------+--------------+-----------------------+-----+---------------+----------+
| None | ansible-pull-test            | off  | down  | pluginv2 | 15.0-RELEASE | DHCP (not running)    | -   | -             | yes      |
+------+------------------------------+------+-------+----------+--------------+-----------------------+-----+---------------+----------+
| 13   | bar                          | on   | up    | jail     | 15.0-RELEASE | epair0b|172.16.99.103 | -   | ansible-init  | no       |
+------+------------------------------+------+-------+----------+--------------+-----------------------+-----+---------------+----------+
| 14   | baz                          | on   | up    | jail     | 15.0-RELEASE | epair0b|172.16.99.172 | -   | ansible-init  | no       |
+------+------------------------------+------+-------+----------+--------------+-----------------------+-----+---------------+----------+
| 12   | foo                          | on   | up    | jail     | 15.0-RELEASE | epair0b|172.16.99.196 | -   | ansible-init  | no       |
+------+------------------------------+------+-------+----------+--------------+-----------------------+-----+---------------+----------+
| 16   | log-server                   | on   | up    | jail     | 15.0-RELEASE | vnet0|172.16.99.10/24 | -   | ansible-init  | no       |
+------+------------------------------+------+-------+----------+--------------+-----------------------+-----+---------------+----------+
| 15   | qux                          | on   | up    | jail     | 15.0-RELEASE | epair0b|172.16.99.104 | -   | ansible-init  | no       |
+------+------------------------------+------+-------+----------+--------------+-----------------------+-----+---------------+----------+
| 6    | repos                        | on   | up    | jail     | 15.0-RELEASE | vnet0|172.16.99.21/24 | -   | ansible-repos | no       |
+------+------------------------------+------+-------+----------+--------------+-----------------------+-----+---------------+----------+
| 7    | repos-devel                  | on   | up    | jail     | 15.0-RELEASE | vnet0|172.16.99.22/24 | -   | ansible-repos | no       |
+------+------------------------------+------+-------+----------+--------------+-----------------------+-----+---------------+----------+
| 17   | www-01                       | on   | up    | jail     | 15.0-RELEASE | epair0b|172.16.99.185 | -   | ansible-init  | no       |
+------+------------------------------+------+-------+----------+--------------+-----------------------+-----+---------------+----------+
| 18   | www-02                       | on   | up    | jail     | 15.0-RELEASE | epair0b|172.16.99.106 | -   | ansible-init  | no       |
+------+------------------------------+------+-------+----------+--------------+-----------------------+-----+---------------+----------+

Playbook pb-logserver-test.yml

---
- name: Test Log Server.
  hosts: log_servers
    
  tasks:

    - name: Run commands.
      register: out
      ansible.builtin.shell: "{{ item }}"
      loop:
        - rm -rf /var/log/remote/localhost/*
        - service syslog-ng status
        - loggen -i -S -n 1 localhost 514
        - sleep 2; find /var/log/remote/localhost/ -name *.log | xargs cat

    - name: Debug.
      when: debug | d(false) | bool
      ansible.builtin.debug:
        msg: |
          {% for i in out.results %}
          shell> {{ i.item }}
          {% if i.stdout | length > 0 %}
          {{ i.stdout }}
          {% endif %}
          {% if i.stderr | length > 0 %}
          {{ i.stderr }}
          {% endif %}

          {% endfor %}

Playbook output - Test Log Server

(env) > ansible-playbook pb-logserver-test.yml -i hosts -e debug=true
PLAY [Test Log Server.] ********************************************************

TASK [Run commands.] ***********************************************************
changed: [log_server] => (item=rm -rf /var/log/remote/localhost/*)
changed: [log_server] => (item=service syslog-ng status)
changed: [log_server] => (item=loggen -i -S -n 1 localhost 514)
changed: [log_server] => (item=sleep 2; find /var/log/remote/localhost/ -name *.log | xargs cat)

TASK [Debug.] ******************************************************************
ok: [log_server] => 
    msg: |-
        shell> rm -rf /var/log/remote/localhost/*

        shell> service syslog-ng status
        syslog_ng is running as pid 54878.

        shell> loggen -i -S -n 1 localhost 514
        count=1, rate = 27777.78 msg/sec
        average rate = 2.00 msg/sec, count=1, time=0.500304, (average) msg size=256, bandwidth=0.50 kB/sec

        shell> sleep 2; find /var/log/remote/localhost/ -name *.log | xargs cat
        Jul  2 15:58:24 localhost prg00000[1234]: seq: 0000000000, thread: 0000, runid: 1783000704, stamp: 2026-07-02T15:58:24 PADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADD

PLAY RECAP *********************************************************************
log_server                 : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Playbook pb-logclient-test.yml

---
- name: Test Log Clients.
  hosts: log_clients

  vars:

    log_server: "{{ hostvars['log_server']['iocage_ip4'] }}"

  tasks:

    - name: Run loggen
      register: out
      ansible.builtin.command: "loggen -i -S -n 1 {{ log_server }} 514"

    - name: Debug.
      ansible.builtin.debug:
        var: out.stderr

- name: Display the logs.
  hosts: log_server
    
  tasks:

    - name: Get log files paths.
      register: out
      ansible.builtin.find:
        paths: /var/log/remote
        recurse: true
        patterns: '*.log'

    - name: Get log files.
      register: out
      ansible.builtin.command: "cat {{ item }}"
      loop: "{{ out.files | map(attribute='path') }}"

    - name: Display log files.
      ansible.builtin.debug:
        msg: |
          {{ item.stdout }}

          - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      loop: "{{ out.results }}"
      loop_control:
        label: "{{ item.cmd }}"

Playbook output - Test Log Clients

(env) > ansible-playbook pb-logclient-test.yml -i hosts
PLAY [Test Log Clients.] *******************************************************

TASK [Run loggen] **************************************************************
changed: [www_01]
changed: [www_02]

TASK [Debug.] ******************************************************************
ok: [www_01] => 
    out.stderr: |-
        count=1, rate = 27777.78 msg/sec
        average rate = 2.00 msg/sec, count=1, time=0.500296, (average) msg size=256, bandwidth=0.50 kB/sec
ok: [www_02] => 
    out.stderr: |-
        count=1, rate = 142857.14 msg/sec
        average rate = 2.00 msg/sec, count=1, time=0.500316, (average) msg size=256, bandwidth=0.50 kB/sec

PLAY [Display the logs.] *******************************************************

TASK [Get log files paths.] ****************************************************
ok: [log_server]

TASK [Get log files.] **********************************************************
changed: [log_server] => (item=/var/log/remote/172.16.99.185/2026_07_02.log)
changed: [log_server] => (item=/var/log/remote/172.16.99.106/2026_07_02.log)
changed: [log_server] => (item=/var/log/remote/localhost/2026_07_02.log)

TASK [Display log files.] ******************************************************
ok: [log_server] => (item=['cat', '/var/log/remote/172.16.99.185/2026_07_02.log']) => 
    msg: |-
        Jul  2 15:55:50 172.16.99.185 syslog-ng[55509]: syslog-ng starting up; version='4.11.0'
        Jul  2 15:55:50 172.16.99.185 syslog-ng[55509]: Syslog connection established; fd='19', server='AF_INET(172.16.99.10:514)', local='AF_INET(0.0.0.0:0)'
        Jul  2 15:55:50 172.16.99.185 1 2026-07-02T15:55:50.991841+02:00 www-01 ansible-vbotka.freebsd.service 55557 - - Invoked with script=syslog-ng command=reload list_enabled=False synopsis=False wait=0.5 env=None jail=None
        Jul  2 15:55:18 172.16.99.185 ansible: n=ansible WARNING| [WARNING]: Could not match supplied host pattern, ignoring: www-01
        Jul  2 15:55:19 172.16.99.185 ansible: n=ansible INFO| PLAY [ansible-init] ************************************************************
        Jul  2 15:55:19 172.16.99.185 ansible: n=ansible INFO| TASK [Get hostname.] ***********************************************************
        Jul  2 15:55:19 172.16.99.185 ansible: n=ansible INFO| ok: [localhost.my.domain]
        Jul  2 15:55:20 172.16.99.185 ansible: n=ansible INFO| TASK [Get custom facts.] *******************************************************
        Jul  2 15:55:20 172.16.99.185 ansible: n=ansible INFO| ok: [localhost.my.domain]
        Jul  2 15:55:20 172.16.99.185 ansible: n=ansible INFO| TASK [Include variables from ai_vars directory.] *******************************
        Jul  2 15:55:20 172.16.99.185 ansible: n=ansible INFO| ok: [localhost.my.domain] => (item=/root/ansible-vars/project-hosts.yml)
        Jul  2 15:55:20 172.16.99.185 ansible: n=ansible INFO| TASK [Display vars.] ***********************************************************
        Jul  2 15:55:20 172.16.99.185 ansible: n=ansible INFO| ok: [localhost.my.domain] =>
        Jul  2 15:55:51 172.16.99.185 ansible: |-
        Jul  2 15:55:51 172.16.99.185 ansible: true
        Jul  2 15:55:51 172.16.99.185 ansible: /root/ansible-vars
        Jul  2 15:55:51 172.16.99.185 ansible: www-01
        Jul  2 15:55:51 172.16.99.185 ansible: ['log-client']
        Jul  2 15:55:51 172.16.99.185 ansible: {'defaultrouter': '172.16.99.1', 'log_server': '172.16.99.10', 'repos': '172.16.99.21', 'repos_devel': '172.16.99.22', 'ansible_pull_syslogng_server': '172.16.99.31'}
        Jul  2 15:55:20 172.16.99.185 ansible: n=ansible INFO| TASK [Set ai_cmd] **************************************************************
        Jul  2 15:55:20 172.16.99.185 ansible: n=ansible INFO| ok: [localhost.my.domain]
        Jul  2 15:55:20 172.16.99.185 ansible: n=ansible INFO| TASK [Execute ai_cmd] **********************************************************
        Jul  2 15:55:20 172.16.99.185 ansible: n=ansible INFO| included: /root/ansible-conf-init/tasks/execute-cmd.yml for localhost.my.domain
        Jul  2 15:55:20 172.16.99.185 ansible: n=ansible INFO| TASK [Display vars.] ***********************************************************
        Jul  2 15:55:20 172.16.99.185 ansible: n=ansible INFO| ok: [localhost.my.domain] =>
        Jul  2 15:55:51 172.16.99.185 ansible: |-
        Jul  2 15:55:51 172.16.99.185 ansible:
        Jul  2 15:55:51 172.16.99.185 ansible: True
        Jul  2 15:55:51 172.16.99.185 ansible:      ansible-pull -i hosts -U git://172.16.99.21/ansible-conf-syslogng-client -d /root/ansible-conf-syslogng-client -e "ai_vars=/root/ansible-vars" -e "ai_pull_mode=true" pb-logclient.yml &&  echo '[INFO] ansible-pull finished.'
        Jul  2 15:55:20 172.16.99.185 ansible: n=ansible INFO| TASK [Execute command async=3600 poll=0] ***************************************
        Jul  2 15:55:20 172.16.99.185 ansible: n=ansible INFO| changed: [localhost.my.domain]
        Jul  2 15:55:20 172.16.99.185 ansible: n=ansible INFO| PLAY RECAP *********************************************************************
        Jul  2 15:55:20 172.16.99.185 ansible: n=ansible INFO| localhost.my.domain        : ok=8    changed=1    unreachable=0    failed=0    skipped=3    rescued=0    ignored=0
        Jul  2 15:55:21 172.16.99.185 ansible: n=ansible INFO| Starting Ansible Pull at 2026-07-02 15:55:21
        Jul  2 15:55:21 172.16.99.185 ansible: n=ansible INFO| /usr/local/bin/ansible-pull -i hosts -U git://172.16.99.21/ansible-conf-syslogng-client -d /root/ansible-conf-syslogng-client -e ai_vars=/root/ansible-vars -e ai_pull_mode=true pb-logclient.yml
        Jul  2 15:55:21 172.16.99.185 ansible: n=ansible WARNING| [WARNING]: Could not match supplied host pattern, ignoring: www-01
        Jul  2 15:55:23 172.16.99.185 ansible: n=ansible INFO| localhost.my.domain | CHANGED => {
        Jul  2 15:55:51 172.16.99.185 ansible: "e013aceca4ffe51bb9fd85ef16e1836ffdd91d5a",
        Jul  2 15:55:51 172.16.99.185 ansible: {
        Jul  2 15:55:51 172.16.99.185 ansible: "/usr/local/bin/python3.11"
        Jul  2 15:55:51 172.16.99.185 ansible:
        Jul  2 15:55:51 172.16.99.185 ansible: null,
        Jul  2 15:55:51 172.16.99.185 ansible: true
        Jul  2 15:55:51 172.16.99.185 ansible:
        Jul  2 15:55:24 172.16.99.185 ansible: n=ansible WARNING| [WARNING]: Could not match supplied host pattern, ignoring: www-01
        Jul  2 15:55:25 172.16.99.185 ansible: n=ansible INFO| PLAY [Configure Log Client.] ***************************************************
        Jul  2 15:55:25 172.16.99.185 ansible: n=ansible INFO| TASK [Include variables from ai_vars directory.] *******************************
        Jul  2 15:55:25 172.16.99.185 ansible: n=ansible INFO| ok: [localhost.my.domain] => (item=/root/ansible-vars/project-hosts.yml)
        Jul  2 15:55:26 172.16.99.185 ansible: n=ansible INFO| TASK [Display vars.] ***********************************************************
        Jul  2 15:55:26 172.16.99.185 ansible: n=ansible INFO| ok: [localhost.my.domain] =>
        Jul  2 15:55:51 172.16.99.185 ansible: |-
        Jul  2 15:55:51 172.16.99.185 ansible: true
        Jul  2 15:55:51 172.16.99.185 ansible: /root/ansible-vars
        Jul  2 15:55:45 172.16.99.185 ansible: n=ansible INFO| TASK [Install packages.] *******************************************************
        Jul  2 15:55:45 172.16.99.185 ansible: n=ansible INFO| changed: [localhost.my.domain]
        Jul  2 15:55:47 172.16.99.185 ansible: n=ansible INFO| TASK [vbotka.freebsd.postinstall : Rcconf: Configure syslogd_enable in /etc/rc.conf] ***
        Jul  2 15:55:47 172.16.99.185 ansible: n=ansible INFO| changed: [localhost.my.domain]
        Jul  2 15:55:47 172.16.99.185 ansible: n=ansible INFO| TASK [vbotka.freebsd.postinstall : Syslog-ng: Sanity fp_syslogng_conf is empty.] ***
        Jul  2 15:55:47 172.16.99.185 ansible: n=ansible INFO| ok: [localhost.my.domain]
        Jul  2 15:55:48 172.16.99.185 ansible: n=ansible INFO| TASK [vbotka.freebsd.postinstall : Syslog-ng: Configure /usr/local/etc/syslog-ng.conf] ***
        Jul  2 15:55:48 172.16.99.185 ansible: n=ansible INFO| changed: [localhost.my.domain]
        Jul  2 15:55:49 172.16.99.185 ansible: n=ansible INFO| TASK [vbotka.freebsd.postinstall : Rcconf: Configure syslog_ng_enable in /etc/rc.conf] ***
        Jul  2 15:55:49 172.16.99.185 ansible: n=ansible INFO| changed: [localhost.my.domain]
        Jul  2 15:55:50 172.16.99.185 ansible: n=ansible INFO| RUNNING HANDLER [vbotka.freebsd.postinstall : Start syslog-ng] *****************
        Jul  2 15:55:50 172.16.99.185 ansible: n=ansible INFO| changed: [localhost.my.domain]
        Jul  2 15:55:51 172.16.99.185 syslog-ng[55509]: Loading the new configuration;
        Jul  2 15:55:51 172.16.99.185 syslog-ng[55509]: Configuration reload finished;
        Jul  2 15:55:51 172.16.99.185 1 2026-07-02T15:55:51.931761+02:00 www-01 ansible-vbotka.freebsd.service 55667 - - Invoked with script=syslogd command=stop list_enabled=False synopsis=False wait=0.5 env=None jail=None
        Jul  2 15:55:51 172.16.99.185 ansible: n=ansible INFO| RUNNING HANDLER [vbotka.freebsd.postinstall : Reload syslog-ng] ****************
        Jul  2 15:55:51 172.16.99.185 ansible: n=ansible INFO| ok: [localhost.my.domain]
        Jul  2 15:55:52 172.16.99.185 ansible: n=ansible INFO| RUNNING HANDLER [vbotka.freebsd.postinstall : Stop syslogd] ********************
        Jul  2 15:55:52 172.16.99.185 ansible: n=ansible INFO| ok: [localhost.my.domain]
        Jul  2 15:55:52 172.16.99.185 ansible: n=ansible INFO| PLAY RECAP *********************************************************************
        Jul  2 15:55:52 172.16.99.185 ansible: n=ansible INFO| localhost.my.domain        : ok=10   changed=5    unreachable=0    failed=0    skipped=19   rescued=0    ignored=0
        Jul  2 15:55:54 172.16.99.185 1 2026-07-02T15:55:54.841722+02:00 www-01 ansible-async_wrapper.py 52201 - - Module complete (52201)
        Jul  2 15:58:46 172.16.99.185 prg00000[1234]: seq: 0000000000, thread: 0000, runid: 1783000726, stamp: 2026-07-02T15:58:46 PADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADD
        Jul  2 15:58:46 172.16.99.185 1 2026-07-02T15:58:46.432475+02:00 www-01 ansible-ansible.legacy.command 57830 - - Invoked with _raw_params=loggen -i -S -n 1 172.16.99.10 514 _uses_shell=False expand_argument_vars=True stdin_add_newline=True strip_empty_ends=True cmd=None argv=None chdir=None executable=None creates=None removes=None stdin=None

        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ok: [log_server] => (item=['cat', '/var/log/remote/172.16.99.106/2026_07_02.log']) => 
    msg: |-
        Jul  2 15:56:01 172.16.99.106 syslog-ng[56733]: syslog-ng starting up; version='4.11.0'
        Jul  2 15:56:01 172.16.99.106 syslog-ng[56733]: Syslog connection established; fd='19', server='AF_INET(172.16.99.10:514)', local='AF_INET(0.0.0.0:0)'
        Jul  2 15:56:02 172.16.99.106 1 2026-07-02T15:56:02.564134+02:00 www-02 ansible-vbotka.freebsd.service 56764 - - Invoked with script=syslog-ng command=reload list_enabled=False synopsis=False wait=0.5 env=None jail=None
        Jul  2 15:56:02 172.16.99.106 syslog-ng[56733]: Loading the new configuration;
        Jul  2 15:56:02 172.16.99.106 syslog-ng[56733]: Configuration reload finished;
        Jul  2 15:56:03 172.16.99.106 1 2026-07-02T15:56:03.497892+02:00 www-02 ansible-vbotka.freebsd.service 56903 - - Invoked with script=syslogd command=stop list_enabled=False synopsis=False wait=0.5 env=None jail=None
        Jul  2 15:55:29 172.16.99.106 ansible: n=ansible WARNING| [WARNING]: Could not match supplied host pattern, ignoring: www-02
        Jul  2 15:55:29 172.16.99.106 ansible: n=ansible INFO| PLAY [ansible-init] ************************************************************
        Jul  2 15:55:30 172.16.99.106 ansible: n=ansible INFO| TASK [Get hostname.] ***********************************************************
        Jul  2 15:55:30 172.16.99.106 ansible: n=ansible INFO| ok: [localhost.my.domain]
        Jul  2 15:55:30 172.16.99.106 ansible: n=ansible INFO| TASK [Get custom facts.] *******************************************************
        Jul  2 15:55:30 172.16.99.106 ansible: n=ansible INFO| ok: [localhost.my.domain]
        Jul  2 15:55:30 172.16.99.106 ansible: n=ansible INFO| TASK [Include variables from ai_vars directory.] *******************************
        Jul  2 15:55:30 172.16.99.106 ansible: n=ansible INFO| ok: [localhost.my.domain] => (item=/root/ansible-vars/project-hosts.yml)
        Jul  2 15:55:31 172.16.99.106 ansible: n=ansible INFO| TASK [Display vars.] ***********************************************************
        Jul  2 15:55:31 172.16.99.106 ansible: n=ansible INFO| ok: [localhost.my.domain] =>
        Jul  2 15:56:03 172.16.99.106 ansible: |-
        Jul  2 15:56:03 172.16.99.106 ansible: true
        Jul  2 15:56:03 172.16.99.106 ansible: /root/ansible-vars
        Jul  2 15:56:03 172.16.99.106 ansible: www-02
        Jul  2 15:56:03 172.16.99.106 ansible: ['log-client']
        Jul  2 15:56:03 172.16.99.106 ansible: {'defaultrouter': '172.16.99.1', 'log_server': '172.16.99.10', 'repos': '172.16.99.21', 'repos_devel': '172.16.99.22', 'ansible_pull_syslogng_server': '172.16.99.31'}
        Jul  2 15:55:31 172.16.99.106 ansible: n=ansible INFO| TASK [Set ai_cmd] **************************************************************
        Jul  2 15:55:31 172.16.99.106 ansible: n=ansible INFO| ok: [localhost.my.domain]
        Jul  2 15:55:31 172.16.99.106 ansible: n=ansible INFO| TASK [Execute ai_cmd] **********************************************************
        Jul  2 15:55:31 172.16.99.106 ansible: n=ansible INFO| included: /root/ansible-conf-init/tasks/execute-cmd.yml for localhost.my.domain
        Jul  2 15:55:31 172.16.99.106 ansible: n=ansible INFO| TASK [Display vars.] ***********************************************************
        Jul  2 15:55:31 172.16.99.106 ansible: n=ansible INFO| ok: [localhost.my.domain] =>
        Jul  2 15:56:03 172.16.99.106 ansible: |-
        Jul  2 15:56:03 172.16.99.106 ansible:
        Jul  2 15:56:03 172.16.99.106 ansible: True
        Jul  2 15:56:03 172.16.99.106 ansible:      ansible-pull -i hosts -U git://172.16.99.21/ansible-conf-syslogng-client -d /root/ansible-conf-syslogng-client -e "ai_vars=/root/ansible-vars" -e "ai_pull_mode=true" pb-logclient.yml &&  echo '[INFO] ansible-pull finished.'
        Jul  2 15:55:31 172.16.99.106 ansible: n=ansible INFO| TASK [Execute command async=3600 poll=0] ***************************************
        Jul  2 15:55:31 172.16.99.106 ansible: n=ansible INFO| changed: [localhost.my.domain]
        Jul  2 15:55:31 172.16.99.106 ansible: n=ansible INFO| PLAY RECAP *********************************************************************
        Jul  2 15:55:31 172.16.99.106 ansible: n=ansible INFO| localhost.my.domain        : ok=8    changed=1    unreachable=0    failed=0    skipped=3    rescued=0    ignored=0
        Jul  2 15:55:32 172.16.99.106 ansible: n=ansible INFO| Starting Ansible Pull at 2026-07-02 15:55:32
        Jul  2 15:55:32 172.16.99.106 ansible: n=ansible INFO| /usr/local/bin/ansible-pull -i hosts -U git://172.16.99.21/ansible-conf-syslogng-client -d /root/ansible-conf-syslogng-client -e ai_vars=/root/ansible-vars -e ai_pull_mode=true pb-logclient.yml
        Jul  2 15:55:34 172.16.99.106 ansible: n=ansible WARNING| [WARNING]: Could not match supplied host pattern, ignoring: www-02
        Jul  2 15:55:35 172.16.99.106 ansible: n=ansible INFO| localhost.my.domain | CHANGED => {
        Jul  2 15:56:03 172.16.99.106 ansible: "e013aceca4ffe51bb9fd85ef16e1836ffdd91d5a",
        Jul  2 15:56:03 172.16.99.106 ansible: {
        Jul  2 15:56:03 172.16.99.106 ansible: "/usr/local/bin/python3.11"
        Jul  2 15:56:03 172.16.99.106 ansible:
        Jul  2 15:56:03 172.16.99.106 ansible: null,
        Jul  2 15:56:03 172.16.99.106 ansible: true
        Jul  2 15:56:03 172.16.99.106 ansible:
        Jul  2 15:55:37 172.16.99.106 ansible: n=ansible WARNING| [WARNING]: Could not match supplied host pattern, ignoring: www-02
        Jul  2 15:55:38 172.16.99.106 ansible: n=ansible INFO| PLAY [Configure Log Client.] ***************************************************
        Jul  2 15:55:38 172.16.99.106 ansible: n=ansible INFO| TASK [Include variables from ai_vars directory.] *******************************
        Jul  2 15:55:38 172.16.99.106 ansible: n=ansible INFO| ok: [localhost.my.domain] => (item=/root/ansible-vars/project-hosts.yml)
        Jul  2 15:55:38 172.16.99.106 ansible: n=ansible INFO| TASK [Display vars.] ***********************************************************
        Jul  2 15:55:38 172.16.99.106 ansible: n=ansible INFO| ok: [localhost.my.domain] =>
        Jul  2 15:56:03 172.16.99.106 ansible: |-
        Jul  2 15:56:03 172.16.99.106 ansible: true
        Jul  2 15:56:03 172.16.99.106 ansible: /root/ansible-vars
        Jul  2 15:55:56 172.16.99.106 ansible: n=ansible INFO| TASK [Install packages.] *******************************************************
        Jul  2 15:55:56 172.16.99.106 ansible: n=ansible INFO| changed: [localhost.my.domain]
        Jul  2 15:55:58 172.16.99.106 ansible: n=ansible INFO| TASK [vbotka.freebsd.postinstall : Rcconf: Configure syslogd_enable in /etc/rc.conf] ***
        Jul  2 15:55:58 172.16.99.106 ansible: n=ansible INFO| changed: [localhost.my.domain]
        Jul  2 15:55:58 172.16.99.106 ansible: n=ansible INFO| TASK [vbotka.freebsd.postinstall : Syslog-ng: Sanity fp_syslogng_conf is empty.] ***
        Jul  2 15:55:58 172.16.99.106 ansible: n=ansible INFO| ok: [localhost.my.domain]
        Jul  2 15:56:00 172.16.99.106 ansible: n=ansible INFO| TASK [vbotka.freebsd.postinstall : Syslog-ng: Configure /usr/local/etc/syslog-ng.conf] ***
        Jul  2 15:56:00 172.16.99.106 ansible: n=ansible INFO| changed: [localhost.my.domain]
        Jul  2 15:56:00 172.16.99.106 ansible: n=ansible INFO| TASK [vbotka.freebsd.postinstall : Rcconf: Configure syslog_ng_enable in /etc/rc.conf] ***
        Jul  2 15:56:00 172.16.99.106 ansible: n=ansible INFO| changed: [localhost.my.domain]
        Jul  2 15:56:02 172.16.99.106 ansible: n=ansible INFO| RUNNING HANDLER [vbotka.freebsd.postinstall : Start syslog-ng] *****************
        Jul  2 15:56:02 172.16.99.106 ansible: n=ansible INFO| changed: [localhost.my.domain]
        Jul  2 15:56:03 172.16.99.106 ansible: n=ansible INFO| RUNNING HANDLER [vbotka.freebsd.postinstall : Reload syslog-ng] ****************
        Jul  2 15:56:03 172.16.99.106 ansible: n=ansible INFO| ok: [localhost.my.domain]
        Jul  2 15:56:04 172.16.99.106 ansible: n=ansible INFO| RUNNING HANDLER [vbotka.freebsd.postinstall : Stop syslogd] ********************
        Jul  2 15:56:04 172.16.99.106 ansible: n=ansible INFO| ok: [localhost.my.domain]
        Jul  2 15:56:04 172.16.99.106 ansible: n=ansible INFO| PLAY RECAP *********************************************************************
        Jul  2 15:56:04 172.16.99.106 ansible: n=ansible INFO| localhost.my.domain        : ok=10   changed=5    unreachable=0    failed=0    skipped=19   rescued=0    ignored=0
        Jul  2 15:56:05 172.16.99.106 1 2026-07-02T15:56:05.454560+02:00 www-02 ansible-async_wrapper.py 53275 - - Module complete (53275)
        Jul  2 15:58:46 172.16.99.106 prg00000[1234]: seq: 0000000000, thread: 0000, runid: 1783000726, stamp: 2026-07-02T15:58:46 PADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADD
        Jul  2 15:58:46 172.16.99.106 1 2026-07-02T15:58:46.432755+02:00 www-02 ansible-ansible.legacy.command 57829 - - Invoked with _raw_params=loggen -i -S -n 1 172.16.99.10 514 _uses_shell=False expand_argument_vars=True stdin_add_newline=True strip_empty_ends=True cmd=None argv=None chdir=None executable=None creates=None removes=None stdin=None

        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ok: [log_server] => (item=['cat', '/var/log/remote/localhost/2026_07_02.log']) => 
    msg: |-
        Jul  2 15:58:24 localhost prg00000[1234]: seq: 0000000000, thread: 0000, runid: 1783000704, stamp: 2026-07-02T15:58:24 PADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADDPADD

        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

PLAY RECAP *********************************************************************
log_server                 : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
www_01                     : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
www_02                     : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Hint

Use the lnav utility on the log server to display all logfiles in the the directory /var/log/remote. Run the following commands on the iocage host:

shell > iocage console log-server
root@log-server:~ # lnav -r /var/log/remote/

Troubleshooting

  • See the Ansible logs /var/log/ansible.log in the jails.

shell > iocage console log-server
root@log-server:~ # cat /var/log/ansible.log
  • Update and pull the repositories. For example,

root@log-server:~ # cd /root/ansible-conf-init/
root@log-server:~/ansible-conf-init # git pull
Already up to date.
root@log-server: # cd /root/ansible-conf-syslogng-server/
root@log-server:~/ansible-conf-syslogng-server # git pull
Already up to date.
  • Start the service ansible_init

root@log-server:~ # service ansible_init start
Service ansible_init started.
Starting Ansible Pull at 2026-06-26 04:43:37
/usr/local/bin/ansible-pull -i hosts -U git://172.16.99.21/ansible-conf-init -d /root/ansible-conf-init -e ai_vars=/root/ansible-vars -e ai_pull_mode=true pb-init.yml
[WARNING]: Could not match supplied host pattern, ignoring: localhost.my.domain
[WARNING]: Could not match supplied host pattern, ignoring: log-server

...
TASK [Display vars.] ***********************************************************
ok: [localhost.my.domain] =>
    msg: |-
        ai_at:
        ai_async: True
        ai_cmd:      ansible-pull -i hosts -U git://172.16.99.21/ansible-conf-syslogng-server -d /root/ansible-conf-syslogng-server -e "ai_vars=/root/ansible-vars" -e "ai_pull_mode=true" pb-logserv.yml &&  echo '[INFO] ansible-pull finished.'

TASK [Execute command async=3600 poll=0] ***************************************
changed: [localhost.my.domain]

PLAY RECAP *********************************************************************
localhost.my.domain        : ok=8    changed=1    unreachable=0    failed=0    skipped=3    rescued=0    ignored=0

Note

The command service ansible_init start removes the the sentinel file /firstboot.

  • See the Ansible log /var/log/ansible.log. The warnings are harmless.

root@log-server:~ # cat /var/log/ansible.log
...
2026-06-26 04:31:12,561 p=21489 u=root n=ansible INFO| Starting Ansible Pull at 2026-06-26 04:31:12
2026-06-26 04:31:12,561 p=21489 u=root n=ansible INFO| /usr/local/bin/ansible-pull -i hosts -U git://172.16.99.21/ansible-conf-syslogng-server -d /root/ansible-conf-syslogng-server -e ai_vars=/root/ansible-vars -e ai_pull_mode=true pb-logserv.yml
2026-06-26 04:31:13,041 p=21491 u=root n=ansible WARNING| [WARNING]: Could not match supplied host pattern, ignoring: log-server
...
2026-06-26 04:43:45,845 p=28341 u=root n=ansible INFO| PLAY [Configure and start Log Server.] *****************************************
2026-06-26 04:43:45,880 p=28341 u=root n=ansible INFO| TASK [Include variables from ai_vars directory.] *******************************
2026-06-26 04:43:45,880 p=28341 u=root n=ansible INFO| ok: [localhost.my.domain] => (item=/root/ansible-vars/project-hosts.yml)
2026-06-26 04:43:45,922 p=28341 u=root n=ansible INFO| TASK [Display vars.] ***********************************************************
2026-06-26 04:43:45,922 p=28341 u=root n=ansible INFO| ok: [localhost.my.domain] =>
    msg: |-
        ai_pull_mode: true
        ai_vars: /root/ansible-vars

2026-06-26 04:43:50,042 p=28341 u=root n=ansible INFO| TASK [Install packages.] *******************************************************
2026-06-26 04:43:50,043 p=28341 u=root n=ansible INFO| ok: [localhost.my.domain]
2026-06-26 04:43:50,820 p=28341 u=root n=ansible INFO| TASK [vbotka.freebsd.postinstall : Rcconf: Configure syslogd_enable in /etc/rc.conf] ***
2026-06-26 04:43:50,821 p=28341 u=root n=ansible INFO| ok: [localhost.my.domain]
2026-06-26 04:43:50,919 p=28341 u=root n=ansible INFO| TASK [vbotka.freebsd.postinstall : Syslog-ng: Sanity fp_syslogng_conf is empty.] ***
2026-06-26 04:43:50,920 p=28341 u=root n=ansible INFO| ok: [localhost.my.domain]
2026-06-26 04:43:51,585 p=28341 u=root n=ansible INFO| TASK [vbotka.freebsd.postinstall : Syslog-ng: Configure /usr/local/etc/syslog-ng.conf] ***
2026-06-26 04:43:51,586 p=28341 u=root n=ansible INFO| ok: [localhost.my.domain]
2026-06-26 04:43:51,955 p=28341 u=root n=ansible INFO| TASK [vbotka.freebsd.postinstall : Rcconf: Configure syslog_ng_enable in /etc/rc.conf] ***
2026-06-26 04:43:51,955 p=28341 u=root n=ansible INFO| ok: [localhost.my.domain]
2026-06-26 04:43:52,004 p=28341 u=root n=ansible INFO| PLAY RECAP *********************************************************************
2026-06-26 04:43:52,004 p=28341 u=root n=ansible INFO| localhost.my.domain        : ok=7    changed=0    unreachable=0    failed=0    skipped=19   rescued=0    ignored=0