8000 FreeBSD service arguments are passed in the wrong order · Issue #85156 · ansible/ansible · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
FreeBSD service arguments are passed in the wrong order #85156
Open
@Shadow53

Description

@Shadow53

Summary

Same as #73731, which is locked. Extra arguments are passed to FreeBSD's service in the wrong order, causing an invalid command.

The current code:

# e.g., service jail_name jail restart
ret = self.execute_command("%s %s %s %s" % (self.svc_cmd, self.arguments, self.name, self.action))

What it should be:

# e.g., service jail restart jail_name
ret = self.execute_command("%s %s %s %s" % (self.svc_cmd, self.name, self.action, self.arguments))

Note that there are flags supported by service, which would go in the current position. Perhaps the better option is supporting both flags and arguments?

From man 8 service:

     The options are as follows:

     -E var=value
         Set the environment variable var to the specified value before
         starting the script.  This option can be used multiple times.

     -e  List services that are enabled.  The list of scripts to check is
         compiled using rcorder(8) the same way that it is done in rc(8), then
         that list of scripts is checked for an "rcvar" assignment.  If
         present the script is checked to see if it is enabled.

     -j jail
         Perform the given actions under the named jail.  The jail argument
         can be either a jail ID or a jail name.

     -l  List all files in /etc/rc.d and the local startup directories.  As
         described in rc.conf(5) this is usually /usr/local/etc/rc.d.  All
         files will be listed whether they are an actual rc.d script or not.

     -R  Restart all enabled local services.

     -r  Generate the rcorder(8) as in -e above, but list all of the files,
         not just what is enabled.

     -v  Be slightly more verbose.

Issue Type

Bug Report

Component Name

lib/ansible/modules/service.py

Ansible Version

ansible [core 2.18.3]
  config file = /home/common/Development/freebsd/homelab/jail-management/ansible.cfg
  configured module search path = ['/home/fedora-kde/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.13/site-packages/ansible
  ansible collection location = /home/fedora-kde/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.13.3 (main, Apr  9 2025, 00:00:00) [GCC 15.0.1 20250410 (Red Hat 15.0.1-0)] (/usr/bin/python3)
  jinja version = 3.1.6
  libyaml = True

Configuration

CONFIG_FILE() = /home/common/Development/freebsd/homelab/jail-management/ansible.cfg
DEFAULT_CONNECTION_PLUGIN_PATH(/home/common/Development/freebsd/homelab/jail-management/ansible.cfg) = ['/home/common/Development/freebsd/homelab/jail-management/connection/sshjail']
DEFAULT_HOST_LIST(/home/common/Development/freebsd/homelab/jail-management/ansible.cfg) = ['/home/common/Development/freebsd/homelab/jail-management/inventory.yml']
DEFAULT_ROLES_PATH(/home/common/Development/freebsd/homelab/jail-management/ansible.cfg) = ['/home/common/Development/freebsd/homelab/jail-management/roles']
EDITOR(env: EDITOR) = /usr/bin/nano
PLAYBOOK_DIR(/home/common/Development/freebsd/homelab/jail-management/ansible.cfg) = /home/common/Development/freebsd/homelab/jail-management/playbook

GALAXY_SERVERS:

OS / Environment

Local: Fedora 42
Remote: FreeBSD 14.2-RELEASE

Steps to Reproduce

# Task, to be used with a FreeBSD target
- name: Restart loopback interface
  ansible.builtin.service:
    name: netif
    state: restarted
    arguments: lo0

Expected Results

I expect the lo0 network interface to be restarted using the netif service.

Actual Results

homelab | FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/local/bin/python3.11"
    },
    "changed": false,
    "invocation": {
        "module_args": {
            "arguments": "lo0",
            "enabled": null,
            "name": "netif",
            "pattern": null,
            "runlevel": "default",
            "sleep": null,
            "state": "restarted"
        }
    },
    "msg": "lo0 does not exist in /etc/rc.d or the local startup\ndirectories (/usr/local/etc/rc.d), or is not executable\n"
}

Code of Conduct

  • I agree to follow the Ansible Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects_2.18bugThis issue/PR relates to a bug.has_prThis issue has an associated PR.moduleThis issue/PR relates to a module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0