Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible service task fails with "Could not find the requested service XXX"

Tags:

I am trying to create ansible playbooks to install and configure kerberos on centos7.

I have a task which yum installs the required rpms

- name: install kerberos
  yum: name={{ item }} state=present
  with_items:
    - krb5-server
    - krb5-libs

And a task to start the service

- name: start kerberos service
  service: name=krb5kdc.service state=started enabled=yes

The playbook fails with

TASK [kerberos : start the systemd kerberos service]  ********************************
fatal: [zen_wozniak]: FAILED! => {"changed": false, "msg": "Could not find the requested service krb5kdc.service: host"}

This seems like it should be pretty simple, yum install the rpm and then start the service, but the service unit file cant even be found. what am I doing wrong?

For clarity I am using ansible 2.4.2.0 and centos:7.3.1611 docker base image.

edit:: The yum install step is working...

TASK [kerberos : debug] ***********************************************************************************************
ok: [brave_payne] => {
"result": {
    "changed": false,
    "failed": false,
    "results": [
        {
            "arch": "x86_64",
            "envra": "0:krb5-server-1.15.1-8.el7.x86_64",
            "epoch": "0",
            "name": "krb5-server",
            "release": "8.el7",
            "repo": "base",
            "version": "1.15.1",
            "yumstate": "available"
        },
        {
            "arch": "x86_64",
            "envra": "0:krb5-server-1.15.1-8.el7.x86_64",
            "epoch": "0",
            "name": "krb5-server",
            "release": "8.el7",
            "repo": "installed",
            "version": "1.15.1",
            "yumstate": "installed"
        }
    ]
}
}

Logging into the the failed ansible container and manually starting looks like this

    [root@94e29c0e8bdd /]# systemctl status krb5kdc.service
Failed to get D-Bus connection: Operation not permitted

And yes the container is running privileged

docker inspect --format='{{.HostConfig.Privileged}}' 94e29c0e8bdd
true
like image 738
ayyrex Avatar asked Mar 02 '18 03:03

ayyrex


1 Answers

UPDATE:

With Ansible systemd module, you can add: daemon_reload: yes


ORIGINAL ANSWER:

It looks like a random issue. The workaround is to run from the machine:

  • systemctl daemon-reload .

Or to run it with Ansible:

  • ansible <host> --become -m shell -a 'systemctl daemon-reload'
like image 78
forzagreen Avatar answered Oct 22 '22 09:10

forzagreen