-
Notifications
You must be signed in to change notification settings - Fork 45
Description
Problem:
Role fails at the "Determine current NTP provider" stage:
TASK [fedora.linux_system_roles.timesync : Determine current NTP provider] ***************************************************************
fatal: [hex.lan]: FAILED! => {"changed": false, "module_stderr": "Shared connection to hex.lan closed.\r\n", "module_stdout": "/var/home/bblasco/.ansible/tmp/ansible-tmp-1769734063.0693882-189237-16933141090487/AnsiballZ_timesync_provider.sh: line 9: runlevel: command not found\r\n{\"ansible_facts\": {\"timesync_ntp_provider_current\": \"chrony\"}}\u001b]3008;end=99235c20f92644d3ad8d663269ec8595\u001b\\", "msg": "MODULE FAILURE: No end of json char found\nSee stdout/stderr for the exact error", "rc": 0}
The verbose output is attached as error.txt
Cause:
From the above we can see the error:
runlevel: command not found
If I check the Fedora 43 bootc system manually:
[bblasco@hex ~]$ cat /etc/fedora-release
Fedora release 43 (Forty Three)
[bblasco@hex ~]$ runlevel
-bash: runlevel: command not found
But if I run it on a Fedora 42 bootc system:
[bblasco@micro ~]$ cat /etc/fedora-release
Fedora release 42 (Adams)
[bblasco@micro ~]$ runlevel
N 3
Code snippet with the problem
I found the code in the file timesync_provider.sh, specifically this snippet:
is_service_enabled() {
local name runlevel prev_runlevel
name="$1"
# shellcheck disable=SC2034
read -r prev_runlevel runlevel < <(runlevel)
systemctl is-enabled "$name.service" &> /dev/null || \
chkconfig --list "$name" 2>/dev/null | grep -q "$runlevel:on"
}
If I understand the code correctly the runlevel code only matters if the system doesn't have systemctl (ie uses systemd), so it's actually failing at the following line:
read -r prev_runlevel runlevel < <(runlevel)
The output of that line is then used for the grep command in the following line:
systemctl is-enabled "$name.service" &> /dev/null || \
chkconfig --list "$name" 2>/dev/null | grep -q "$runlevel:on"
How to fix
Good question!
I tried removing anything relating to runlevel and just populating the vars manually for the purposes of my own testing:
is_service_enabled() {
local name runlevel prev_runlevel
name="$1"
prev_runlevel="N"
runlevel="3"
# shellcheck disable=SC2034
# read -r prev_runlevel runlevel < <(runlevel)
systemctl is-enabled "$name.service" &> /dev/null # || \
# chkconfig --list "$name" 2>/dev/null | grep -q "$runlevel:on"
}
But then I get this error (which I don't really understand) instead:
TASK [fedora.linux_system_roles.timesync : Determine current NTP provider] ***************************************************************
fatal: [hex.lan]: FAILED! => {"changed": false, "module_stderr": "Shared connection to hex.lan closed.\r\n", "module_stdout": "{\"ansible_facts\": {\"timesync_ntp_provider_current\": \"chrony\"}}\u001b]3008;end=58517a9662d14e8e97b8aa5b3b4060a6\u001b\\", "msg": "MODULE FAILURE: No end of json char found\nSee stdout/stderr for the exact error", "rc": 0}
Running the playbook in verbose mode I get the output in the attached troubleshoot.txt
Software versions
Control node:
fedoralaptop on master [!?] via 🐍 v3.14.2
❯ ansible --version
ansible [core 2.18.12]
config file = /var/home/bblasco/git/fedoralaptop/ansible.cfg
configured module search path = ['/var/home/bblasco/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.14/site-packages/ansible
ansible collection location = /var/home/bblasco/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.14.2 (main, Dec 5 2025, 00:00:00) [GCC 15.2.1 20251111 (Red Hat 15.2.1-4)] (/usr/bin/python3)
jinja version = 3.1.6
libyaml = True
fedoralaptop on master [!?] via 🐍 v3.14.2
❯ cat /etc/fedora-release
Fedora release 43 (Forty Three)
fedoralaptop on master [!?] via 🐍 v3.14.2
❯ python --version
Python 3.14.2
fedoralaptop on master [!?] via 🐍 v3.14.2
❯
Node being automated
[bblasco@hex ~]$ cat /etc/fedora-release
Fedora release 43 (Forty Three)
[bblasco@hex ~]$ python --version
Python 3.14.2
Please let me know what other info you need