Description
Summary
I want to reboot a group of servers that host a website. But Server startup takes a while so I need to wait on the service and then a few extra seconds.
service tomcat10 status | grep "startup in" && sleep 30
works well for this but it took way too much time to figure out how to format the test_command paramenter to work as an ad-hoc command run through ansible
.
Issue Type
Bug Report
Component Name
reboot
Ansible Version
$ ansible --version
ansible [core 2.18.6]
config file = /root/.ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /root/.local/share/pipx/venvs/ansible-core/lib/python3.12/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /root/.local/bin/ansible
python version = 3.12.3 (main, Feb 4 2025, 14:48:35) [GCC 13.3.0] (/root/.local/share/pipx/venvs/ansible-core/bin/python)
jinja version = 3.1.4
libyaml = True
Configuration
# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = /root/.ansible.cfg
DEFAULT_HOST_LIST(/root/.ansible.cfg) = ['/root/workspace/ansible/inventory']
DEFAULT_STDOUT_CALLBACK(/root/.ansible.cfg) = community.general.unixy
INTERPRETER_PYTHON(/root/.ansible.cfg) = auto_silent
GALAXY_SERVERS:
OS / Environment
Ubuntu 24.04.2 LTS (Noble Numbat)
Steps to Reproduce
The following is an ad-hoc command using the reboot-module, adhering to standard Unix-like variable quoting rules.
ansible -m ansible.builtin.reboot -a test_command='service tomcat10 status|grep "startup in" && sleep 30s' -f 1 -o test_idp
Expected Results
Reboot and use my specified test_command
to determine successful reboot.
Actual Results
ERROR! this task 'ansible.builtin.reboot' has extra params, which is only allowed in the following modules: command, shell, win_command, include_tasks, import_tasks, win_shell, raw, add_host, script, include_vars, include_role, import_role, meta, group_by, set_fact
What I actually have to do to make it work is the following:
ansible -m ansible.builtin.reboot -a 'test_command="service tomcat10 status|grep \"startup in\" && sleep 30s"' -f 1 -o test_idp
The handling of ansible -a
paramenters need to be reworked or at least clarified in the documentation.
At the very least, the error-message about extra params seems wrong.
### Code of Conduct
- [x] I agree to follow the Ansible Code of Conduct