Hi all,

I am trying to setup zookeeper using ansible with docker, I have copied the 
zookeeper.service to /usr/lib/systemd/system, however when I run molecule 
test to test my ansible code, it always fail.

My zookeeper.service looks like following:
[Unit]
Requires=network.target remote-fs.target
After=network.target remote-fs.target

[Service]
Type=simple
#User=kafka
ExecStart=/opt/kafka_2.11-2.0.0/bin/zookeeper-server-start.sh 
/opt/kafka_2.11-2.0.0/config/zookeeper.properties
ExecStop=/opt/kafka_2.11-2.0.0/bin/zookeeper-server-stop.sh
Restart=on-abnormal

[Install]
WantedBy=multi-user.target


My ansible script as follow:
---
- name: Check if Zookeeper service file exists
  stat:
    path: /usr/lib/systemd/system/zookeeper.service
  register: zookeeper_service_exist

- name: Copy zookeeper service file to /usr/lib/systemd/system/
  copy:
    src: files/zookeeper.service
    dest: /usr/lib/systemd/system/
    mode: 0755
  when: not zookeeper_service_exist.stat.exists

- name: Start Zookeeper service if not started
  systemd:
    name: zookeeper
    state: started

I always receive the following error:
   fatal: [kafka-deploy]: FAILED! => {
        "changed": false,
        "cmd": "/bin/systemctl",
        "invocation": {
            "module_args": {
                "daemon_reload": false,
                "enabled": null,
                "force": null,
                "masked": null,
                "name": "zookeeper",
                "no_block": false,
                "scope": null,
                "state": "started",
                "user": null
            }
        },
        "msg": "Failed to get D-Bus connection: Operation not permitted",
        "rc": 1,
        "stderr": "Failed to get D-Bus connection: Operation not 
permitted\n",
        "stderr_lines": [
            "Failed to get D-Bus connection: Operation not permitted"
        ],
        "stdout": "",
        "stdout_lines": []
    }

Hope someone can help me with this.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f26fab5c-e7c7-4ebd-a5af-b46a012cb211%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to