Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Ansible outputs Unknown Job for ambari-agent

avatar
Rising Star

I am getting following error:

fatal: [node4.hc.com]: FAILED! => {"changed": false, "failed": true, "msg": "stop: Unknown job: ambari-agent\nstart: Unknown job: ambari-agent\n"}

fatal: [node2.hc.com]: FAILED! => {"changed": false, "failed": true, "msg": "stop: Unknown job: ambari-agent\nstart: Unknown job: ambari-agent\n"}

and role is :

--- - hosts: all

tasks:

- name: Install Ambari agent

yum: name=ambari-agent state=present

- name: Configure ambari-server hostname in ambari-agent configuration

lineinfile: dest=/etc/ambari-agent/conf/ambari-agent.ini regexp=^.*hostname=.*$ line=hostname={{ item }} backup=yes with_items: "{{groups['ambari']}}"

- name: Ensure ambari-agent is running and enabled

service: name=ambari-agent state=started enabled=yes

Why is it not able to find the service ?

1 ACCEPTED SOLUTION

avatar
Rising Star

I couldn't figure out that why ambari-agent module was not being recognize but i managed to use script from init.d to start the service and it worked.

Here is the snippet of the play:

---

name: Ensure ambari-agent is running and enabled

command: /etc/init.d/ambari-agent restart

View solution in original post

5 REPLIES 5

avatar
Guru

Hi @Bhavin Tandel ,

are all the other steps running fine ? maybe posting the whole output will help....

I have similar playbook, which works fine on RHEL

- name: install ambari-agent yum: name=ambari-agent state=latest 
...
- name: Ensure ambari-agent is running and enabled 
service: name=ambari-agent state=restarted enabled=yes

guessing you are on a RHEL based distro...

What if you do a manual "service ambari-agent restart" ?!?!

avatar
Rising Star

Thanks @Gerd Koenig for the quick reply. This the whole output, and yeah i am on Centos 6.5. If i run the command manually then it executed successfully.6262-conemu64-2016-08-02-14-18-49.png

avatar
Rising Star

I couldn't figure out that why ambari-agent module was not being recognize but i managed to use script from init.d to start the service and it worked.

Here is the snippet of the play:

---

name: Ensure ambari-agent is running and enabled

command: /etc/init.d/ambari-agent restart

avatar
Super Collaborator

Hi @Bhavin Tandel

This is a valid question.

Ambari 2.2.1.1 introduced a bug, by adding upstart support on all flavours of Linux: https://issues.apache.org/jira/browse/AMBARI-14842

Unfortunately, the same /etc/init/ambari-agent.conf file was used for all flavours of Linux. And in CentOS/RHEL6, the line 'kill signal SIGKILL' from this file is not compatible with the older version of upstart used in CentOS/RHEL6.

Ansible service module would always prefer to use upstart instead of SysVinit to start services, hence the error, as the upstart stop/start ambari-agent does not work in CentOS/RHEL6.

This is fixed in Ambari 2.2.2.0 so I suggest you use Ambari 2.2.2.0. If you can't, then you'll need to use the following Ansible task before your service task:

- name: Fix for upstart script in RHEL6
  lineinfile: dest=/etc/init/ambari-agent.conf
              state=absent
              regexp='^kill(.*)'
  when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "6"

Kind regards,

Alexandru

avatar
Rising Star

Thanks @Alexandru Anghel

This was very informative