ambari-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastián Ramírez (JIRA) <j...@apache.org>
Subject [jira] [Commented] (AMBARI-9215) ambari-server not running when (re)started via ansible 'command' or 'shell' module
Date Mon, 13 Jul 2015 16:00:05 GMT

    [ https://issues.apache.org/jira/browse/AMBARI-9215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14624852#comment-14624852
] 

Sebastián Ramírez commented on AMBARI-9215:
-------------------------------------------

Here's how I do it, and it's working for me.

Ambari: 2.0.1
CentOS: 6.6

I'm using the {{service}} module, not the bare shell command.

{{ansible myhost -m service -a "name=ambari-server state=restarted" --ask-pass -u root}}

----

And here's the playbook / tasks I'm using, it may be interesting for you.

I'm using the "when" conditional with the filter and the regex to check the result of the
{{ambari-server status}}, that is how I check if it is running or not, and using the {{service}}
module with a {{restarted}} state I ensure {{ambari-server}} is started even if it is not
started yet, because the service module alone thinks it is started even when it is not.

Ansible related tasks:

{code}
    - name: Check for ambari-server status
      command: ambari-server status
      register: ambaristatus
    - name: Setup if ambari-server not running
      command: ambari-server setup -s
      when: ambaristatus.stdout | search('.*Ambari Server not running.*')
    - name: Start ambari-server
      service:
        name: ambari-server
        state: restarted
      register: ambaristart
      when: ambaristatus.stdout | search('.*Ambari Server not running.*')
{code}

> ambari-server not running when (re)started via ansible 'command' or 'shell' module
> ----------------------------------------------------------------------------------
>
>                 Key: AMBARI-9215
>                 URL: https://issues.apache.org/jira/browse/AMBARI-9215
>             Project: Ambari
>          Issue Type: Bug
>    Affects Versions: 1.6.1
>         Environment: HDP 2.1 on RHEL 6 with 2.1.GlusterFS stack.
>            Reporter: Daniel Horak
>
> When I start ambari-server via ansible 'command' or 'shell' module, ambari server immediately
stop, when the ansible command finish.
> *How to reproduce:*
> 1) prepare ansible inventory file (you have to have configured passwordless ssh to the
server AMBARI.EXAMPLE.COM).
> {noformat}
> # echo "AMBARI.EXAMPLE.COM" > hosts
> {noformat}
> 2) check ansible configuration
> {noformat}
> # ansible AMBARI.EXAMPLE.COM -i hosts  -m ping
>   AMBARI.EXAMPLE.COM | success >> {
>       "changed": false, 
>       "ping": "pong"
>   }
> {noformat}
> 3) run ambari-server restart (and sleep 30) via ansible and in the meantime, check the
state of ambari-server on the server AMBARI.EXAMPLE.COM.
> {noformat}
> # ansible AMBARI.EXAMPLE.COM -i hosts -m shell -a "ambari-server restart; sleep 30"
>   AMBARI.EXAMPLE.COM | success | rc=0 >>
>   Using python  /usr/bin/python2.6
>   Restarting ambari-server
>   Using python  /usr/bin/python2.6
>   Stopping ambari-server
>   Ambari Server is not running
>   Using python  /usr/bin/python2.6
>   Starting ambari-server
>   Ambari Server running with 'root' privileges.
>   Organizing resource files at /var/lib/ambari-server/resources...
>   Waiting for server start...
>   Server PID at: /var/run/ambari-server/ambari-server.pid
>   Server out at: /var/log/ambari-server/ambari-server.out
>   Server log at: /var/log/ambari-server/ambari-server.log
>   Ambari Server 'start' completed successfully.
> {noformat}
> in the meantime on the AMBARI.EXAMPLE.COM:
> {noformat}
> AMBARI.EXAMPLE.COM# ambari-server status
>   Using python  /usr/bin/python2.6
>   Ambari-server status
>   Ambari Server running
>   Found Ambari Server PID: '3785 at: /var/run/ambari-server/ambari-server.pid
> {noformat}
> 4) when the ansible command finish, check the state of ambari-server and related log:
> {noformat}
> AMBARI.EXAMPLE.COM# ambari-server status
>   Using python  /usr/bin/python2.6
>   Ambari-server status
>   Ambari Server not running. Stale PID File at: /var/run/ambari-server/ambari-server.pid
> AMBARI.EXAMPLE.COM# tail -4 /var/log/ambari-server/ambari-server.log 
>   16:52:26,965  INFO [Thread-2] ContextHandler:795 - stopped o.e.j.s.ServletContextHandler{/,file:/usr/lib/ambari-server/web/}
>   16:52:27,018  INFO [main] AmbariServer:439 - Joined the Server
>   16:52:27,144  INFO [Thread-2] ContextHandler:795 - stopped o.e.j.s.ServletContextHandler{/,null}
>   16:52:27,197  INFO [Thread-2] ShutdownThread:82 - shutdown already commenced
> {noformat}
> *Note:* when I use ansible 'service' module, it works well, but I need to use 'shell'
module, because it is called from longer shell script (direct call {{ambari-server restart}}
is just reproducer). Also restarting other services this way (e.g. ambari-agent) works well.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message