Using Chef to install TeamCity without manual user intervention - impossible?

I'm using Chef to automate the development, CI, QA, and deployment pipeline of our company. However, when writing the TeamCity cookbook recipe, it becomes obvious that the installation process for TeamCity can't be fully automated, as there are manual steps required in order to do so, especially when installing and configuring TeamCity to use an external database - a necessity for production use.

To clarify:

1. When TeamCity has been installed and started, the data directory (.BuildServer) isn't created until the op uses a browser to go to the web interface and creates the first admin. There doesn't seem to be a way of programmatically creating the first admin. This, in itself, makes it impossible to fully automate the installation and setup process, as the REST API can't be used until there's an admin account whose credentials can be used.

2. To set up an external database, such as MySQL, the .BuildServer directory must exist, as the installation process involves modifying its contents.

As it is now, the Chef recipe has to work in several stages, some of which can be automated and some which cannot. The following comments are an excerpt from the Chef TeamCity recipe and describe the process in detail. The basic installation (download, unpack, set up init.d scripts, start, etc) is automatic. The comments pertain to what happens next:

# At this point, TeamCity must be bootstrapped manually - it can't be done programmatically. :-(
# Do the following:
#   1. Surf to
#   2. Create an admin. Username and password don't matter - this is just to generate the DB.
#   3. Don't bother with creating anything else. All info will be erased, including the admin.
#   4. Run chef-client again on the TeamCity server. This will download, install and set up
#        the MySQL connection.
#   5. Surf to once more. The page will tell you that an admin
#        needs to rescue the DB. This is normal. To find the admin token it asks for, follow
#        the instructions on screen. You need to examine the tail of a log file on the server.
#   6. Input the token and press the button.
#   7. After a few seconds, the TeamCity server becomes available again.
#   8. Create your admins, projects, etc.
# From this point on, Chef will keep everything in shape for you.

My question is the following: is there a way to accomplish all this programmatically? Scouring the documentation hasn't yielded anything so far.

Thanks for any ideas,

/ Peter Bengtson


I'm also interested in this topic.  I set my server up manually, but I'm working on a recipe to configure build agents.  There are some steps in installing the teamcity agent with chef that I think might be difficult to automate...



I have a TeamCity Agent cookbook (supports rel/centos and windows).  It has a few propritary bits, so I cannot just share it out right.  However I would rather contribute to an open source one, if it can meet my needs.  What do you have so far?
This is basiclly what I have:

My bigger issue was setting up the other requirements on the agents, (java, maven, SDK's, etc)

NOTE: I'm still a bit of a chef/ruby noob, any thoughts/advice/review are welcome!


I gave up on installing the agent, though I see it's possible with your code.  I ended up just using chef to prepare the agent machine (users, apt updates, java, ruby, my database, etc), then used the agent-push install to put the agent on there.

I used community cookbooks to get java and ruby set up.  the 'java', 'ruby-build', and 'rbenv' cookbooks.  Though not the 'rbenv' on the opscode side.  A different one from github:

I also discovered, while writing a cookbook for installing teamcity-server, that the database setup instructions in teamcity's documentation are misleading: they make it sound like you need to start the server once to generate the data directory, then modify the config files there, but I found I can pre-place my modified config files (like the database parameters) into the future location of the data directory, and teamcity will pick them up on first run.  So you can fully automate installation of the server.


Please sign in to leave a comment.