How to automate this initial setup?

Hello,

You can use the command line that is documented here:
http://docs.couchbase.com/couchbase-manual-2.2/#command-line-interface-for-administration

You can then integrate this in any administration tool, I have for example written some scripts for Ansible.

Regards
Tug
@tgrall