Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module_utils_service: Fix glob path of rc.d for SUSE #43018

Merged
merged 1 commit into from Jul 31, 2018

Conversation

alxgu
Copy link
Contributor

@alxgu alxgu commented Jul 19, 2018

SUMMARY

The service module reports always a changed message when you set "enabled: true" for a service e.g. ntp.

FIX:
SUSE has the rc%.d directories under /etc/init.d
Set the glob path to /etc/init.d on SLES.

Quote of /etc/rc.d.README on SLES11.

"Some people expect the system startup scripts in /etc/rc.d/.
We use a slightly different structure for better LSB compliance."

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

module_utils/service.py

ANSIBLE VERSION
ansible 2.7.0.dev0 (service_utils_sysv f8a64807dc) last updated 2018/07/19 12:37:40 (GMT +000)
ADDITIONAL INFORMATION

OS / ENVIRONMENT

SLES11
before:
srv1~] :)$ chkconfig ntp
ntp  on
srv0: ansible -m service -a "name=ntp enabled=true" srv1 -b -D

srv1| SUCCESS => {
    "changed": true,
    "name": "ntp",
    "status": {
        "enabled": {
            "changed": true,
            "rc": 0,
            "stderr": "",
            "stdout": ""
        },
        "null": {
            "changed": false,
            "rc": null,
            "stderr": null,
            "stdout": null
        }
    }
}

after:
srv1~] :)$ chkconfig ntp
srv0: ansible -m service -a "name=ntp enabled=true" srv1 -b -D
srv1| SUCCESS => {
    "changed": false,
    "name": "ntp",
    "status": {
        "enabled": {
            "changed": false,
            "rc": null,
            "stderr": null,
            "stdout": null
        },
        "null": {
            "changed": false,
            "rc": null,
            "stderr": null,
            "stdout": null
        }
    }
}

@ansibot ansibot added affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. small_patch support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Jul 19, 2018
@ansibot
Copy link
Contributor

ansibot commented Jul 19, 2018

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/module_utils/service.py:52:14: E111 indentation is not a multiple of four

click here for bot help

@ansibot ansibot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Jul 19, 2018
@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Jul 19, 2018
@samdoran
Copy link
Contributor

cc @bcoca

@samdoran samdoran removed the needs_triage Needs a first human triage before being processed. label Jul 19, 2018
return bool(glob.glob('/etc/rc%s.d/S??%s' % (runlevel, name)))
else:
if "SUSE" in platform.dist()[0].upper():
return bool(glob.glob('/etc/init.d/rc?.d/S??%s' % name))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, for old suse this might not work and others that derive from suse might have same issue, lets use it as a fallback location in general

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SLES11 is "oldest" supported version. SLES10 has python2.4 - ansible will exit immediately with

SyntaxError: future feature absolute_import is not defined

Should I change the commit like:

if not os.path.isdir('/etc/rc0.d/'):
    return bool(glob.glob('/etc/init.d/rc?.d/S??%s' % name))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/me hides his sles8 box

Still, for other derivatives, it would still be better to not gate it specifically to 'SUSE' dist

@alxgu
Copy link
Contributor Author

alxgu commented Jul 23, 2018

@bcoca Changed to a more generic fix

@ansibot ansibot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Jul 23, 2018
@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Jul 23, 2018
@alxgu
Copy link
Contributor Author

alxgu commented Jul 30, 2018

shipit

@samdoran
Copy link
Contributor

@alxgu Please create a changelog fragment. See fragments for examples.

Some distribtuions like SUSE has the rc%.d directories under /etc/init.d

Quote of /etc/rc.d.README on SLES11.

"Some people expect the system startup scripts in /etc/rc.d/.
We use a slightly different structure for better LSB compliance."
@alxgu
Copy link
Contributor Author

alxgu commented Jul 31, 2018

@samdoran done

@samdoran samdoran merged commit 29a6203 into ansible:devel Jul 31, 2018
@samdoran
Copy link
Contributor

Please create a backport PR for this to be included in previous versions.

@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants