Support Questions

Find answers, ask questions, and share your expertise
Announcements
Check out our newest addition to the community, the Cloudera Data Analytics (CDA) group hub.

Ansible outputs Unknown Job for ambari-agent

Contributor

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

Contributor

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

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" ?!?!

Contributor

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

Contributor

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

Expert Contributor

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

Contributor

Thanks @Alexandru Anghel

This was very informative

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.