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

Add openrc support to service_facts #76373

Merged
merged 3 commits into from Dec 9, 2021

Conversation

clementmartin
Copy link
Contributor

@clementmartin clementmartin commented Nov 26, 2021

SUMMARY

Add openrc support to service_facts module.

The service module supports openrc, but the service_facts doesn't, making it unusable on for example alpine linux.

As in openrc, services are configured by runlevels, instead of using status enabled/disabled, I chose to include the configure runlevels, or None if there isn't any reported.

Services can be added to multiple runlevels, so this is reported as an array.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

service_facts

ADDITIONAL INFORMATION

Using the following playbook:

---
- hosts: all
  become: false
  tasks:
    - service_facts:
      become: true

    - debug: var=ansible_facts.services

Before:

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [alpine]

TASK [service_facts] ***********************************************************
skipping: [alpine]

TASK [debug] *******************************************************************
ok: [alpine] => {
    "ansible_facts.services": "VARIABLE IS NOT DEFINED!"
}

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

After:

PLAY [all] *********************************************************************                                                                                                                                                  [394/15332]

TASK [Gathering Facts] *********************************************************
ok: [alpine]

TASK [service_facts] ***********************************************************
ok: [alpine]

TASK [debug] *******************************************************************
ok: [alpine] => {
    "ansible_facts.services": {
        "acpid": {
            "name": "acpid",
            "runlevels": [
                "default"
            ],
            "source": "openrc",
            "state": "started"
        },
        "agetty": {
            "name": "agetty",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "binfmt": {
            "name": "binfmt",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "bootmisc": {
            "name": "bootmisc",
            "runlevels": [
                "boot"
            ],
            "source": "openrc",
            "state": "started"
        },
        "cgroups": {
            "name": "cgroups",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "consolefont": {                                                                                                                                                                                                          [349/15332]
            "name": "consolefont",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "crond": {
            "name": "crond",
            "runlevels": [
                "default"
            ],
            "source": "openrc",
            "state": "started"
        },
        "devfs": {
            "name": "devfs",
            "runlevels": [
                "sysinit"
            ],
            "source": "openrc",
            "state": "started"
        },
        "dmesg": {
            "name": "dmesg",
            "runlevels": [
                "sysinit"
            ],
            "source": "openrc",
            "state": "started"
        },
        "dnsd": {
            "name": "dnsd",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "firstboot": {
            "name": "firstboot",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "fsck": {
            "name": "fsck",
            "runlevels": null,
            "source": "openrc",
            "state": "started"
        },
        "haveged": {                                                                                                                                                                                                              [301/15332]
            "name": "haveged",
            "runlevels": [
                "default"
            ],
            "source": "openrc",
            "state": "started"
        },
        "hostname": {
            "name": "hostname",
            "runlevels": [
                "boot"
            ],
            "source": "openrc",
            "state": "started"
        },
        "httpd": {
            "name": "httpd",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "hwclock": {
            "name": "hwclock",
            "runlevels": [
                "boot"
            ],
            "source": "openrc",
            "state": "started"
        },
        "hwdrivers": {
            "name": "hwdrivers",
            "runlevels": [
                "sysinit"
            ],
            "source": "openrc",
            "state": "started"
        },
        "inetd": {
            "name": "inetd",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "killprocs": {                                                                                                                                                                                                            [257/15332]
            "name": "killprocs",
            "runlevels": [
                "shutdown"
            ],
            "source": "openrc",
            "state": "stopped"
        },
        "klogd": {
            "name": "klogd",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "kmod-static-nodes": {
            "name": "kmod-static-nodes",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "loadkmap": {
            "name": "loadkmap",
            "runlevels": [
                "boot"
            ],
            "source": "openrc",
            "state": "started"
        },
        "local": {
            "name": "local",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "localmount": {
            "name": "localmount",
            "runlevels": null,
            "source": "openrc",
            "state": "started"
        },
        "loopback": {
            "name": "loopback",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "machine-id": {                                                                                                                                                                                                           [211/15332]
            "name": "machine-id",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "mdev": {
            "name": "mdev",
            "runlevels": [
                "sysinit"
            ],
            "source": "openrc",
            "state": "started"
        },
        "modloop": {
            "name": "modloop",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "modules": {
            "name": "modules",
            "runlevels": [
                "boot"
            ],
            "source": "openrc",
            "state": "started"
        },
        "mount-ro": {
            "name": "mount-ro",
            "runlevels": [
                "shutdown"
            ],
            "source": "openrc",
            "state": "stopped"
        },
        "mtab": {
            "name": "mtab",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "net-online": {                                                                                                                                                                                                           [169/15332]
            "name": "net-online",
            "runlevels": [
                "default"
            ],
            "source": "openrc",
            "state": "started"
        },
        "netmount": {
            "name": "netmount",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "network": {
            "name": "network",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "networking": {
            "name": "networking",
            "runlevels": [
                "boot"
            ],
            "source": "openrc",
            "state": "started"
        },
        "ntpd": {
            "name": "ntpd",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "numlock": {
            "name": "numlock",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "openntpd": {
            "name": "openntpd",
            "runlevels": [
                "default"
            ],
            "source": "openrc",
            "state": "crashed"
        },
        "osclock": {                                                                                                                                                                                                              [121/15332]
            "name": "osclock",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "procfs": {
            "name": "procfs",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "qemu-guest-agent": {
            "name": "qemu-guest-agent",
            "runlevels": [
                "default"
            ],
            "source": "openrc",
            "state": "started"
        },
        "rdate": {
            "name": "rdate",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "root": {
            "name": "root",
            "runlevels": null,
            "source": "openrc",
            "state": "started"
        },
        "runsvdir": {
            "name": "runsvdir",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "s6-svscan": {
            "name": "s6-svscan",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "save-keymaps": {                                                                                                                                                                                                          [77/15332]
            "name": "save-keymaps",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "save-termencoding": {
            "name": "save-termencoding",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "savecache": {
            "name": "savecache",
            "runlevels": [
                "shutdown"
            ],
            "source": "openrc",
            "state": "stopped"
        },
        "sshd": {
            "name": "sshd",
            "runlevels": [
                "default"
            ],
            "source": "openrc",
            "state": "started"
        },
        "staticroute": {
            "name": "staticroute",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "swap": {
            "name": "swap",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "swclock": {
            "name": "swclock",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "sysctl": {                                                                                                                                                                                                                [31/15332]
            "name": "sysctl",
            "runlevels": [
                "boot"
            ],
            "source": "openrc",
            "state": "started"
        },
        "sysfs": {
            "name": "sysfs",
            "runlevels": null,
            "source": "openrc",
            "state": "started"
        },
        "sysfsconf": {
            "name": "sysfsconf",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "syslog": {
            "name": "syslog",
            "runlevels": [
                "boot"
            ],
            "source": "openrc",
            "state": "started"
        },
        "termencoding": {
            "name": "termencoding",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "udhcpd": {
            "name": "udhcpd",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "urandom": {
            "name": "urandom",
            "runlevels": [
                "boot"
            ],
            "source": "openrc",
            "state": "started"
        },
        "utmpd": {
            "name": "utmpd",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "watchdog": {
            "name": "watchdog",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        },
        "wtmpd": {
            "name": "wtmpd",
            "runlevels": null,
            "source": "openrc",
            "state": "stopped"
        }
    }
}

PLAY RECAP *********************************************************************
alpine                     : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

@ansibot ansibot added affects_2.13 core_review In order to be merged, this PR must follow the core review workflow. feature This issue/PR relates to a feature request. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. new_contributor This PR is the first contribution by a new community member. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Nov 26, 2021
Copy link
Member

@bcoca bcoca left a comment

Choose a reason for hiding this comment

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

A changelog is required, I'm not going to ask for tests since most of our images won't run openrc

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Nov 30, 2021
clementmartin pushed a commit to clementmartin/ansible that referenced this pull request Nov 30, 2021
@ansibot ansibot added the needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. label Nov 30, 2021
@ansibot
Copy link
Contributor

ansibot commented Nov 30, 2021

The test ansible-test sanity --test package-data [explain] failed with the error:

Command "/root/.ansible/test/venv/sanity.package-data/3.10/ed96082c/bin/python /root/ansible/test/sanity/code-smell/package-data.py" returned exit status 1.
>>> Standard Error
Traceback (most recent call last):
  File "/root/ansible/test/sanity/code-smell/package-data.py", line 401, in <module>
    main()
  File "/root/ansible/test/sanity/code-smell/package-data.py", line 378, in main
    sdist_path = create_sdist(tmp_dir)
  File "/root/ansible/test/sanity/code-smell/package-data.py", line 185, in create_sdist
    raise Exception('make snapshot failed:\n%s' % stderr)
Exception: make snapshot failed:
docs/man/man1/ansible-console.1.rst:46: (WARNING/2) Bullet list ends without a blank line; unexpected unindent.
Traceback (most recent call last):
  File "/root/.ansible/test/venv/sanity.package-data/3.10/ed96082c/lib/python3.10/site-packages/antsibull_changelog/cli.py", line 239, in run
    return arguments.func(arguments)
  File "/root/.ansible/test/venv/sanity.package-data/3.10/ed96082c/lib/python3.10/site-packages/antsibull_changelog/cli.py", line 458, in command_release
    add_release(
  File "/root/.ansible/test/venv/sanity.package-data/3.10/ed96082c/lib/python3.10/site-packages/antsibull_changelog/changes.py", line 943, in add_release
    changes.save()
  File "/root/.ansible/test/venv/sanity.package-data/3.10/ed96082c/lib/python3.10/site-packages/antsibull_changelog/changes.py", line 150, in save
    self.sort()
  File "/root/.ansible/test/venv/sanity.package-data/3.10/ed96082c/lib/python3.10/site-packages/antsibull_changelog/changes.py", line 619, in sort
    config['changes'] = {
  File "/root/.ansible/test/venv/sanity.package-data/3.10/ed96082c/lib/python3.10/site-packages/antsibull_changelog/changes.py", line 620, in <dictcomp>
    section: sorted(entries) if section != self.config.prelude_name else entries
TypeError: '<' not supported between instances of 'str' and 'dict'
make: *** [Makefile:143: changelog] Error 1

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

changelogs/fragments/76373-add-openrc-support-to-service_facts.yaml:0:0: section "minor_changes" list items must be type str not dict

click here for bot help

@ansibot ansibot removed the needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. label Nov 30, 2021
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Nov 30, 2021
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Nov 30, 2021
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Dec 1, 2021
@nitzmahone nitzmahone added P3 Priority 3 - Approved, No Time Limitation and removed needs_triage Needs a first human triage before being processed. labels Dec 2, 2021
@bcoca bcoca merged commit bc753c0 into ansible:devel Dec 9, 2021
bcoca pushed a commit to bcoca/ansible that referenced this pull request Dec 15, 2021
* Add openrc support to service_facts

Co-authored-by: Clément Martin <clement.martin@onespan.com>
@ansible ansible locked and limited conversation to collaborators Dec 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.13 core_review In order to be merged, this PR must follow the core review workflow. feature This issue/PR relates to a feature request. module This issue/PR relates to a module. new_contributor This PR is the first contribution by a new community member. P3 Priority 3 - Approved, No Time Limitation 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

4 participants