Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How can I detect if ambari-server setup has already been ran

Solved Go to solution
Highlighted

How can I detect if ambari-server setup has already been ran

I am creating ansible scripts to bootstrap our ambari servers. I need to check if ambari-server setup has already been ran so that re-running the ansible scripts do not error out when it gets to that step. The easiest way to make these idempotent in ansible is to check for the existence of a file, but I haven't been able to find any obvious file created by the setup process that I can rely on.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How can I detect if ambari-server setup has already been ran

Super Mentor

@maxolasersquad 

One very basic test we can do to verify if the "ambari-server setup" was performed or not is to look for JDBC settings.

For example when we simply install ambari server binary on a host then the ambari.properties file will not have any JDBC configs so the output for the following will be empty.

Example: (no output on a server where ambari-server setup was not executed)

# grep 'jdbc' /etc/ambari-server/conf/ambari.properties


However, on a server where setup was executed you will see atleast some jdbc settings as following:

# grep 'jdbc' /etc/ambari-server/conf/ambari.properties 
custom.mysql.jdbc.name=mysql-connector-java.jar
custom.oracle.jdbc.name=ojdbc8.jar
previous.custom.mysql.jdbc.name=mysql-jdbc-driver.jar
server.jdbc.connection-pool=internal
server.jdbc.database=postgres
server.jdbc.database_name=ambari
server.jdbc.postgres.schema=ambari
server.jdbc.user.name=ambari
server.jdbc.user.passwd=${alias=ambari.db.password}

.

 

2 REPLIES 2

Re: How can I detect if ambari-server setup has already been ran

Super Mentor

@maxolasersquad 

One very basic test we can do to verify if the "ambari-server setup" was performed or not is to look for JDBC settings.

For example when we simply install ambari server binary on a host then the ambari.properties file will not have any JDBC configs so the output for the following will be empty.

Example: (no output on a server where ambari-server setup was not executed)

# grep 'jdbc' /etc/ambari-server/conf/ambari.properties


However, on a server where setup was executed you will see atleast some jdbc settings as following:

# grep 'jdbc' /etc/ambari-server/conf/ambari.properties 
custom.mysql.jdbc.name=mysql-connector-java.jar
custom.oracle.jdbc.name=ojdbc8.jar
previous.custom.mysql.jdbc.name=mysql-jdbc-driver.jar
server.jdbc.connection-pool=internal
server.jdbc.database=postgres
server.jdbc.database_name=ambari
server.jdbc.postgres.schema=ambari
server.jdbc.user.name=ambari
server.jdbc.user.passwd=${alias=ambari.db.password}

.

 

Re: How can I detect if ambari-server setup has already been ran

Perfect. Here's my solution based on your feedback.

 

- name: Check if Ambari setup has already run
  command: grep 'jdbc' /etc/ambari-server/conf/ambari.properties
  register: ambari_setup_check
  check_mode: no
  ignore_errors: yes
  changed_when: no

 

- name: Setup Ambari server
  command: printf '%s\n' y ambari y y n | ambari-server setup -j /usr/lib/jvm/java-8-  openjdk-amd64
  become: yes
  when: ambari_setup_check.rc == 1

Don't have an account?
Coming from Hortonworks? Activate your account here