Ansible fails to start services

39 views
Skip to first unread message

Borja Salamanca Dominguez

unread,
May 27, 2019, 11:13:17 AM5/27/19
to Ansible Project
Hello Ansible Group, i recently had problems while i try to launch any services via Ansible playbook.
I sent via Ansible these services to etc/systemd/system/zookeeper.services and /etc/systemd/system/kafka.services

zookeeper.service:

[Unit]
Description=Apache Zookeeper server (Kafka)
Documentation=http://zookeeper.apache.org
Requires=network.target remote-fs.target
After=network.target remote-fs.target

[Service]
User=borja
ExecStart=/home/borja/inventory/Innovery/zookeeper/bin/zkServer.sh start /home/borja/inventory/Innovery/zookeeper/config/zookeeper.properties
ExecStop=/home/borja/inventory/Innovery/zookeeper/bin/zkServer.sh stop 

[Install]
WantedBy=multi-user.target



kafka.service:

[Unit]
Description=Apache Kafka server (broker)
Documentation=http://kafka.apache.org/documentation.html
Requires=network.target remote-fs.target
After=network.target remote-fs.target

[Service]
User=borja
ExecStart=/home/borja/inventory/Innovery/Kafka/bin/kafka-server-start.sh /home/borja/inventory/Innovery/Kafka/config/server.properties
ExecStop=/home/borja/inventory/Innovery/Kafka/bin/kafka-server-stop.sh

[Install]
WantedBy=multi-user.target



The Kafka/Zookeeper installation procedure consists in decompress kafka .tar.gz file and zookeeper .tar.gz file.
Looks like it doesn't work at all, the services never start via Ansible on the remote machine, but if i launch these services on the remote machine they work perfectly.
It is making me crazy! Any help?

Thanks, Ansible Group.



Jonathan Lozada De La Matta

unread,
May 27, 2019, 11:16:09 AM5/27/19
to ansible...@googlegroups.com
how are you starting the services and what comes up qhen you it with -vvvv ? a lot of services after a file change lile this require a daemon-reload

Jonathan Lozada De La Matta on mobile
 

From: ansible...@googlegroups.com on behalf of Borja Salamanca Dominguez <borja....@gmail.com>
Sent: Monday, May 27, 2019 11:13 AM
To: Ansible Project
Subject: [ansible-project] Ansible fails to start services
 
--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/607ee173-0b70-4052-862c-a2053425081d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Borja Salamanca Dominguez

unread,
May 28, 2019, 3:05:43 AM5/28/19
to Ansible Project
I tried sending an .sh file to the remote machine with the needed commands and launching it:

#!/bin/bash
nohup bin/zookeeper-server-start.sh config/zookeeper.properties &
nohup bin/kafka-server-start.sh config/server.properties &


If i launch this .sh on the remote machine manually, it works but it doesn't work if i do it via Ansible playbook with this task:
Anything that i try manually works perfectly.

- name: starting service via .sh
  shell: /path/to/remoteserver/sh_location/start_service.sh

I tried using command module instead. Doesn't work either.

When the service is on the remote server, i tried to launch with these tasks, they give the same output error (Connection Timed Out):
Before launching these tasks i have a daemon reload task, but doesn't matter which task, the first one that references any service will give the same error.
So if i launch the daemon reload task first, it will fail. If i skip this reload, the next one will fail.

- name: starting service via Systemd module
  systemd:
  name: zookeeper.service
  no_block: yes
  state: started
  daemon_reload: yes

- name: starting services via service module
  service:
  state: started
  name: zookeeper.service

- name: starting service launching a raw command on the remote server
  shell: 'systemctl start zookeeper.service'

All these tasks where tested with kafka.service too.
(Kafka needs Zookeeper to be operative first)

Since i tried multiple times by different ways to get the same output error, i modified the timeout attribute inside ansible.cfg, increasing it from the default values.
This changes didn't fix the problem.

I also tried to start the service via sh having this command in the .sh file: systemctl start zookeeper.service but this doesn't get the job done.

The -vvvv option give this output:

fatal: [172.22.1.96]: FAILED! => {
    "changed": true,
    "cmd": "/home/borja/inventory/Innovery/Zookeeper/launchService.sh",
    "delta": "0:00:25.044432",
    "end": "2019-05-28 08:27:26.373093",
    "invocation": {
        "module_args": {
            "_raw_params": "/home/borja/inventory/Innovery/Zookeeper/launchService.sh",
            "_uses_shell": true,
            "argv": null,
            "chdir": null,
            "creates": null,
            "executable": null,
            "removes": null,
            "stdin": null,
            "warn": true
        }
    },
    "msg": "non-zero return code",
    "rc": 1,
    "start": "2019-05-28 08:27:01.328661",
    "stderr": "Failed to start zookeeper.service: Connection timed out\nSee system logs and 'systemctl status zookeeper.service' for details.",
    "stderr_lines": [
        "Failed to start zookeeper.service: Connection timed out",
        "See system logs and 'systemctl status zookeeper.service' for details."
    ],
    "stdout": "",
    "stdout_lines": []
}

El lunes, 27 de mayo de 2019, 17:16:09 (UTC+2), Jonathan Lozada De La Matta escribió:
how are you starting the services and what comes up qhen you it with -vvvv ? a lot of services after a file change lile this require a daemon-reload

Jonathan Lozada De La Matta on mobile
 

From: ansible...@googlegroups.com on behalf of Borja Salamanca Dominguez <borja...@gmail.com>
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.

Dick Visser

unread,
May 29, 2019, 12:15:29 AM5/29/19
to ansible...@googlegroups.com
Usually if things work manually but not via ansible it’s because ansible has a different set of environment variables.
Could that be it?



To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.
Reply all
Reply to author
Forward
0 new messages