Hi,
I'm trying to automate bitbucket-server deployment on AWS. I've written a terraform module to provision an instance with the bitbucket AMI, a database instance, network config etc.
I've reached the stage where I want to configure bitbucket without requiring somebody to follow the wizard. I've combed through the documentation and I've found documentation saying you can set configuration by supplying some of the 3 recognised env vars in /etc/atl (which controls whether bitbucket attempts to setup a database/db connection config upon installation and whether it should generate a self signed cert), and I've found suggestions that you can set config (particularly JDBC parameters) in $BITBUCKET_HOME/shared/bitbucket.properties. I've also found documentation that suggests doing this configuration in ec2 user data, but when I try to piece it all together, and write something like this:
```
BITBUCKET_PROPERTIES_PATH=/var/atlassian/application-data/bitbucket/shared/bitbucket.properties
cat >> /etc/atl <<EOF
ATL_SSL_SELF_CERT_ENABLED=true
ATL_POSTGRES_ENABLED=false
EOF
sudo -u atlbitbucket mkdir -p $(dirname $BITBUCKET_PROPERTIES_PATH)
cat >> $BITBUCKET_PROPERTIES_PATH <<EOF
setup.displayName=bitbucket
setup.baseUrl=https://${bitbucket_base_url}
setup.license=${bitbucket_license}
setup.sysadmin.displayName=${bitbucket_admin_display_name}
setup.sysadmin.emailAddress=${bitbucket_admin_email_address}
jdbc.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.url=jdbc:sqlserver://${db_host};databaseName=${bitbucket_db_name}
jdbc.user=${bitbucket_db_username}
jdbc.password=${bitbucket_db_password}
EOF
service atlbitbucket restart
```
Where ${x} is filled in by terraform templating
But I find that butbucket.properties is being overwritten by something, I've checked this by preventing the bitbucket user from modifying the file and I see my user-data changes are in place. I've had a look through the source code for the ami deployment, but it's not easy to figure out which part is responsible.
I've found that I can make the system "overwrite" the properties file with my JDBC vars by adding those variables, along with "ATL_DB_NAME" in /etc/atl, but that doesn't let me specify license etc. so I'm still stuck.
Is there a correct way of doing what I want to do, or am I doomed to have to manually configure the server?
Documentation I'm referring to for configuring bitbucket: