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

ansible_facts.services not reporting on user systemd services #79410

Open
1 task done
gg-g opened this issue Nov 18, 2022 · 2 comments
Open
1 task done

ansible_facts.services not reporting on user systemd services #79410

gg-g opened this issue Nov 18, 2022 · 2 comments
Labels
affects_2.15 feature This issue/PR relates to a feature request. waiting_on_contributor This would be accepted but there are no plans to actively work on it.

Comments

@gg-g
Copy link

gg-g commented Nov 18, 2022

Summary

ansible_facts.services does not report on user systemd services.

Issue Type

Feature Request

Component Name

ansible_facts.services

Ansible Version

$ ansible --version

ansible [core 2.11.12]
  config file = /home/ansible/ansible.cfg
  configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ansible/p3_ansible/lib64/python3.6/site-packages/ansible
  ansible collection location = /home/ansible/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/ansible/p3_ansible/bin/ansible
  python version = 3.6.8 (default, Jun 14 2022, 12:54:58) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10)]
  jinja version = 3.0.3
  libyaml = True

Configuration

# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed

DEPRECATION_WARNINGS(/home/ansible/ansible.cfg) = False

OS / Environment

Red Hat Enterprise Linux release 8.6 (Ootpa)

Steps to Reproduce

I have an elasticsearch running as systemd user service on a target system:


$ systemctl --user status elasticsearch.service
● elasticsearch.service - Elasticsearch
   Loaded: loaded (/home/elastic/.config/systemd/user/elasticsearch.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2022-11-18 08:50:10 CET; 9min ago
     Docs: https://www.elastic.co
  Process: 1294187 ExecStart=/opt/elasticsearch/current/bin/elasticsearch -d -p ${PID_DIR}/elasticsearch.pid (code=exited, status=0/SUCCESS)
 Main PID: 1294265 (java)
...

I defined tasks to check if it is present in the list of enabled systemd services.

- name: Populate service facts
  ansible.builtin.service_facts:

# this one we see
- name: Print service facts
  ansible.builtin.debug:
    var: ansible_facts.services['NetworkManager.service']

# this one we don't
- name: Print service facts
  ansible.builtin.debug:
    var: ansible_facts.services['elasticsearch.service']

Expected Results

I expected my user service elasticsearch.service to be included in service_facts

Actual Results

TASK [elasticsearch : Populate service facts] ******************************************************************************************************************************************************
ok: [dwp-els-01-d.cc.cec.eu.int]

TASK [elasticsearch : Print service facts] *********************************************************************************************************************************************************
ok: [dwp-els-01-d.cc.cec.eu.int] => {
    "ansible_facts.services['NetworkManager.service']": {
        "name": "NetworkManager.service",
        "source": "systemd",
        "state": "stopped",
        "status": "not-found"
    }
}

TASK [elasticsearch : Print service facts] *********************************************************************************************************************************************************
ok: [dwp-els-01-d.cc.cec.eu.int] => {
    "ansible_facts.services['elasticsearch.service']": "VARIABLE IS NOT DEFINED!"
}

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibot
Copy link
Contributor

ansibot commented Nov 18, 2022

Files identified in the description:
None

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.11 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. labels Nov 18, 2022
@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label Nov 29, 2022
@mkrizek
Copy link
Contributor

mkrizek commented Nov 29, 2022

Changing this to a feature request.

@mkrizek mkrizek added feature This issue/PR relates to a feature request. and removed bug This issue/PR relates to a bug. labels Nov 29, 2022
@bcoca bcoca added the waiting_on_contributor This would be accepted but there are no plans to actively work on it. label Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.15 feature This issue/PR relates to a feature request. waiting_on_contributor This would be accepted but there are no plans to actively work on it.
Projects
None yet
Development

No branches or pull requests

5 participants