-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscreenshots.html
120 lines (120 loc) · 29 KB
/
screenshots.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>AutomateIt: Screenshots</title>
<link href='http://yui.yahooapis.com/2.4.1/build/reset-fonts-grids/reset-fonts-grids.css' media='all' rel='stylesheet' type='text/css' />
<link href='stylesheets/application.css' media='all' rel='stylesheet' type='text/css' />
<!-- /= stylesheets -->
</head>
<body>
<div id='everything'>
<div id='header'>
<table>
<tr>
<td>
<div class='logo'>
<a href='index.html'>
<img alt='AutomateIt - Open source server automation' src='images/logo.png' />
</a>
</div>
</td>
<td align='middle'>
<!-- / .tagline -->
<!-- / System Administration 2.0 -->
</td>
</tr>
</table>
</div>
<div id='menu_and_page_content'>
<table>
<tr>
<td>
<div id='menu'>
<ul>
<!-- / %li Learn -->
<li><a href="index">Home</a></li>
<li><a href="about">About</a></li>
<li><a href="compare">Compare</a></li>
<li> </li>
<!-- / %li Use -->
<li><a href="screenshots">Screenshots</a></li>
<li><a href="documentation/tutorial">Tutorial</a></li>
<li><a href="documentation">Documentation</a></li>
<li><a href="compatibility">Compatibility</a></li>
<li><a href="download">Download</a></li>
<li> </li>
<!-- / %li Connect -->
<li><a href="http://groups.google.com/group/automateit">Community</a></li>
<li><a href="contact">Contact</a></li>
<li><a href="credits">Credits</a></li>
<li><a href="changes">Changes</a></li>
</ul>
</div>
</td>
<td>
<div id='page_content'>
<div id='screenshots_section'>
<h1>AutomateIt screenshots</h1>
<p><strong>AutomateIt is an open source tool for automating the setup and maintenance of servers, applications and their dependencies.</strong></p>
<p>The screenshots below will show how to use AutomateIt to setup a Ruby on Rails application server on Linux. AutomateIt can also be used to fully automate entire systems and works well with a variety of OSes, frameworks and tools.</p>
<p>The code in these screens is self-documenting and the accompanying text is deliberately brief. Please read the <a href="documentation/tutorial">Tutorial</a> for further information.</p>
<p>You will need to <a href="download">install</a> AutomateIt to run these examples.</p>
<h2>Let’s see some code!</h2>
<h3>Project</h3>
<p>Create a project, this will make a <code>demo</code> directory for your configuration files and recipes:</p>
<pre><font color="#90ee90">root@kagami> automateit --create demo</font>
</pre>

<p>Change into this new directory with <code>cd demo</code>.</p>
<h3>Tags</h3>
<p>Describe hosts and their roles in the project’s <code>config/tags.yml</code> file. The example in these screenshots is run on host a called <code>kagami</code>. This host is tagged with the <code>rails_servers</code> and <code>myapp_servers</code> roles. To make this recipe run on your system, replace <code>kagami</code> with your hostname. Tags will be checked in the recipe using <code>tagged?</code><br />
methods:</p>
<pre><font color="#8db6cd">rails_servers</font><font color="#66cdaa"><b>:</b></font>
 <span style="background-color: #103040"><font color="#7fff00">-</font></span> kagami
 <span style="background-color: #103040"><font color="#7fff00">-</font></span> tsukasa
<font color="#8db6cd">myapp_servers</font><font color="#66cdaa"><b>:</b></font>
 <span style="background-color: #103040"><font color="#7fff00">-</font></span> kagami
</pre>

<h3>Fields</h3>
<p>Define configuration constants in the project’s <code>config/fields.yml</code> file, these will be retrieved in the recipe using <code>lookup</code> methods:</p>
<pre><font color="#8db6cd">user</font><font color="#66cdaa"><b>:</b></font> myapp_user
<font color="#8db6cd">port</font><font color="#66cdaa"><b>:</b></font> <span style="background-color: #103040"><font color="#00ffff">9826</font></span>
<font color="#8db6cd">path</font><font color="#66cdaa"><b>:</b></font> /tmp/myapp_server
</pre>

<h3>Installer recipe</h3>
<p>Write a recipe to set up a Rails application server, saving it as <code>recipes/install.rb</code>:</p>
<pre><font color="#9a94c8"># Install dependencies on hosts with 'rails_servers' or 'myapp_servers' roles</font>
<font color="#90ee90">if</font> tagged?(<font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">rails_servers | myapp_servers</font></span><font color="#66cdaa"><b>"</b></font>)
 <font color="#9a94c8"># Install platform-specific packages</font>
 <font color="#90ee90">if</font> tagged?(<font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">ubuntu | debian</font></span><font color="#66cdaa"><b>"</b></font>)
 <font color="#9a94c8"># Install the 'build-essential' package and others on Ubuntu or Debian</font>
 package_manager.install(<font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">build-essential</font></span><font color="#66cdaa"><b>"</b></font>, <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">ruby1.8-dev</font></span><font color="#66cdaa"><b>"</b></font>, <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">libsqlite3-dev</font></span><font color="#66cdaa"><b>"</b></font>)
 <font color="#90ee90">elsif</font> tagged?(<font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">fedoracore | fedora | centos</font></span><font color="#66cdaa"><b>"</b></font>)
 <font color="#9a94c8"># Install equivalent packages on Fedora and similar OSes</font>
 package_manager.install(<font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">gcc</font></span><font color="#66cdaa"><b>"</b></font>, <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">ruby-devel</font></span><font color="#66cdaa"><b>"</b></font>, <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">sqlite-devel</font></span><font color="#66cdaa"><b>"</b></font>)
 <font color="#90ee90">else</font>
 <font color="#9a94c8"># Fail if running on another platform</font>
 <span style="background-color: #103040"><font color="#90ee90"><b>raise</b></font></span> <font color="#8db6cd">NotImplementedError</font>.new(<font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">no packages specified for this platform</font></span><font color="#66cdaa"><b>"</b></font>)
 <font color="#90ee90">end</font>

 <font color="#9a94c8"># Install Rails and supporting libraries with RubyGems</font>
 package_manager.install(<font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">rails</font></span><font color="#66cdaa"><b>"</b></font>, <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">sqlite3-ruby</font></span><font color="#66cdaa"><b>"</b></font>, <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">mongrel</font></span><font color="#66cdaa"><b>"</b></font>,
 <font color="#8db6cd">:with</font> => <font color="#8db6cd">:gem</font>, <font color="#8db6cd">:docs</font> => <span style="background-color: #103040"><font color="#00cdcd">false</font></span>)
<font color="#90ee90">end</font> <font color="#9a94c8"># ENDS: if tagged?("rails_servers | myapp_servers")</font>

<font color="#9a94c8"># Setup the myapp server, a simple Rails server instance</font>
<font color="#90ee90">if</font> tagged?(<font color="#8db6cd">:myapp_servers</font>)
 <font color="#9a94c8"># Create user for the application</font>
 account_manager.add_user(lookup(<font color="#8db6cd">:user</font>))

 <font color="#9a94c8"># Create a directory for the application and 'cd' into it</font>
 mkdir_p(lookup(<font color="#8db6cd">:path</font>)) <font color="#90ee90">do</font>
 <font color="#9a94c8"># Run shell commands to create the app and database</font>
 <font color="#90ee90">unless</font> <font color="#8db6cd">File</font>.exists?(<font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">config/routes.rb</font></span><font color="#66cdaa"><b>"</b></font>)
 sh(<font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">rails --database=sqlite3 . > /dev/null</font></span><font color="#66cdaa"><b>"</b></font>)
 <font color="#90ee90">end</font>

 <font color="#9a94c8"># Create the database if it doesn't exist.</font>
 <font color="#90ee90">if</font> <font color="#8db6cd">Dir</font>[<font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">db/*.sqlite3</font></span><font color="#66cdaa"><b>"</b></font>].empty?
 sh(<font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">rake db:migrate</font></span><font color="#66cdaa"><b>"</b></font>)
 <font color="#90ee90">end</font>

 <font color="#9a94c8"># Edit the homepage</font>
 edit(<font color="#8db6cd">:file</font> => <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">public/index.html</font></span><font color="#66cdaa"><b>"</b></font>) <font color="#90ee90">do</font>
 append(<font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee"><!-- Edited by AutomateIt --></font></span><font color="#66cdaa"><b>"</b></font>)
 replace(<font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">Welcome aboard</font></span><font color="#66cdaa"><b>"</b></font>, <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">This is MyAppServer</font></span><font color="#66cdaa"><b>"</b></font>)
 <font color="#90ee90">end</font>

 <font color="#9a94c8"># Set the ownership of the created files</font>
 chperm(<font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">.</font></span><font color="#66cdaa"><b>"</b></font>, <font color="#8db6cd">:user</font> => lookup(<font color="#8db6cd">:user</font>), <font color="#8db6cd">:recurse</font> => <span style="background-color: #103040"><font color="#00cdcd">true</font></span>)

 <font color="#9a94c8"># Generate a service startup file using a template</font>
 render(
 <font color="#8db6cd">:file</font> => dist+<font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">myapp_server.erb</font></span><font color="#66cdaa"><b>"</b></font>,
 <font color="#8db6cd">:to</font> => <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">/etc/init.d/myapp_server</font></span><font color="#66cdaa"><b>"</b></font>,
 <font color="#8db6cd">:mode</font> => <span style="background-color: #103040"><font color="#00ffff">0555</font></span>,
 <font color="#8db6cd">:locals</font> => {
 <font color="#8db6cd">:path</font> => lookup(<font color="#8db6cd">:path</font>),
 <font color="#8db6cd">:user</font> => lookup(<font color="#8db6cd">:user</font>),
 <font color="#8db6cd">:port</font> => lookup(<font color="#8db6cd">:port</font>),
 }
 )

 <font color="#9a94c8"># Start the server</font>
 service_manager.start(<font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">myapp_server</font></span><font color="#66cdaa"><b>"</b></font>)
 <font color="#90ee90">end</font> <font color="#9a94c8"># ENDS: mkdir_p(lookup(:path)) do</font>
<font color="#90ee90">end</font> <font color="#9a94c8"># ENDS: if tagged?(:myapp_servers)</font>
</pre>

<h3>Template</h3>
<p>Create a template file to render, <code>dist/myapp_server.erb</code>. This is <strong>not</strong> AutomateIt code — the only thing worth paying attention to is that the <span class="caps">ERB</span> template fields will be replaced by the <code>render</code> call in the recipe. For example, the <code>port = "<%=port%>"</code> line will be rendered as <code>port = "9826"</code>.</p>
<pre><font color="#87ceff">#!/usr/bin/env ruby</font>

user = <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee"><%=user%></font></span><font color="#66cdaa"><b>"</b></font>
port = <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee"><%=port%></font></span><font color="#66cdaa"><b>"</b></font>
path = <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee"><%=path%></font></span><font color="#66cdaa"><b>"</b></font>
pid = <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">mongrel.pid</font></span><font color="#66cdaa"><b>"</b></font>

<font color="#8db6cd">ENV</font>[<font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">PATH</font></span><font color="#66cdaa"><b>"</b></font>] = <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">%s/bin:%s</font></span><font color="#66cdaa"><b>"</b></font> % [<font color="#66cdaa"><b>`</b></font><span style="background-color: #103040"><font color="#00e5ee">gem env gemdir</font></span><font color="#66cdaa"><b>`</b></font>.strip, <font color="#8db6cd">ENV</font>[<font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">PATH</font></span><font color="#66cdaa"><b>"</b></font>]]

<font color="#90ee90">case</font> <font color="#8db6cd">ARGV</font>.first
<font color="#90ee90">when</font> <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">start</font></span><font color="#66cdaa"><b>"</b></font>
 <font color="#8db6cd">Dir</font>.chdir(path)
 puts <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">Starting MyAppServer at http://localhost:</font></span><font color="#66cdaa"><b>#{port}</b></font><span style="background-color: #103040"><font color="#00e5ee">/</font></span><font color="#66cdaa"><b>"</b></font>
 <font color="#90ee90">exit</font> system(<font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">PATH=</font></span><font color="#66cdaa"><b>#{ENV["PATH"]}</b></font><span style="background-color: #103040"><font color="#00e5ee"> mongrel_rails start </font></span><font color="#66cdaa"><b>"</b></font> \
 <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">--user </font></span><font color="#66cdaa"><b>#{user}</b></font><span style="background-color: #103040"><font color="#00e5ee"> --group </font></span><font color="#66cdaa"><b>#{user}</b></font><span style="background-color: #103040"><font color="#00e5ee"> --pid </font></span><font color="#66cdaa"><b>#{pid}</b></font><span style="background-color: #103040"><font color="#00e5ee"> --daemonize </font></span><font color="#66cdaa"><b>"</b></font> \
 <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">--port </font></span><font color="#66cdaa"><b>#{port}</b></font><span style="background-color: #103040"><font color="#00e5ee"> 2>&1 | grep -v cgi_multipart_eof_fix</font></span><font color="#66cdaa"><b>"</b></font>) ? <span style="background-color: #103040"><font color="#00ffff">0</font></span> : <span style="background-color: #103040"><font color="#00ffff">1</font></span>
<font color="#90ee90">when</font> <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">stop</font></span><font color="#66cdaa"><b>"</b></font>
 <font color="#8db6cd">Dir</font>.chdir(path)
 <font color="#90ee90">exit</font> system(<font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">PATH=</font></span><font color="#66cdaa"><b>#{ENV["PATH"]}</b></font><span style="background-color: #103040"><font color="#00e5ee"> mongrel_rails stop </font></span><font color="#66cdaa"><b>"</b></font> \
 <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">--pid </font></span><font color="#66cdaa"><b>#{pid}</b></font><span style="background-color: #103040"><font color="#00e5ee"> 2>&1 | grep -v cgi_multipart_eof_fix</font></span><font color="#66cdaa"><b>"</b></font>) ? <span style="background-color: #103040"><font color="#00ffff">0</font></span> : <span style="background-color: #103040"><font color="#00ffff">1</font></span>
<font color="#90ee90">when</font> <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">status</font></span><font color="#66cdaa"><b>"</b></font>
 <font color="#90ee90">begin</font>
 <font color="#8db6cd">Process</font>.kill(<span style="background-color: #103040"><font color="#00ffff">0</font></span>, <font color="#8db6cd">File</font>.read(<font color="#8db6cd">File</font>.join(path, pid)).to_i)
 <font color="#90ee90">exit</font> <span style="background-color: #103040"><font color="#00ffff">0</font></span>
 <font color="#90ee90">rescue</font> <font color="#8db6cd">Errno</font>::<font color="#8db6cd">ENOENT</font>, <font color="#8db6cd">Errno</font>::<font color="#8db6cd">ESRCH</font>
 <font color="#90ee90">exit</font> -<span style="background-color: #103040"><font color="#00ffff">1</font></span> <font color="#9a94c8"># File or pid not found</font>
 <font color="#90ee90">end</font>
<font color="#90ee90">else</font>
 puts <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">ERROR: expected argument -- start, stop or status</font></span><font color="#66cdaa"><b>"</b></font>
<font color="#90ee90">end</font>
</pre>

<h3>Preview and execution</h3>
<p>Preview the commands this recipe will execute, without actually executing them, by specifying the <code>--preview</code> flag:</p>
<pre><font color="#90ee90">root@kagami> automateit --preview recipes/install.rb</font>
** apt-get install -y -q ruby1.8-dev libsqlite3-dev < /dev/null 2>&1
** gem install -y --no-ri --no-rdoc rails sqlite3-ruby mongrel 2>&1
** useradd --create-home --shell /bin/bash myapp_user > /dev/null
** nscd --invalidate passwd
** mkdir -p /tmp/myapp_server
** pushd /tmp/myapp_server
** rails --database=sqlite3 . > /dev/null
** rake db:migrate
=> Edited 'public/index.html'
** chown -R myapp_user .
=> Rendering '/etc/init.d/myapp_server' because of it doesn't exist
** chmod 0555 /etc/init.d/myapp_server
** /etc/init.d/myapp_server start
** popd
<font color="#90ee90">root@kagami></font>
</pre>

<p>Run the recipe without the <code>--preview</code> to apply it. Commands like <code>apt-get</code> will now display output because they’re being executed. The <code>gem</code> command typically requires manual intervention, but AutomateIt can guess which versions of Gems to install. When finished, the newly-created Rails server will be started:</p>
<pre><font color="#90ee90">root@kagami> automateit recipes/install.rb</font>
** apt-get install -y -q ruby1.8-dev libsqlite3-dev < /dev/null 2>&1
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
[...]
** gem install -y --no-ri --no-rdoc rails sqlite3-ruby mongrel 2>&1
Select which gem to install for your platform (i486-linux)
1. mongrel 1.0.1 (mswin32)
2. mongrel 1.0.1 (ruby)
3. mongrel 1.0 (mswin32)
4. mongrel 1.0 (ruby)
5. Skip this gem
6. Cancel installation
>=> Guessing: 2
[...]
** useradd --create-home --shell /bin/bash myapp_user > /dev/null
** nscd --invalidate passwd
** mkdir -p /tmp/myapp_server
** pushd /tmp/myapp_server
** rails --database=sqlite3 . > /dev/null
** rake db:migrate
[...]
=> Edited 'public/index.html'
** chown -R myapp_user .
=> Rendering '/etc/init.d/myapp_server' because of it doesn't exist
** chmod 0555 /etc/init.d/myapp_server
** /etc/init.d/myapp_server start
Starting MyAppServer at http://localhost:9826/
** popd
<font color="#90ee90">root@kagami></font>
</pre>

<p>Run the recipe again — it will detect that everything is as it should be and won’t do anything:</p>
<pre><font color="#90ee90">root@kagami> automateit recipes/install.rb</font>
<font color="#90ee90">root@kagami></font>
</pre>

<p>Now stop the Rails server manually and re-run the recipe — it will figure out that the server isn’t running and start it:</p>
<pre><font color="#90ee90">root@kagami> /etc/init.d/myapp_server stop</font>
Sending TERM to Mongrel at PID 32419...Done.
<font color="#90ee90">root@kagami> automateit recipes/install.rb</font>
** pushd /tmp/myapp_server
** /etc/init.d/myapp_server start
Starting MyAppServer at http://localhost:9826/
** popd
<font color="#90ee90">root@kagami></font>
</pre>

<h3>Uninstaller recipe</h3>
<p>You can uninstall the Rails server with this recipe, save it as <code>recipes/uninstall.rb</code>:</p>
<pre><font color="#90ee90">if</font> tagged? <font color="#8db6cd">:myapp_servers</font>
 service_manager.stop <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">myapp_server</font></span><font color="#66cdaa"><b>"</b></font>
 rm <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">/etc/init.d/myapp_server</font></span><font color="#66cdaa"><b>"</b></font>
 rm_rf lookup(<font color="#8db6cd">:path</font>)
 account_manager.remove_user lookup(<font color="#8db6cd">:user</font>)
<font color="#90ee90">end</font>
</pre>

<p>Run the uninstaller:</p>
<pre><font color="#90ee90">root@kagami> automateit recipes/uninstall.rb</font>
** "/etc/init.d/myapp_server" "stop"
Sending TERM to Mongrel at PID 29149...Done.
** rm /etc/init.d/myapp_server
** rm_rf /tmp/myapp_server
** userdel -r myapp_user
** nscd --invalidate passwd
<font color="#90ee90">root@kagami></font>
</pre>

<p>Re-run the uninstaller — it’ll detect that the files are gone and the server is stopped, and so it won’t do anything:</p>
<pre><font color="#90ee90">root@kagami> automateit recipes/uninstall.rb</font>
<font color="#90ee90">root@kagami></font>
</pre>

<h3>Embedding</h3>
<p>AutomateIt can be easily embedded into other programs. For example, put the following <code>Rakefile</code> into the <code>demo</code> project directory. You will now be able to execute Rake tasks like <code>rake preview install</code>, which will run the equivalent of <code>automateit --preview recipes/install.rb</code>.</p>
<pre><span style="background-color: #103040"><font color="#a2b5cd">require</font></span> <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">automateit</font></span><font color="#66cdaa"><b>"</b></font>

<font color="#9a94c8"># Create an Interpreter for project in current directory.</font>
<font color="#8db6cd">@interpreter</font> = <font color="#8db6cd">AutomateIt</font>.new(<font color="#8db6cd">:project</font> => <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">.</font></span><font color="#66cdaa"><b>"</b></font>)

<font color="#9a94c8"># Include Interpreter's 'invoke' and 'preview' methods into Rake.</font>
<font color="#8db6cd">@interpreter</font>.include_in(<span style="background-color: #103040"><font color="#00cdcd">self</font></span>, <font color="#66cdaa"><b>%w(</b></font><span style="background-color: #103040"><font color="#00e5ee">invoke preview</font></span><font color="#66cdaa"><b>)</b></font>)

desc <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">Install myapp server</font></span><font color="#66cdaa"><b>"</b></font>
task <font color="#8db6cd">:install</font> <font color="#90ee90">do</font>
 <font color="#9a94c8"># The 'invoke' method was created by the 'include_in' call earlier,</font>
 <font color="#9a94c8"># as a convenient shortcut for: @interpreter.invoke("install")</font>
 invoke <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">install</font></span><font color="#66cdaa"><b>"</b></font>
<font color="#90ee90">end</font>

desc <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">Uninstall myapp server</font></span><font color="#66cdaa"><b>"</b></font>
task <font color="#8db6cd">:uninstall</font> <font color="#90ee90">do</font>
 invoke <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">uninstall</font></span><font color="#66cdaa"><b>"</b></font>
<font color="#90ee90">end</font>

desc <font color="#66cdaa"><b>"</b></font><span style="background-color: #103040"><font color="#00e5ee">Preview action, e.g, 'rake preview install'</font></span><font color="#66cdaa"><b>"</b></font>
task <font color="#8db6cd">:preview</font> <font color="#90ee90">do</font>
 preview <span style="background-color: #103040"><font color="#00cdcd">true</font></span>
<font color="#90ee90">end</font>
</pre>


<h2>Learn more</h2>
<p>AutomateIt can do much more than this simple example shows. For more information, see the hands-on <a href="documentation/tutorial">Tutorial</a> and reference <a href="documentation">Documentation</a>.</p>
</div>
</div>
</td>
</tr>
</table>
</div>
<div id='footer'>
<p>
Copyright © 2007-2009 Igal Koshevoy. <a href="legal">Legal</a>.
</p>
</div>
</div>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-2647440-1";
urchinTracker();
</script>
</body>
</html>