Aviate Quickstart

To give you an idea of what Aviate can do, we will go through an example of deploying a simple website. This is a very light example and uses little of Aviate's features. If you want a beefier example, you can look into the deployment file of Wordpress. The following are the points we want to tackle in our example deployment process:

  • We do not want to store the password in the deployment file.
  • We want to backup the existing website before we deploy.
  • We want to synchronize the working directory with the server.
  • We have separate configuration files for local development and the production website.
  • We have a separate .htaccess for local development and the production website.

Below is the DepFile we would use to deploy this website:

<?xml version="1.0" encoding="iso-8859-1"?>
<project name="my-site">

	<variables>
		<argument name="working_dir" required="true" question="Working directory?" />
		<argument name="ssh_password" required="true" question="SSH Password?" />
	</variables>

	<constants>
		<constant name="BACKUP_FILE" value="backup-#{YEAR}-#{MONTH}-#{DAY}" />
		<constant name="SITE_DIR" value="/var/www" />
	</constants>

	<servers>
		<server:local id="local" root="${working_dir}" />
		<server:ssh
			id="ssh_server" os="linux" root="#{SITE_DIR}"
			host="myserver.com" port="22" username="root" password="${ssh_password}"
		/>
	</servers>

	<targets>
		<target name="sync">
 			<task name="main">
				<fs:rsync
					source="local" destination="ssh_server"
					from="${working_dir}/" to="#{SITE_DIR}" options="opt"
				>
					<dictionary name="opt">
						<entry name="-r"/>
						<entry name="--delete"/>
						<entry name="--exclude" value=".svn" />
					</dictionary>
				</fs:rsync>
				<fs:rename
					destination="ssh_server" replace="true"
					from="config.inc.live.php" to="config.inc.php"
				/>
				<fs:rename
					destination="ssh_server" replace="true"
					from=".htaccess.live" to=".htaccess"
				/>
			</task>
		</target>
		<target name="backup">
			<task name="main" chain="ssh_server">
				<fs:compress
					source="local" destination="local" from="#{SITE_DIR}"
					to="/var/backup/#{BACKUP_SITE_DIR_FILE_ID}.tar.gz"
				/>
			</task>
		</target>
	</targets>
</project>

To deploy the website, you can simple execute the sync target, which will execute first the backup target since it depends on it.

prompt> aviate mysite.dep -t sync

Aviate will prompt you for values for the "working_dir" and "ssh_password" variables. If you do not want to be prompted, you can specify them on the command line:

prompt> aviate mysite.dep -t sync working_dir=/var/www ssh_password=mypassword