Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

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

avatar

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

avatar
Master 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}

.

 

View solution in original post

2 REPLIES 2

avatar
Master 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}

.

 

avatar

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