https://wiki.diasporafoundation.org/api.php?action=feedcontributions&user=Joebew42&feedformat=atomdiaspora* project wiki - User contributions [en]2024-03-28T09:47:12ZUser contributionsMediaWiki 1.39.3https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=4236Installation/Vagrant puppet capistrano2015-08-01T18:02:29Z<p>Joebew42: /* Initialize project */</p>
<hr />
<div>= Before you get started =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''Official github repository of the project''']<br />
<br />
You must to have installed on your computer Vagrant 1.7 or greater and Capistrano 3.1 or greater (to install Capistrano follow instructions below.)<br />
<br />
= Overview - What is diaspora*-replica? =<br />
<br />
The aim of this project is to provide a way to automate the provision and the deploy of a diaspora* POD through tools like [http://www.vagrantup.com/ '''Vagrant 2'''], [http://puppetlabs.com/ '''Puppet'''] and [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
* If you are a developer you can use these tools to setup a development environment<br />
* If you are a POD maintainer you can use these tools to automatically provision and configure machines (on a bare-metal server or cloud providers) and deploy diaspora* on it<br />
<br />
= Deploy diaspora* on local environment =<br />
<br />
If you want to try diaspora* without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle two environments: ''development'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the FQDNs for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora-replica<br />
git submodule update --init<br />
</pre><br />
<br />
== Install vagrant plugins ==<br />
<br />
<pre><br />
vagrant plugin install vagrant-puppet-install<br />
</pre><br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up production</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned and the bundler will install ruby gems.<br />
Once capistrano completed the deploy task, you can start diaspora through ''eye''<br />
<br />
<pre><br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30/40 seconds) and then your diaspora* installation will be up and running at ''http://production.diaspora.local''<br />
<br />
== Start, stop, restart and info ==<br />
<br />
You can use Capistrano tasks to start, stop, restart or get information about diaspora*<br />
<br />
<pre><br />
cap production diaspora:eye:start<br />
cap production diaspora:eye:stop<br />
cap production diaspora:eye:restart<br />
cap production diaspora:eye:info<br />
</pre><br />
<br />
== Deploy other branches ==<br />
<br />
If you want to deploy a different branch of diaspora* (ex. ''develop'' instead of ''master'') you have to update ''puppet/manifest/site.pp'' by specifying correct ''rvm'' and ''ruby'' version:<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora'<br />
}<br />
}<br />
</pre><br />
<br />
Set up the the ''repo_url'' and/or the ''branch'' that we want to deploy by editing ''capistrano/config/deploy/production.rb''<br />
<br />
<pre><br />
...<br />
set :repo_url, 'https://github.com/diaspora/diaspora.git'<br />
set :branch, 'develop'<br />
...<br />
</pre><br />
<br />
Execute the provision of the machine and the deploy of diaspora*<br />
<br />
<pre><br />
vagrant up production<br />
cd capistrano/<br />
cap production deploy<br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
Check out your diaspora* installation at ''http://production.diaspora.local''<br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy diaspora:eye:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== What if I want to deploy the branch master with Postgresql? ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
Add the generated Gemfile.lock under version control. In ''capistrano/config/deploy/production.rb'' you have to specify your git repository:<br />
<br />
<pre><br />
set :repo_url, 'https://github.com/[your_github_username]/diaspora.git'<br />
set :branch, '[your_branch]'<br />
</pre><br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora-replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Install vagrant plugins ==<br />
<br />
<pre><br />
vagrant plugin install vagrant-puppet-install<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
Ensure you have '''nfs-server''' installed and running on your host. '''Vagrantfile''' is configured to synchronize an host directory (''src/'') with a guest directory (''diaspora_src/''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora-replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
Create a new branch or switch to existing one (eg. ''master'' or ''develop''). Lets say we want to switch to the ''develop'' branch:<br />
<br />
<pre><br />
cd src/<br />
git checkout develop<br />
cd ..<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.2<br />
</pre><br />
<br />
The line above is just an example, since you have to remember to choose the right ''rubies'' accordingly to ''.ruby-version'' file<br />
<br />
<pre><br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle install --with mysql postgresql<br />
</pre><br />
<br />
If ''bundle'' fails consider to update it with ''gem update bundler''<br />
<br />
<pre><br />
vagrant@development:~$ rake generate:secret_token<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Prepare test environment ==<br />
<br />
<pre><br />
vagrant@development:~$ rake db:test:prepare<br />
vagrant@development:~$ rake assets:generate_error_pages<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rspec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
Follow these steps in order to upgrade an existing installation of diaspora*. In this example we'll consider the production environment (you can apply the same instructions for ''staging'', ''development'' or user defined environment).<br />
<br />
<pre><br />
cd diaspora-replica/<br />
git pull --rebase origin master<br />
git submodule update<br />
<br />
vagrant up production<br />
vagrant provision production --provision-with puppet<br />
<br />
cd capistrano/<br />
cap production deploy<br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=4235Installation/Vagrant puppet capistrano2015-08-01T18:01:31Z<p>Joebew42: /* Deploy diaspora* on local environment */</p>
<hr />
<div>= Before you get started =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''Official github repository of the project''']<br />
<br />
You must to have installed on your computer Vagrant 1.7 or greater and Capistrano 3.1 or greater (to install Capistrano follow instructions below.)<br />
<br />
= Overview - What is diaspora*-replica? =<br />
<br />
The aim of this project is to provide a way to automate the provision and the deploy of a diaspora* POD through tools like [http://www.vagrantup.com/ '''Vagrant 2'''], [http://puppetlabs.com/ '''Puppet'''] and [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
* If you are a developer you can use these tools to setup a development environment<br />
* If you are a POD maintainer you can use these tools to automatically provision and configure machines (on a bare-metal server or cloud providers) and deploy diaspora* on it<br />
<br />
= Deploy diaspora* on local environment =<br />
<br />
If you want to try diaspora* without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle two environments: ''development'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the FQDNs for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora-replica<br />
git submodule update --init<br />
</pre><br />
<br />
== Install vagrant plugins ==<br />
<br />
<pre><br />
vagrant plugin install vagrant-puppet-install<br />
</pre><br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up production</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned and the bundler will install ruby gems.<br />
Once capistrano completed the deploy task, you can start diaspora through ''eye''<br />
<br />
<pre><br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30/40 seconds) and then your diaspora* installation will be up and running at ''http://production.diaspora.local''<br />
<br />
== Start, stop, restart and info ==<br />
<br />
You can use Capistrano tasks to start, stop, restart or get information about diaspora*<br />
<br />
<pre><br />
cap production diaspora:eye:start<br />
cap production diaspora:eye:stop<br />
cap production diaspora:eye:restart<br />
cap production diaspora:eye:info<br />
</pre><br />
<br />
== Deploy other branches ==<br />
<br />
If you want to deploy a different branch of diaspora* (ex. ''develop'' instead of ''master'') you have to update ''puppet/manifest/site.pp'' by specifying correct ''rvm'' and ''ruby'' version:<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora'<br />
}<br />
}<br />
</pre><br />
<br />
Set up the the ''repo_url'' and/or the ''branch'' that we want to deploy by editing ''capistrano/config/deploy/production.rb''<br />
<br />
<pre><br />
...<br />
set :repo_url, 'https://github.com/diaspora/diaspora.git'<br />
set :branch, 'develop'<br />
...<br />
</pre><br />
<br />
Execute the provision of the machine and the deploy of diaspora*<br />
<br />
<pre><br />
vagrant up production<br />
cd capistrano/<br />
cap production deploy<br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
Check out your diaspora* installation at ''http://production.diaspora.local''<br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy diaspora:eye:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== What if I want to deploy the branch master with Postgresql? ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
Add the generated Gemfile.lock under version control. In ''capistrano/config/deploy/production.rb'' you have to specify your git repository:<br />
<br />
<pre><br />
set :repo_url, 'https://github.com/[your_github_username]/diaspora.git'<br />
set :branch, '[your_branch]'<br />
</pre><br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora-replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
Ensure you have '''nfs-server''' installed and running on your host. '''Vagrantfile''' is configured to synchronize an host directory (''src/'') with a guest directory (''diaspora_src/''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora-replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
Create a new branch or switch to existing one (eg. ''master'' or ''develop''). Lets say we want to switch to the ''develop'' branch:<br />
<br />
<pre><br />
cd src/<br />
git checkout develop<br />
cd ..<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.2<br />
</pre><br />
<br />
The line above is just an example, since you have to remember to choose the right ''rubies'' accordingly to ''.ruby-version'' file<br />
<br />
<pre><br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle install --with mysql postgresql<br />
</pre><br />
<br />
If ''bundle'' fails consider to update it with ''gem update bundler''<br />
<br />
<pre><br />
vagrant@development:~$ rake generate:secret_token<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Prepare test environment ==<br />
<br />
<pre><br />
vagrant@development:~$ rake db:test:prepare<br />
vagrant@development:~$ rake assets:generate_error_pages<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rspec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
Follow these steps in order to upgrade an existing installation of diaspora*. In this example we'll consider the production environment (you can apply the same instructions for ''staging'', ''development'' or user defined environment).<br />
<br />
<pre><br />
cd diaspora-replica/<br />
git pull --rebase origin master<br />
git submodule update<br />
<br />
vagrant up production<br />
vagrant provision production --provision-with puppet<br />
<br />
cd capistrano/<br />
cap production deploy<br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=4219Installation/Vagrant puppet capistrano2015-07-11T17:56:51Z<p>Joebew42: /* Cloning your git repository in src/ directory */</p>
<hr />
<div>= Before you get started =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''Official github repository of the project''']<br />
<br />
You must to have installed on your computer Vagrant 1.7 or greater and Capistrano 3.1 or greater (to install Capistrano follow instructions below.)<br />
<br />
= Overview - What is diaspora*-replica? =<br />
<br />
The aim of this project is to provide a way to automate the provision and the deploy of a diaspora* POD through tools like [http://www.vagrantup.com/ '''Vagrant 2'''], [http://puppetlabs.com/ '''Puppet'''] and [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
* If you are a developer you can use these tools to setup a development environment<br />
* If you are a POD maintainer you can use these tools to automatically provision and configure machines (on a bare-metal server or cloud providers) and deploy diaspora* on it<br />
<br />
= Deploy diaspora* on local environment =<br />
<br />
If you want to try diaspora* without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle two environments: ''development'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the FQDNs for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora-replica<br />
git submodule update --init<br />
</pre><br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up production</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned and the bundler will install ruby gems.<br />
Once capistrano completed the deploy task, you can start diaspora through ''eye''<br />
<br />
<pre><br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30/40 seconds) and then your diaspora* installation will be up and running at ''http://production.diaspora.local''<br />
<br />
== Start, stop, restart and info ==<br />
<br />
You can use Capistrano tasks to start, stop, restart or get information about diaspora*<br />
<br />
<pre><br />
cap production diaspora:eye:start<br />
cap production diaspora:eye:stop<br />
cap production diaspora:eye:restart<br />
cap production diaspora:eye:info<br />
</pre><br />
<br />
== Deploy other branches ==<br />
<br />
If you want to deploy a different branch of diaspora* (ex. ''develop'' instead of ''master'') you have to update ''puppet/manifest/site.pp'' by specifying correct ''rvm'' and ''ruby'' version:<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora'<br />
}<br />
}<br />
</pre><br />
<br />
Set up the the ''repo_url'' and/or the ''branch'' that we want to deploy by editing ''capistrano/config/deploy/production.rb''<br />
<br />
<pre><br />
...<br />
set :repo_url, 'https://github.com/diaspora/diaspora.git'<br />
set :branch, 'develop'<br />
...<br />
</pre><br />
<br />
Execute the provision of the machine and the deploy of diaspora*<br />
<br />
<pre><br />
vagrant up production<br />
cd capistrano/<br />
cap production deploy<br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
Check out your diaspora* installation at ''http://production.diaspora.local''<br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy diaspora:eye:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== What if I want to deploy the branch master with Postgresql? ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
Add the generated Gemfile.lock under version control. In ''capistrano/config/deploy/production.rb'' you have to specify your git repository:<br />
<br />
<pre><br />
set :repo_url, 'https://github.com/[your_github_username]/diaspora.git'<br />
set :branch, '[your_branch]'<br />
</pre><br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora-replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
Ensure you have '''nfs-server''' installed and running on your host. '''Vagrantfile''' is configured to synchronize an host directory (''src/'') with a guest directory (''diaspora_src/''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora-replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
Create a new branch or switch to existing one (eg. ''master'' or ''develop''). Lets say we want to switch to the ''develop'' branch:<br />
<br />
<pre><br />
cd src/<br />
git checkout develop<br />
cd ..<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.2<br />
</pre><br />
<br />
The line above is just an example, since you have to remember to choose the right ''rubies'' accordingly to ''.ruby-version'' file<br />
<br />
<pre><br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle install --with mysql postgresql<br />
</pre><br />
<br />
If ''bundle'' fails consider to update it with ''gem update bundler''<br />
<br />
<pre><br />
vagrant@development:~$ rake generate:secret_token<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Prepare test environment ==<br />
<br />
<pre><br />
vagrant@development:~$ rake db:test:prepare<br />
vagrant@development:~$ rake assets:generate_error_pages<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rspec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
Follow these steps in order to upgrade an existing installation of diaspora*. In this example we'll consider the production environment (you can apply the same instructions for ''staging'', ''development'' or user defined environment).<br />
<br />
<pre><br />
cd diaspora-replica/<br />
git pull --rebase origin master<br />
git submodule update<br />
<br />
vagrant up production<br />
vagrant provision production --provision-with puppet<br />
<br />
cd capistrano/<br />
cap production deploy<br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=4204Installation/Vagrant puppet capistrano2015-07-08T16:59:56Z<p>Joebew42: /* How to contribute this project */</p>
<hr />
<div>= Before you get started =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''Official github repository of the project''']<br />
<br />
You must to have installed on your computer Vagrant 1.7 or greater and Capistrano 3.1 or greater (to install Capistrano follow instructions below.)<br />
<br />
= Overview - What is diaspora*-replica? =<br />
<br />
The aim of this project is to provide a way to automate the provision and the deploy of a diaspora* POD through tools like [http://www.vagrantup.com/ '''Vagrant 2'''], [http://puppetlabs.com/ '''Puppet'''] and [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
* If you are a developer you can use these tools to setup a development environment<br />
* If you are a POD maintainer you can use these tools to automatically provision and configure machines (on a bare-metal server or cloud providers) and deploy diaspora* on it<br />
<br />
= Deploy diaspora* on local environment =<br />
<br />
If you want to try diaspora* without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle two environments: ''development'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the FQDNs for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora-replica<br />
git submodule update --init<br />
</pre><br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up production</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned and the bundler will install ruby gems.<br />
Once capistrano completed the deploy task, you can start diaspora through ''eye''<br />
<br />
<pre><br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30/40 seconds) and then your diaspora* installation will be up and running at ''http://production.diaspora.local''<br />
<br />
== Start, stop, restart and info ==<br />
<br />
You can use Capistrano tasks to start, stop, restart or get information about diaspora*<br />
<br />
<pre><br />
cap production diaspora:eye:start<br />
cap production diaspora:eye:stop<br />
cap production diaspora:eye:restart<br />
cap production diaspora:eye:info<br />
</pre><br />
<br />
== Deploy other branches ==<br />
<br />
If you want to deploy a different branch of diaspora* (ex. ''develop'' instead of ''master'') you have to update ''puppet/manifest/site.pp'' by specifying correct ''rvm'' and ''ruby'' version:<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora'<br />
}<br />
}<br />
</pre><br />
<br />
Set up the the ''repo_url'' and/or the ''branch'' that we want to deploy by editing ''capistrano/config/deploy/production.rb''<br />
<br />
<pre><br />
...<br />
set :repo_url, 'https://github.com/diaspora/diaspora.git'<br />
set :branch, 'develop'<br />
...<br />
</pre><br />
<br />
Execute the provision of the machine and the deploy of diaspora*<br />
<br />
<pre><br />
vagrant up production<br />
cd capistrano/<br />
cap production deploy<br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
Check out your diaspora* installation at ''http://production.diaspora.local''<br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy diaspora:eye:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== What if I want to deploy the branch master with Postgresql? ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
Add the generated Gemfile.lock under version control. In ''capistrano/config/deploy/production.rb'' you have to specify your git repository:<br />
<br />
<pre><br />
set :repo_url, 'https://github.com/[your_github_username]/diaspora.git'<br />
set :branch, '[your_branch]'<br />
</pre><br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora-replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora-replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
Create a new branch or switch to existing one (eg. ''master'' or ''develop''). Lets say we want to switch to the ''develop'' branch:<br />
<br />
<pre><br />
cd src/<br />
git checkout develop<br />
cd ..<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.2<br />
</pre><br />
<br />
The line above is just an example, since you have to remember to choose the right ''rubies'' accordingly to ''.ruby-version'' file<br />
<br />
<pre><br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle install --with mysql postgresql<br />
</pre><br />
<br />
If ''bundle'' fails consider to update it with ''gem update bundler''<br />
<br />
<pre><br />
vagrant@development:~$ rake generate:secret_token<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Prepare test environment ==<br />
<br />
<pre><br />
vagrant@development:~$ rake db:test:prepare<br />
vagrant@development:~$ rake assets:generate_error_pages<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rspec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
Follow these steps in order to upgrade an existing installation of diaspora*. In this example we'll consider the production environment (you can apply the same instructions for ''staging'', ''development'' or user defined environment).<br />
<br />
<pre><br />
cd diaspora-replica/<br />
git pull --rebase origin master<br />
git submodule update<br />
<br />
vagrant up production<br />
vagrant provision production --provision-with puppet<br />
<br />
cd capistrano/<br />
cap production deploy<br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=4203Installation/Vagrant puppet capistrano2015-07-08T16:42:07Z<p>Joebew42: /* How to set up a Development Environment */</p>
<hr />
<div>= Before you get started =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''Official github repository of the project''']<br />
<br />
You must to have installed on your computer Vagrant 1.7 or greater and Capistrano 3.1 or greater (to install Capistrano follow instructions below.)<br />
<br />
= Overview - What is diaspora*-replica? =<br />
<br />
The aim of this project is to provide a way to automate the provision and the deploy of a diaspora* POD through tools like [http://www.vagrantup.com/ '''Vagrant 2'''], [http://puppetlabs.com/ '''Puppet'''] and [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
* If you are a developer you can use these tools to setup a development environment<br />
* If you are a POD maintainer you can use these tools to automatically provision and configure machines (on a bare-metal server or cloud providers) and deploy diaspora* on it<br />
<br />
= Deploy diaspora* on local environment =<br />
<br />
If you want to try diaspora* without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle two environments: ''development'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the FQDNs for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora-replica<br />
git submodule update --init<br />
</pre><br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up production</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned and the bundler will install ruby gems.<br />
Once capistrano completed the deploy task, you can start diaspora through ''eye''<br />
<br />
<pre><br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30/40 seconds) and then your diaspora* installation will be up and running at ''http://production.diaspora.local''<br />
<br />
== Start, stop, restart and info ==<br />
<br />
You can use Capistrano tasks to start, stop, restart or get information about diaspora*<br />
<br />
<pre><br />
cap production diaspora:eye:start<br />
cap production diaspora:eye:stop<br />
cap production diaspora:eye:restart<br />
cap production diaspora:eye:info<br />
</pre><br />
<br />
== Deploy other branches ==<br />
<br />
If you want to deploy a different branch of diaspora* (ex. ''develop'' instead of ''master'') you have to update ''puppet/manifest/site.pp'' by specifying correct ''rvm'' and ''ruby'' version:<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora'<br />
}<br />
}<br />
</pre><br />
<br />
Set up the the ''repo_url'' and/or the ''branch'' that we want to deploy by editing ''capistrano/config/deploy/production.rb''<br />
<br />
<pre><br />
...<br />
set :repo_url, 'https://github.com/diaspora/diaspora.git'<br />
set :branch, 'develop'<br />
...<br />
</pre><br />
<br />
Execute the provision of the machine and the deploy of diaspora*<br />
<br />
<pre><br />
vagrant up production<br />
cd capistrano/<br />
cap production deploy<br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
Check out your diaspora* installation at ''http://production.diaspora.local''<br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy diaspora:eye:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== What if I want to deploy the branch master with Postgresql? ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
Add the generated Gemfile.lock under version control. In ''capistrano/config/deploy/production.rb'' you have to specify your git repository:<br />
<br />
<pre><br />
set :repo_url, 'https://github.com/[your_github_username]/diaspora.git'<br />
set :branch, '[your_branch]'<br />
</pre><br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora-replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora-replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
Create a new branch or switch to existing one (eg. ''master'' or ''develop''). Lets say we want to switch to the ''develop'' branch:<br />
<br />
<pre><br />
cd src/<br />
git checkout develop<br />
cd ..<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.2<br />
</pre><br />
<br />
The line above is just an example, since you have to remember to choose the right ''rubies'' accordingly to ''.ruby-version'' file<br />
<br />
<pre><br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle install --with mysql postgresql<br />
</pre><br />
<br />
If ''bundle'' fails consider to update it with ''gem update bundler''<br />
<br />
<pre><br />
vagrant@development:~$ rake generate:secret_token<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Prepare test environment ==<br />
<br />
<pre><br />
vagrant@development:~$ rake db:test:prepare<br />
vagrant@development:~$ rake assets:generate_error_pages<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rspec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
Follow these steps in order to upgrade an existing installation of diaspora*. In this example we'll consider the production environment (you can apply the same instructions for ''staging'', ''development'' or user defined environment).<br />
<br />
<pre><br />
cd diaspora-replica/<br />
git pull --rebase origin master<br />
git submodule update<br />
<br />
vagrant up production<br />
vagrant provision production --provision-with puppet<br />
<br />
cd capistrano/<br />
cap production deploy<br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=4197Installation/Vagrant puppet capistrano2015-07-06T16:34:33Z<p>Joebew42: </p>
<hr />
<div>= Before you get started =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''Official github repository of the project''']<br />
<br />
You must to have installed on your computer Vagrant 1.7 or greater and Capistrano 3.1 or greater (to install Capistrano follow instructions below.)<br />
<br />
= Overview - What is diaspora*-replica? =<br />
<br />
The aim of this project is to provide a way to automate the provision and the deploy of a diaspora* POD through tools like [http://www.vagrantup.com/ '''Vagrant 2'''], [http://puppetlabs.com/ '''Puppet'''] and [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
* If you are a developer you can use these tools to setup a development environment<br />
* If you are a POD maintainer you can use these tools to automatically provision and configure machines (on a bare-metal server or cloud providers) and deploy diaspora* on it<br />
<br />
= Deploy diaspora* on local environment =<br />
<br />
If you want to try diaspora* without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle two environments: ''development'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the FQDNs for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora-replica<br />
git submodule update --init<br />
</pre><br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up production</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned and the bundler will install ruby gems.<br />
Once capistrano completed the deploy task, you can start diaspora through ''eye''<br />
<br />
<pre><br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30/40 seconds) and then your diaspora* installation will be up and running at ''http://production.diaspora.local''<br />
<br />
== Start, stop, restart and info ==<br />
<br />
You can use Capistrano tasks to start, stop, restart or get information about diaspora*<br />
<br />
<pre><br />
cap production diaspora:eye:start<br />
cap production diaspora:eye:stop<br />
cap production diaspora:eye:restart<br />
cap production diaspora:eye:info<br />
</pre><br />
<br />
== Deploy other branches ==<br />
<br />
If you want to deploy a different branch of diaspora* (ex. ''develop'' instead of ''master'') you have to update ''puppet/manifest/site.pp'' by specifying correct ''rvm'' and ''ruby'' version:<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora'<br />
}<br />
}<br />
</pre><br />
<br />
Set up the the ''repo_url'' and/or the ''branch'' that we want to deploy by editing ''capistrano/config/deploy/production.rb''<br />
<br />
<pre><br />
...<br />
set :repo_url, 'https://github.com/diaspora/diaspora.git'<br />
set :branch, 'develop'<br />
...<br />
</pre><br />
<br />
Execute the provision of the machine and the deploy of diaspora*<br />
<br />
<pre><br />
vagrant up production<br />
cd capistrano/<br />
cap production deploy<br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
Check out your diaspora* installation at ''http://production.diaspora.local''<br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy diaspora:eye:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== What if I want to deploy the branch master with Postgresql? ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
Add the generated Gemfile.lock under version control. In ''capistrano/config/deploy/production.rb'' you have to specify your git repository:<br />
<br />
<pre><br />
set :repo_url, 'https://github.com/[your_github_username]/diaspora.git'<br />
set :branch, '[your_branch]'<br />
</pre><br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora-replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora-replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.1<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake generate:secret_token<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Configure test environment ==<br />
<br />
<pre><br />
vagrant@development:~$ rake db:test:prepare<br />
vagrant@development:~$ bin/rake assets:generate_error_pages<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rspec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
Follow these steps in order to upgrade an existing installation of diaspora*. In this example we'll consider the production environment (you can apply the same instructions for ''staging'', ''development'' or user defined environment).<br />
<br />
<pre><br />
cd diaspora-replica/<br />
git pull --rebase origin master<br />
git submodule update<br />
<br />
vagrant up production<br />
vagrant provision production --provision-with puppet<br />
<br />
cd capistrano/<br />
cap production deploy<br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=4196Installation/Vagrant puppet capistrano2015-07-06T16:30:00Z<p>Joebew42: </p>
<hr />
<div>= Before you get started =<br />
<br />
You must to have installed on your computer Vagrant 1.7 or greater and Capistrano 3.1 or greater (to install Capistrano follow instructions below.)<br />
<br />
= Overview - What is diaspora*-replica? =<br />
<br />
The aim of this project is to provide a way to automate the provision and the deploy of a diaspora* POD through tools like [http://www.vagrantup.com/ '''Vagrant 2'''], [http://puppetlabs.com/ '''Puppet'''] and [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
* If you are a developer you can use these tools to setup a development environment<br />
* If you are a POD maintainer you can use these tools to automatically provision and configure machines (on a bare-metal server or cloud providers) and deploy diaspora* on it<br />
<br />
= Deploy diaspora* on local environment =<br />
<br />
If you want to try diaspora* without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle two environments: ''development'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the FQDNs for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora-replica<br />
git submodule update --init<br />
</pre><br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up production</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned and the bundler will install ruby gems.<br />
Once capistrano completed the deploy task, you can start diaspora through ''eye''<br />
<br />
<pre><br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30/40 seconds) and then your diaspora* installation will be up and running at ''http://production.diaspora.local''<br />
<br />
== Start, stop, restart and info ==<br />
<br />
You can use Capistrano tasks to start, stop, restart or get information about diaspora*<br />
<br />
<pre><br />
cap production diaspora:eye:start<br />
cap production diaspora:eye:stop<br />
cap production diaspora:eye:restart<br />
cap production diaspora:eye:info<br />
</pre><br />
<br />
== Deploy other branches ==<br />
<br />
If you want to deploy a different branch of diaspora* (ex. ''develop'' instead of ''master'') you have to update ''puppet/manifest/site.pp'' by specifying correct ''rvm'' and ''ruby'' version:<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora'<br />
}<br />
}<br />
</pre><br />
<br />
Set up the the ''repo_url'' and/or the ''branch'' that we want to deploy by editing ''capistrano/config/deploy/production.rb''<br />
<br />
<pre><br />
...<br />
set :repo_url, 'https://github.com/diaspora/diaspora.git'<br />
set :branch, 'develop'<br />
...<br />
</pre><br />
<br />
Execute the provision of the machine and the deploy of diaspora*<br />
<br />
<pre><br />
vagrant up production<br />
cd capistrano/<br />
cap production deploy<br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
Check out your diaspora* installation at ''http://production.diaspora.local''<br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy diaspora:eye:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== What if I want to deploy the branch master with Postgresql? ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
Add the generated Gemfile.lock under version control. In ''capistrano/config/deploy/production.rb'' you have to specify your git repository:<br />
<br />
<pre><br />
set :repo_url, 'https://github.com/[your_github_username]/diaspora.git'<br />
set :branch, '[your_branch]'<br />
</pre><br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora-replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora-replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.1<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake generate:secret_token<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Configure test environment ==<br />
<br />
<pre><br />
vagrant@development:~$ rake db:test:prepare<br />
vagrant@development:~$ bin/rake assets:generate_error_pages<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rspec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
Follow these steps in order to upgrade an existing installation of diaspora*. In this example we'll consider the production environment (you can apply the same instructions for ''staging'', ''development'' or user defined environment).<br />
<br />
<pre><br />
cd diaspora-replica/<br />
git pull --rebase origin master<br />
git submodule update<br />
<br />
vagrant up production<br />
vagrant provision production --provision-with puppet<br />
<br />
cd capistrano/<br />
cap production deploy<br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=4195Installation/Vagrant puppet capistrano2015-07-06T16:27:51Z<p>Joebew42: </p>
<hr />
<div>= Before you get started =<br />
<br />
You must to have installed on your computer Vagrant 1.7 or greater and Capistrano 3.1 or greater (to install Capistrano follow instructions below.)<br />
<br />
= Overview - What is diaspora*-replica? =<br />
<br />
The aim of this project is to provide a way to automate the provision and the deploy of a diaspora* POD through tools like [http://www.vagrantup.com/ '''Vagrant 2'''], [http://puppetlabs.com/ '''Puppet'''] and [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
* If you are a developer you can use these tools to setup a development environment<br />
* If you are a POD maintainer you can use these tools to automatically provision and configure machines (on a bare-metal server or cloud providers) and deploy diaspora* on it<br />
<br />
= Deploy diaspora* on local environment =<br />
<br />
If you want to try diaspora* without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle two environments: ''development'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the FQDNs for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora-replica<br />
git submodule update --init<br />
</pre><br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up production</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned and the bundler will install ruby gems.<br />
Once capistrano completed the deploy task, you can start diaspora through ''foreman''<br />
<br />
<pre><br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30/40 seconds) and then your diaspora* installation will be up and running at ''http://production.diaspora.local''<br />
<br />
== Start, stop, restart and info ==<br />
<br />
You can use Capistrano tasks to start, stop, restart or get information about diaspora*<br />
<br />
<pre><br />
cap production diaspora:eye:start<br />
cap production diaspora:eye:stop<br />
cap production diaspora:eye:restart<br />
cap production diaspora:eye:info<br />
</pre><br />
<br />
== Deploy other branches ==<br />
<br />
If you want to deploy a different branch of diaspora* (ex. ''develop'' instead of ''master'') you have to update ''puppet/manifest/site.pp'' by specifying correct ''rvm'' and ''ruby'' version:<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora'<br />
}<br />
}<br />
</pre><br />
<br />
Set up the the ''repo_url'' and/or the ''branch'' that we want to deploy by editing ''capistrano/config/deploy/production.rb''<br />
<br />
<pre><br />
...<br />
set :repo_url, 'https://github.com/diaspora/diaspora.git'<br />
set :branch, 'develop'<br />
...<br />
</pre><br />
<br />
Execute the provision of the machine and the deploy of diaspora*<br />
<br />
<pre><br />
vagrant up production<br />
cd capistrano/<br />
cap production deploy<br />
cap production diaspora:eye:start<br />
</pre><br />
<br />
Check out your diaspora* installation at ''http://production.diaspora.local''<br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy foreman:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== What if I want to deploy the branch master with Postgresql? ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
Add the generated Gemfile.lock under version control. In ''capistrano/config/deploy/production.rb'' you have to specify your git repository:<br />
<br />
<pre><br />
set :repo_url, 'https://github.com/[your_github_username]/diaspora.git'<br />
set :branch, '[your_branch]'<br />
</pre><br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora-replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora-replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.1<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake generate:secret_token<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Configure test environment ==<br />
<br />
<pre><br />
vagrant@development:~$ rake db:test:prepare<br />
vagrant@development:~$ bin/rake assets:generate_error_pages<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rspec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
Follow these steps in order to upgrade an existing installation of diaspora*. In this example we'll consider the production environment (you can apply the same instructions for ''staging'', ''development'' or user defined environment).<br />
<br />
<pre><br />
cd diaspora-replica/<br />
git pull --rebase origin master<br />
git submodule update<br />
<br />
vagrant up production<br />
vagrant provision production --provision-with puppet<br />
<br />
cd capistrano/<br />
cap production deploy<br />
cap production foreman:restart<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=4084Installation/Vagrant puppet capistrano2015-05-09T21:46:40Z<p>Joebew42: /* Deploy diaspora* on local environment */</p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy diaspora* on local environment =<br />
<br />
If you want to try diaspora* without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up production</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned and the bundler will install ruby gems.<br />
Once capistrano completed the deploy task, you can start diaspora through ''foreman''<br />
<br />
<pre><br />
cap production foreman:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30/40 seconds) and then your diaspora* installation will be up and running at ''http://production.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap production foreman:start<br />
cap production foreman:stop<br />
cap production foreman:restart<br />
</pre><br />
<br />
== Deploy other branches ==<br />
<br />
If you want to deploy a different branch of diaspora* (ex. ''develop'' instead of ''master'') you have to update ''puppet/manifest/site.pp'' by specifying correct ''rvm'' and ''ruby'' version:<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Set up the the ''repo_url'' and/or the ''branch'' that we want to deploy by editing ''capistrano/config/deploy/production.rb''<br />
<br />
<pre><br />
...<br />
set :repo_url, 'https://github.com/diaspora/diaspora.git'<br />
set :branch, 'develop'<br />
...<br />
</pre><br />
<br />
Execute the provision of the machine and the deploy of diaspora*<br />
<br />
<pre><br />
vagrant up production<br />
cd capistrano/<br />
cap production deploy<br />
cap production foreman:start<br />
</pre><br />
<br />
Check out your diaspora* installation at ''http://production.diaspora.local''<br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy foreman:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.1<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake generate:secret_token<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rspec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
Follow these steps in order to upgrade an existing installation of diaspora*. In this example we'll consider the production environment (you can apply the same instructions for ''staging'', ''development'' or user defined environment).<br />
<br />
<pre><br />
cd diaspora-replica/<br />
git pull --rebase origin master<br />
git submodule update<br />
<br />
vagrant up production<br />
vagrant provision production --provision-with puppet<br />
<br />
cd capistrano/<br />
cap production deploy<br />
cap production foreman:restart<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=4083Installation/Vagrant puppet capistrano2015-05-09T21:46:22Z<p>Joebew42: </p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy diaspora* on local environment =<br />
<br />
If you you want to try diaspora* without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up production</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned and the bundler will install ruby gems.<br />
Once capistrano completed the deploy task, you can start diaspora through ''foreman''<br />
<br />
<pre><br />
cap production foreman:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30/40 seconds) and then your diaspora* installation will be up and running at ''http://production.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap production foreman:start<br />
cap production foreman:stop<br />
cap production foreman:restart<br />
</pre><br />
<br />
== Deploy other branches ==<br />
<br />
If you want to deploy a different branch of diaspora* (ex. ''develop'' instead of ''master'') you have to update ''puppet/manifest/site.pp'' by specifying correct ''rvm'' and ''ruby'' version:<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Set up the the ''repo_url'' and/or the ''branch'' that we want to deploy by editing ''capistrano/config/deploy/production.rb''<br />
<br />
<pre><br />
...<br />
set :repo_url, 'https://github.com/diaspora/diaspora.git'<br />
set :branch, 'develop'<br />
...<br />
</pre><br />
<br />
Execute the provision of the machine and the deploy of diaspora*<br />
<br />
<pre><br />
vagrant up production<br />
cd capistrano/<br />
cap production deploy<br />
cap production foreman:start<br />
</pre><br />
<br />
Check out your diaspora* installation at ''http://production.diaspora.local''<br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy foreman:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.1<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake generate:secret_token<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rspec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
Follow these steps in order to upgrade an existing installation of diaspora*. In this example we'll consider the production environment (you can apply the same instructions for ''staging'', ''development'' or user defined environment).<br />
<br />
<pre><br />
cd diaspora-replica/<br />
git pull --rebase origin master<br />
git submodule update<br />
<br />
vagrant up production<br />
vagrant provision production --provision-with puppet<br />
<br />
cd capistrano/<br />
cap production deploy<br />
cap production foreman:restart<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=4059Installation/Vagrant puppet capistrano2015-05-03T17:45:53Z<p>Joebew42: /* How to upgrade diaspora*-replica */</p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy diaspora* on local environment =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up production</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned and the bundler will install ruby gems.<br />
Once capistrano completed the deploy task, you can start diaspora through ''foreman''<br />
<br />
<pre><br />
cap production foreman:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30 seconds) and then your diaspora* installation will be up and running at ''http://production.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap production foreman:start<br />
cap production foreman:stop<br />
cap production foreman:restart<br />
</pre><br />
<br />
== Deploy other branches ==<br />
<br />
If you want to deploy a different branch of diaspora* (ex. ''develop'' instead of ''master'') you have to update ''puppet/manifest/site.pp'' by specifying correct ''rvm'' and ''ruby'' version:<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Set up the the ''repo_url'' and/or the ''branch'' that we want to deploy by editing ''capistrano/config/deploy/production.rb''<br />
<br />
<pre><br />
...<br />
set :repo_url, 'https://github.com/diaspora/diaspora.git'<br />
set :branch, 'develop'<br />
...<br />
</pre><br />
<br />
Execute the provision of the machine and the deploy of diaspora*<br />
<br />
<pre><br />
vagrant up production<br />
cd capistrano/<br />
cap production deploy<br />
cap production foreman:start<br />
</pre><br />
<br />
Check out your diaspora* installation at ''http://production.diaspora.local''<br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy foreman:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.1<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake generate:secret_token<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rspec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
Follow these steps in order to upgrade an existing installation of diaspora*. In this example we'll consider the production environment (you can apply the same instructions for ''staging'', ''development'' or user defined environment).<br />
<br />
<pre><br />
cd diaspora-replica/<br />
git pull --rebase origin master<br />
git submodule update<br />
<br />
vagrant up production<br />
vagrant provision production --provision-with puppet<br />
<br />
cd capistrano/<br />
cap production deploy<br />
cap production foreman:restart<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=4058Installation/Vagrant puppet capistrano2015-05-03T17:20:21Z<p>Joebew42: /* Using PostgreSQL Database */</p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy diaspora* on local environment =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up production</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned and the bundler will install ruby gems.<br />
Once capistrano completed the deploy task, you can start diaspora through ''foreman''<br />
<br />
<pre><br />
cap production foreman:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30 seconds) and then your diaspora* installation will be up and running at ''http://production.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap production foreman:start<br />
cap production foreman:stop<br />
cap production foreman:restart<br />
</pre><br />
<br />
== Deploy other branches ==<br />
<br />
If you want to deploy a different branch of diaspora* (ex. ''develop'' instead of ''master'') you have to update ''puppet/manifest/site.pp'' by specifying correct ''rvm'' and ''ruby'' version:<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Set up the the ''repo_url'' and/or the ''branch'' that we want to deploy by editing ''capistrano/config/deploy/production.rb''<br />
<br />
<pre><br />
...<br />
set :repo_url, 'https://github.com/diaspora/diaspora.git'<br />
set :branch, 'develop'<br />
...<br />
</pre><br />
<br />
Execute the provision of the machine and the deploy of diaspora*<br />
<br />
<pre><br />
vagrant up production<br />
cd capistrano/<br />
cap production deploy<br />
cap production foreman:start<br />
</pre><br />
<br />
Check out your diaspora* installation at ''http://production.diaspora.local''<br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy foreman:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.1<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake generate:secret_token<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rspec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
<pre><br />
cd diaspora-replica<br />
git pull --rebase origin master<br />
git submodule update<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=4057Installation/Vagrant puppet capistrano2015-05-03T17:19:59Z<p>Joebew42: /* Deploy diaspora* with Capistrano */</p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy diaspora* on local environment =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up production</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned and the bundler will install ruby gems.<br />
Once capistrano completed the deploy task, you can start diaspora through ''foreman''<br />
<br />
<pre><br />
cap production foreman:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30 seconds) and then your diaspora* installation will be up and running at ''http://production.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap production foreman:start<br />
cap production foreman:stop<br />
cap production foreman:restart<br />
</pre><br />
<br />
== Deploy other branches ==<br />
<br />
If you want to deploy a different branch of diaspora* (ex. ''develop'' instead of ''master'') you have to update ''puppet/manifest/site.pp'' by specifying correct ''rvm'' and ''ruby'' version:<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Set up the the ''repo_url'' and/or the ''branch'' that we want to deploy by editing ''capistrano/config/deploy/production.rb''<br />
<br />
<pre><br />
...<br />
set :repo_url, 'https://github.com/diaspora/diaspora.git'<br />
set :branch, 'develop'<br />
...<br />
</pre><br />
<br />
Execute the provision of the machine and the deploy of diaspora*<br />
<br />
<pre><br />
vagrant up production<br />
cd capistrano/<br />
cap production deploy<br />
cap production foreman:start<br />
</pre><br />
<br />
Check out your diaspora* installation at ''http://production.diaspora.local''<br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy foreman:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.1<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake generate:secret_token<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rspec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
<pre><br />
cd diaspora-replica<br />
git pull --rebase origin master<br />
git submodule update<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=3827Installation/Vagrant puppet capistrano2015-01-13T02:23:55Z<p>Joebew42: /* Deploy diaspora* on local */</p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy diaspora* on local environment =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up production</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned.<br />
Once capistrano completed the deploy task, you can start diaspora through ''foreman''<br />
<br />
<pre><br />
cap production foreman:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30 seconds) and then your diaspora* installation will be up and running at ''http://production.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap production foreman:start<br />
cap production foreman:stop<br />
cap production foreman:restart<br />
</pre><br />
<br />
== Deploy other branches ==<br />
<br />
If you want to deploy a different branch of diaspora* (ex. ''develop'' instead of ''master'') you have to update ''puppet/manifest/site.pp'' by specifying correct ''rvm'' and ''ruby'' version:<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Set up the the ''repo_url'' and/or the ''branch'' that we want to deploy by editing ''capistrano/config/deploy/production.rb''<br />
<br />
<pre><br />
...<br />
set :repo_url, 'https://github.com/diaspora/diaspora.git'<br />
set :branch, 'develop'<br />
...<br />
</pre><br />
<br />
Execute the provision of the machine and the deploy of diaspora*<br />
<br />
<pre><br />
vagrant up production<br />
cd capistrano/<br />
cap production deploy<br />
cap production foreman:start<br />
</pre><br />
<br />
Check out your diaspora* installation at ''http://production.diaspora.local''<br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy foreman:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.1<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake generate:secret_token<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rspec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
<pre><br />
cd diaspora-replica<br />
git pull --rebase origin master<br />
git submodule update<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=3826Installation/Vagrant puppet capistrano2015-01-13T02:21:07Z<p>Joebew42: /* Deploy other branches */</p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy diaspora* on local =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up production</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned.<br />
Once capistrano completed the deploy task, you can start diaspora through ''foreman''<br />
<br />
<pre><br />
cap production foreman:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30 seconds) and then your diaspora* installation will be up and running at ''http://production.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap production foreman:start<br />
cap production foreman:stop<br />
cap production foreman:restart<br />
</pre><br />
<br />
== Deploy other branches ==<br />
<br />
If you want to deploy a different branch of diaspora* (ex. ''develop'' instead of ''master'') you have to update ''puppet/manifest/site.pp'' by specifying correct ''rvm'' and ''ruby'' version:<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Set up the the ''repo_url'' and/or the ''branch'' that we want to deploy by editing ''capistrano/config/deploy/production.rb''<br />
<br />
<pre><br />
...<br />
set :repo_url, 'https://github.com/diaspora/diaspora.git'<br />
set :branch, 'develop'<br />
...<br />
</pre><br />
<br />
Execute the provision of the machine and the deploy of diaspora*<br />
<br />
<pre><br />
vagrant up production<br />
cd capistrano/<br />
cap production deploy<br />
cap production foreman:start<br />
</pre><br />
<br />
Check out your diaspora* installation at ''http://production.diaspora.local''<br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy foreman:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.1<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake generate:secret_token<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rspec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
<pre><br />
cd diaspora-replica<br />
git pull --rebase origin master<br />
git submodule update<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=3822Installation/Vagrant puppet capistrano2015-01-12T08:51:09Z<p>Joebew42: /* Deploy diaspora* with Capistrano */</p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy diaspora* on local =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up production</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned.<br />
Once capistrano completed the deploy task, you can start diaspora through ''foreman''<br />
<br />
<pre><br />
cap production foreman:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30 seconds) and then your diaspora* installation will be up and running at ''http://production.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap production foreman:start<br />
cap production foreman:stop<br />
cap production foreman:restart<br />
</pre><br />
<br />
== Deploy other branches ==<br />
<br />
If you want to deploy a different branch of diaspora* (ex. ''develop'' instead of ''master'') you have to update ''puppet/manifest/site.pp'' by specifying correct ''rvm'' and ''ruby'' version:<br />
<br />
<pre><br />
node 'production.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Set up the the ''repo_url'' and/or the ''branch'' that we want to deploy by editing ''capistrano/config/deploy/production.rb''<br />
<br />
<pre><br />
...<br />
set :repo_url, 'https://github.com/diaspora/diaspora.git'<br />
set :branch, 'develop'<br />
...<br />
</pre><br />
<br />
Execute the provision of the machine and the deploy of diaspora*<br />
<br />
<pre><br />
vagrant up production<br />
cd capistrano/<br />
cap production deploy<br />
cap production foreman:start<br />
</pre><br />
<br />
Check out your diaspora* installation at ''http://production.diaspora.local''<br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy foreman:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.1<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake generate:secret_token<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rspec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
<pre><br />
cd diaspora-replica<br />
git pull --rebase origin master<br />
git submodule update<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=3821Installation/Vagrant puppet capistrano2015-01-12T08:48:16Z<p>Joebew42: </p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy diaspora* on local =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up production</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned.<br />
Once capistrano completed the deploy task, you can start diaspora through ``foreman``<br />
<br />
<pre><br />
cap production foreman:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30 seconds) and then your diaspora* installation will be up and running at ''http://production.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap production foreman:start<br />
cap production foreman:stop<br />
cap production foreman:restart<br />
</pre><br />
<br />
== Deploy other branches ==<br />
<br />
If you want to deploy a different branch of diaspora* (ex. ''develop'' instead of ''master'') you have to update ''puppet/manifest/site.pp'' by specifying correct ''rvm'' and ''ruby'' version:<br />
<br />
<pre><br />
node 'production.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Set up the the ''repo_url'' and/or the ''branch'' that we want to deploy by editing ''capistrano/config/deploy/production.rb''<br />
<br />
<pre><br />
...<br />
set :repo_url, 'https://github.com/diaspora/diaspora.git'<br />
set :branch, 'develop'<br />
...<br />
</pre><br />
<br />
Execute the provision of the machine and the deploy of diaspora*<br />
<br />
<pre><br />
vagrant up production<br />
cd capistrano/<br />
cap production deploy<br />
cap production foreman:start<br />
</pre><br />
<br />
Check out your diaspora* installation at ''http://production.diaspora.local''<br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy foreman:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.1<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake generate:secret_token<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rspec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
<pre><br />
cd diaspora-replica<br />
git pull --rebase origin master<br />
git submodule update<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=3809Installation/Vagrant puppet capistrano2015-01-01T13:11:45Z<p>Joebew42: /* puppets/manifests/site.pp */</p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned.<br />
Once capistrano completed the deploy task, you can start diaspora through ``foreman``<br />
<br />
<pre><br />
cap development foreman:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30 seconds) and then your diaspora* installation will be up and running at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development foreman:start<br />
cap development foreman:stop<br />
cap development foreman:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy foreman:start<br />
</pre><br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy foreman:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.1<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake generate:secret_token<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rspec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
<pre><br />
cd diaspora-replica<br />
git pull --rebase origin master<br />
git submodule update<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=3808Installation/Vagrant puppet capistrano2014-12-31T21:18:07Z<p>Joebew42: /* Run all tests */</p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned.<br />
Once capistrano completed the deploy task, you can start diaspora through ``foreman``<br />
<br />
<pre><br />
cap development foreman:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30 seconds) and then your diaspora* installation will be up and running at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development foreman:start<br />
cap development foreman:stop<br />
cap development foreman:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy foreman:start<br />
</pre><br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy foreman:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.1<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake generate:secret_token<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rspec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
<pre><br />
cd diaspora-replica<br />
git pull --rebase origin master<br />
git submodule update<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=3807Installation/Vagrant puppet capistrano2014-12-31T21:17:58Z<p>Joebew42: /* Install gems and create databases */</p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned.<br />
Once capistrano completed the deploy task, you can start diaspora through ``foreman``<br />
<br />
<pre><br />
cap development foreman:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30 seconds) and then your diaspora* installation will be up and running at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development foreman:start<br />
cap development foreman:stop<br />
cap development foreman:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy foreman:start<br />
</pre><br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy foreman:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.1<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake generate:secret_token<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rake spec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
<pre><br />
cd diaspora-replica<br />
git pull --rebase origin master<br />
git submodule update<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=3806Installation/Vagrant puppet capistrano2014-12-31T18:53:41Z<p>Joebew42: /* puppets/manifests/site.pp */</p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned.<br />
Once capistrano completed the deploy task, you can start diaspora through ``foreman``<br />
<br />
<pre><br />
cap development foreman:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30 seconds) and then your diaspora* installation will be up and running at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development foreman:start<br />
cap development foreman:stop<br />
cap development foreman:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy foreman:start<br />
</pre><br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and adjust settings, if needed.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy foreman:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.1<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rake spec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
<pre><br />
cd diaspora-replica<br />
git pull --rebase origin master<br />
git submodule update<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=3805Installation/Vagrant puppet capistrano2014-12-31T18:44:32Z<p>Joebew42: </p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned.<br />
Once capistrano completed the deploy task, you can start diaspora through ``foreman``<br />
<br />
<pre><br />
cap development foreman:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30 seconds) and then your diaspora* installation will be up and running at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development foreman:start<br />
cap development foreman:stop<br />
cap development foreman:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy foreman:start<br />
</pre><br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy foreman:start<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.1<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rake spec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
<pre><br />
cd diaspora-replica<br />
git pull --rebase origin master<br />
git submodule update<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=3804Installation/Vagrant puppet capistrano2014-12-31T18:31:34Z<p>Joebew42: /* Deploy a development pod */</p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned.<br />
Once capistrano completed the deploy task, you can start diaspora through ``foreman``<br />
<br />
<pre><br />
cap development foreman:start<br />
</pre><br />
<br />
Wait until unicorn workers are ready (about 30 seconds) and then your diaspora* installation will be up and running at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development foreman:start<br />
cap development foreman:stop<br />
cap development foreman:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.1<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rake spec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
<pre><br />
cd diaspora-replica<br />
git pull --rebase origin master<br />
git submodule update<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=3803Installation/Vagrant puppet capistrano2014-12-31T15:49:50Z<p>Joebew42: /* Configure Rubies and Gemsets */</p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy deploy:restart<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned. Once capistrano completed the deploy task your diaspora* installation is up and running at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.1<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rake spec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
<pre><br />
cd diaspora-replica<br />
git pull --rebase origin master<br />
git submodule update<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=3802Installation/Vagrant puppet capistrano2014-12-31T15:49:05Z<p>Joebew42: /* Deploy a real diaspora* POD */</p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy deploy:restart<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned. Once capistrano completed the deploy task your diaspora* installation is up and running at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Deploy diaspora* on production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.26.3',<br />
ruby_version => '2.1.5',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root',<br />
unicorn_worker => 4,<br />
sidekiq_concurrency => 5,<br />
sidekiq_retry => 10,<br />
sidekiq_namespace => 'diaspora',<br />
foreman_web => 1,<br />
foreman_sidekiq => 1<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.0.0<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rake spec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
<pre><br />
cd diaspora-replica<br />
git pull --rebase origin master<br />
git submodule update<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=3801Installation/Vagrant puppet capistrano2014-12-31T15:41:37Z<p>Joebew42: /* Configure a fake FQDN in your system */</p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure FQDNs in your system ==<br />
<br />
Vagrantfile, Puppet and Capistrano are already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. If you want to try them you have to update ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy deploy:restart<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned. Once capistrano completed the deploy task your diaspora* installation is up and running at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Deploy a real diaspora* POD =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.0.0<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rake spec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
<pre><br />
cd diaspora-replica<br />
git pull --rebase origin master<br />
git submodule update<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=3781Installation/Vagrant puppet capistrano2014-12-29T19:13:22Z<p>Joebew42: /* Deploy diaspora* with Capistrano */</p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure a fake FQDN in your system ==<br />
<br />
You will find a Vagrantfile, Puppet and Capistrano already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. Before start using these tools is necessary to update your ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy deploy:restart<br />
</pre><br />
<br />
When executed the first time, this step can take several minutes (about 20, based on your internet connection), because the diaspora git repository must be cloned. Once capistrano completed the deploy task your diaspora* installation is up and running at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Deploy a real diaspora* POD =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.0.0<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rake spec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
<pre><br />
cd diaspora-replica<br />
git pull --rebase origin master<br />
git submodule update<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=3761Installation/Vagrant puppet capistrano2014-12-22T13:04:46Z<p>Joebew42: </p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure a fake FQDN in your system ==<br />
<br />
You will find a Vagrantfile, Puppet and Capistrano already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. Before start using these tools is necessary to update your ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy deploy:restart<br />
</pre><br />
<br />
Now, your diaspora* installation is up and running, you can go visit it at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Deploy a real diaspora* POD =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica/<br />
git submodule update --init<br />
</pre><br />
<br />
== Cloning your git repository in src/ directory ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''). For better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica/<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.0.0<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rake spec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
<pre><br />
cd diaspora-replica<br />
git pull --rebase origin master<br />
git submodule update<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Getting_started_with_contributing&diff=3760Getting started with contributing2014-12-22T12:59:47Z<p>Joebew42: /* Other helpful resources */</p>
<hr />
<div>{{Languages}}<br />
A lot of new contributors that want to dive in to helping fix bugs and develop new awesome things often ask "Well, where do I start?". Below are some links to comprehensive resources so that newcomers can get up to speed and get dive right in to fixing bugs.<br />
<br />
== Getting started with git and GitHub ==<br />
<br />
All of Diaspora's code is hosted on [http://github.com/diaspora/diaspora GitHub], a social coding platform that leverages [http://en.wikipedia.org/git Git] for many different Free and Open Source projects. You can use any operating system to contribute with GitHub, all you need is an account and to follow GitHub's easy and helpful [http://help.github.com/linux-set-up-git/ guide] for setting up your account from the command line and learning to use the commands. Git is supported on all major platforms.<br />
<br />
Once you're all set up, check out the [https://github.com/diaspora/diaspora/issues issue tracker] and watch for entries tagged with "''[https://github.com/diaspora/diaspora/issues?labels=newcomer newcomer]''" or "''[https://github.com/diaspora/diaspora/issues?labels=quickfix quickfix]''". Most often those are the things which you don't need a deep understanding of the complete codebase for to work on them, and the tasks should be easy enough for novice programmers to tackle.<br />
<br />
== All about bugs ==<br />
<br />
There are some different things about bugs that you ought to know, specifically, [[How_to_Report_a_Bug|how to report a bug]], and [[How_to_work_on_bugs|how to claim and fix a bug]]. Both incorporate well into our GitHub-based workflow, and is designed to make the process of fixing bugs easier for everybody.<br />
<br />
== How to contribute the right way ==<br />
<br />
Diaspora's development tries its very best to stick to a set of guidelines when it comes to contributing code. When you're writing a bugfix or custom code from scratch, it's good practice to ask yourself:<br />
<br />
* Does my code have [[Testing Workflow | tests]]?<br />
* Am I sticking to the [[Git Workflow]] the best I can?<br />
<br />
== Other helpful resources ==<br />
<br />
Below are some helpful relevant links to other parts of the wiki. We're currently restructuring everything, so the below links may be subject to change.<br />
<br />
* [[Required Gems Overview|An Overview of Required Ruby Gems]]<br />
* [[Installation|How to get a dev environment set up]]<br />
* [[Installation/Vagrant_puppet_capistrano#How_to_set_up_a_Development_Environment|How to set up a Development Environment with Vagrant and Puppet]]<br />
* [[An Introduction to the Diaspora Source|A Detailed Introduction to the Source Code]]<br />
<br />
[[Category:Developers]]<br />
[[Category:Github transfer done]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=3758Installation/Vagrant puppet capistrano2014-12-22T11:33:49Z<p>Joebew42: </p>
<hr />
<div>= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure a fake FQDN in your system ==<br />
<br />
You will find a Vagrantfile, Puppet and Capistrano already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. Before start using these tools is necessary to update your ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy deploy:restart<br />
</pre><br />
<br />
Now, your diaspora* installation is up and running, you can go visit it at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Deploy a real diaspora* POD =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Cloning your git repo to your host ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''), for better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.0.0<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rake spec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
<pre><br />
cd diaspora-replica<br />
git pull --rebase origin master<br />
git submodule update<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation&diff=3757Installation2014-12-22T11:32:57Z<p>Joebew42: </p>
<hr />
<div>__NOTOC__ __NOEDITSECTION__<br />
<div style="display:none"><br />
{{#css:<br />
#installation { <br />
display: -webkit-flex;<br />
display: -moz-flex;<br />
display: -ms-flex;<br />
display: flex;<br />
<br />
-webkit-flex-flow: row wrap;<br />
-moz-flex-flow: row wrap;<br />
-ms-flex-flow: row wrap;<br />
flex-flow: row wrap;<br />
}<br />
#installation .option {<br />
text-align: center;<br />
vertical-align: top;<br />
border: 1em solid #F5F5F5;<br />
/*border-bottom: none;*/<br />
margin: 0 -1em -1em 0;<br />
padding-bottom: 1.5em;<br />
}<br />
#installation .icon:before {<br />
content: '';<br />
display: inline-block;<br />
height: 180px;<br />
vertical-align: middle;<br />
} <br />
#installation .option table {<br />
width: 100% !important;<br />
}<br />
#installation ul {<br />
margin: 0.5em;<br />
list-style:none;<br />
}<br />
<br />
.flex-2third {<br />
-webkit-flex: 2 62.9%;<br />
-moz-flex: 2 62.9%;<br />
-ms-flex: 2 62.9%;<br />
flex: 2 62.9%;<br />
}<br />
.flex-1third {<br />
-webkit-flex: 1 30.9%;<br />
-moz-flex: 1 30.9%;<br />
-ms-flex: 1 30.9%;<br />
flex: 1 30.9%;<br />
}<br />
.flex-half {<br />
-webkit-flex: 1 47.9%;<br />
-moz-flex: 1 47.9%;<br />
-ms-flex: 1 47.9%;<br />
flex: 1 47.9%;<br />
}<br />
.flex-full {<br />
-webkit-flex: 1 97.9%;<br />
-moz-flex: 1 97.9%;<br />
-ms-flex: 1 97.9%;<br />
flex: 1 97.9%;<br />
}<br />
@supports (not (flex-wrap: wrap)) {<br />
#installation { display: block }<br />
#installation > div { display: inline-block; }<br />
.flex-2third { width: 65%; }<br />
.flex-1third { width: 32%; }<br />
.flex-half { width: 48.5%; }<br />
.flex-full { width: 98%; }<br />
}<br />
<br />
#installation #linux { }<br />
#installation #osx { padding-bottom: 3.35em; }<br />
#installation #bsd { }<br />
#installation #paas { padding-bottom: 1.5em; }<br />
#installation #windows { padding-bottom: 4.65em; }<br />
#installation #development { }<br />
<br />
}}<br />
</div><br />
<br />
<div id="installation"><br />
<div id="linux" class="option flex-2third"><br />
<br />
{{:Installation/Linux}}<br />
<br />
</div><!-- /Linux --><!-- stupid whitespace<br />
--><div id="osx" class="option flex-1third"><br />
<br />
{{:Installation/Mac OS}}<br />
<br />
</div><!-- /MacOS --><!-- stupid whitespace<br />
--><div id="bsd" class="option flex-1third"><br />
<br />
{{:Installation/BSD}}<br />
<br />
</div><!-- /BSD --><!-- stupid whitespace<br />
--><div id="paas" class="option flex-1third"><br />
<br />
{{:Installation/PaaS}}<br />
<br />
</div><!-- /PaaS --><!-- stupid whitespace<br />
--><div id="vagrant_puppet_capistrano" class="option flex-1third"><br />
<br />
{{:Installation/Vagrant_puppet_capistrano_info}}<br />
<br />
</div><!-- /vagrant_puppet_capistrano --><!-- stupid whitespace<br />
--><div id="development" class="option flex-2third"><br />
<br />
{{:Installation/Development Setup}}<br />
<br />
</div><!-- /development --><!-- stupid whitespace<br />
--><div id="windows" class="option flex-1third"><br />
<br />
{{:Installation/Windows}}<br />
<br />
</div><!-- /windows --><br />
<br />
</div><!-- /container --><br />
<br />
[[Category:Installation]]<br />
[[Category:Podmin]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=File:Vagrant-puppet.png&diff=3755File:Vagrant-puppet.png2014-12-22T11:23:47Z<p>Joebew42: </p>
<hr />
<div></div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation&diff=3754Installation2014-12-22T11:20:00Z<p>Joebew42: </p>
<hr />
<div>__NOTOC__ __NOEDITSECTION__<br />
<div style="display:none"><br />
{{#css:<br />
#installation { <br />
display: -webkit-flex;<br />
display: -moz-flex;<br />
display: -ms-flex;<br />
display: flex;<br />
<br />
-webkit-flex-flow: row wrap;<br />
-moz-flex-flow: row wrap;<br />
-ms-flex-flow: row wrap;<br />
flex-flow: row wrap;<br />
}<br />
#installation .option {<br />
text-align: center;<br />
vertical-align: top;<br />
border: 1em solid #F5F5F5;<br />
/*border-bottom: none;*/<br />
margin: 0 -1em -1em 0;<br />
padding-bottom: 1.5em;<br />
}<br />
#installation .icon:before {<br />
content: '';<br />
display: inline-block;<br />
height: 180px;<br />
vertical-align: middle;<br />
} <br />
#installation .option table {<br />
width: 100% !important;<br />
}<br />
#installation ul {<br />
margin: 0.5em;<br />
list-style:none;<br />
}<br />
<br />
.flex-2third {<br />
-webkit-flex: 2 62.9%;<br />
-moz-flex: 2 62.9%;<br />
-ms-flex: 2 62.9%;<br />
flex: 2 62.9%;<br />
}<br />
.flex-1third {<br />
-webkit-flex: 1 30.9%;<br />
-moz-flex: 1 30.9%;<br />
-ms-flex: 1 30.9%;<br />
flex: 1 30.9%;<br />
}<br />
.flex-half {<br />
-webkit-flex: 1 47.9%;<br />
-moz-flex: 1 47.9%;<br />
-ms-flex: 1 47.9%;<br />
flex: 1 47.9%;<br />
}<br />
.flex-full {<br />
-webkit-flex: 1 97.9%;<br />
-moz-flex: 1 97.9%;<br />
-ms-flex: 1 97.9%;<br />
flex: 1 97.9%;<br />
}<br />
@supports (not (flex-wrap: wrap)) {<br />
#installation { display: block }<br />
#installation > div { display: inline-block; }<br />
.flex-2third { width: 65%; }<br />
.flex-1third { width: 32%; }<br />
.flex-half { width: 48.5%; }<br />
.flex-full { width: 98%; }<br />
}<br />
<br />
#installation #linux { }<br />
#installation #osx { padding-bottom: 3.35em; }<br />
#installation #bsd { }<br />
#installation #paas { padding-bottom: 1.5em; }<br />
#installation #windows { padding-bottom: 4.65em; }<br />
#installation #development { }<br />
<br />
}}<br />
</div><br />
<br />
<div id="installation"><br />
<div id="linux" class="option flex-2third"><br />
<br />
{{:Installation/Linux}}<br />
<br />
</div><!-- /Linux --><!-- stupid whitespace<br />
--><div id="osx" class="option flex-1third"><br />
<br />
{{:Installation/Mac OS}}<br />
<br />
</div><!-- /MacOS --><!-- stupid whitespace<br />
--><div id="bsd" class="option flex-1third"><br />
<br />
{{:Installation/BSD}}<br />
<br />
</div><!-- /BSD --><!-- stupid whitespace<br />
--><div id="paas" class="option flex-1third"><br />
<br />
{{:Installation/PaaS}}<br />
<br />
</div><!-- /PaaS --><!-- stupid whitespace<br />
--><div id="windows" class="option flex-1third"><br />
<br />
{{:Installation/Windows}}<br />
<br />
</div><!-- /windows --><!-- stupid whitespace<br />
--><div id="development" class="option flex-2third"><br />
<br />
{{:Installation/Development Setup}}<br />
<br />
</div><!-- /development --><!-- stupid whitespace<br />
--><div id="vagrant_puppet_capistrano" class="option flex-1third"><br />
<br />
{{:Installation/Vagrant_puppet_capistrano_info}}<br />
<br />
</div><!-- /vagrant_puppet_capistrano --><br />
<br />
</div><!-- /container --><br />
<br />
[[Category:Installation]]<br />
[[Category:Podmin]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=3691Installation/Vagrant puppet capistrano2014-12-07T21:49:57Z<p>Joebew42: </p>
<hr />
<div>{{Work in progress}}<br />
<br />
= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure a fake FQDN in your system ==<br />
<br />
You will find a Vagrantfile, Puppet and Capistrano already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. Before start using these tools is necessary to update your ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy deploy:restart<br />
</pre><br />
<br />
Now, your diaspora* installation is up and running, you can go visit it at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Deploy a real diaspora* POD =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Cloning your git repo to your host ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''), for better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.0.0<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rake spec<br />
</pre><br />
<br />
= How to upgrade diaspora*-replica =<br />
<br />
<pre><br />
cd diaspora-replica<br />
git pull --rebase origin master<br />
git submodule update<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=2827Installation/Vagrant puppet capistrano2014-05-13T00:04:14Z<p>Joebew42: /* How to contribute this project */</p>
<hr />
<div>{{Work in progress}}<br />
<br />
= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure a fake FQDN in your system ==<br />
<br />
You will find a Vagrantfile, Puppet and Capistrano already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. Before start using these tools is necessary to update your ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy deploy:restart<br />
</pre><br />
<br />
Now, your diaspora* installation is up and running, you can go visit it at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Deploy a real diaspora* POD =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Cloning your git repo to your host ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''), for better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.0.0<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rake spec<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server, Ubuntu 12.04LTS Server and CentOS 6.4. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=2826Installation/Vagrant puppet capistrano2014-05-13T00:01:55Z<p>Joebew42: /* How to contribute this project */</p>
<hr />
<div>{{Work in progress}}<br />
<br />
= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure a fake FQDN in your system ==<br />
<br />
You will find a Vagrantfile, Puppet and Capistrano already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. Before start using these tools is necessary to update your ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy deploy:restart<br />
</pre><br />
<br />
Now, your diaspora* installation is up and running, you can go visit it at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Deploy a real diaspora* POD =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Cloning your git repo to your host ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''), for better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.0.0<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rake spec<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested on Ubuntu 14.04LTS Server and Ubuntu 12.04LTS Server. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=2825Installation/Vagrant puppet capistrano2014-05-13T00:01:19Z<p>Joebew42: /* Which Operating Systems are supported? */</p>
<hr />
<div>{{Work in progress}}<br />
<br />
= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure a fake FQDN in your system ==<br />
<br />
You will find a Vagrantfile, Puppet and Capistrano already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. Before start using these tools is necessary to update your ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy deploy:restart<br />
</pre><br />
<br />
Now, your diaspora* installation is up and running, you can go visit it at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Deploy a real diaspora* POD =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Cloning your git repo to your host ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''), for better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.0.0<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rake spec<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
* Ubuntu 14.04LTS Server<br />
* Ubuntu 12.04LTS Server<br />
* CentOS 6.4<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the '''Vagrantfile''' is configured to run an Ubuntu 14.04LTS Server box. If you want to switch to Ubuntu 12.04LTS Server or CentOS 6.4, you have to edit the file.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested only on Ubuntu 12.04LTS server. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=2824Installation/Vagrant puppet capistrano2014-05-12T23:59:18Z<p>Joebew42: /* Introduction */</p>
<hr />
<div>{{Work in progress}}<br />
<br />
= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.6 or above, and Capistrano 3.1 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure a fake FQDN in your system ==<br />
<br />
You will find a Vagrantfile, Puppet and Capistrano already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. Before start using these tools is necessary to update your ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy deploy:restart<br />
</pre><br />
<br />
Now, your diaspora* installation is up and running, you can go visit it at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Deploy a real diaspora* POD =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Cloning your git repo to your host ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''), for better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.0.0<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rake spec<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
At the moment we support '''Ubuntu 12.04LTS Server''' and '''CentOS 6.4'''<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the Vagrantfile will creates an Ubuntu box. If you want to switch for CentOS, you have to comment out the lines regarding Ubuntu and uncomment the lines about CentOS<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested only on Ubuntu 12.04LTS server. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=2509Installation/Vagrant puppet capistrano2014-01-25T17:59:12Z<p>Joebew42: /* Configure Rubies and Gemsets */</p>
<hr />
<div>{{Work in progress}}<br />
<br />
= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.2 or above, and Capistrano 3.0 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure a fake FQDN in your system ==<br />
<br />
You will find a Vagrantfile, Puppet and Capistrano already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. Before start using these tools is necessary to update your ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy deploy:restart<br />
</pre><br />
<br />
Now, your diaspora* installation is up and running, you can go visit it at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Deploy a real diaspora* POD =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Cloning your git repo to your host ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''), for better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use 2.0.0<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rake spec<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
At the moment we support '''Ubuntu 12.04LTS Server''' and '''CentOS 6.4'''<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the Vagrantfile will creates an Ubuntu box. If you want to switch for CentOS, you have to comment out the lines regarding Ubuntu and uncomment the lines about CentOS<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested only on Ubuntu 12.04LTS server. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=2508Installation/Vagrant puppet capistrano2014-01-25T17:45:42Z<p>Joebew42: /* Using PostgreSQL Database */</p>
<hr />
<div>{{Work in progress}}<br />
<br />
= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.2 or above, and Capistrano 3.0 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure a fake FQDN in your system ==<br />
<br />
You will find a Vagrantfile, Puppet and Capistrano already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. Before start using these tools is necessary to update your ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy deploy:restart<br />
</pre><br />
<br />
Now, your diaspora* installation is up and running, you can go visit it at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Deploy a real diaspora* POD =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Cloning your git repo to your host ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''), for better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use ruby-1.9.3-p448<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rake spec<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
At the moment we support '''Ubuntu 12.04LTS Server''' and '''CentOS 6.4'''<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the Vagrantfile will creates an Ubuntu box. If you want to switch for CentOS, you have to comment out the lines regarding Ubuntu and uncomment the lines about CentOS<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested only on Ubuntu 12.04LTS server. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=2507Installation/Vagrant puppet capistrano2014-01-25T17:45:21Z<p>Joebew42: /* puppets/manifests/site.pp */</p>
<hr />
<div>{{Work in progress}}<br />
<br />
= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.2 or above, and Capistrano 3.0 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure a fake FQDN in your system ==<br />
<br />
You will find a Vagrantfile, Puppet and Capistrano already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. Before start using these tools is necessary to update your ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy deploy:restart<br />
</pre><br />
<br />
Now, your diaspora* installation is up and running, you can go visit it at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Deploy a real diaspora* POD =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
rvm_version => '1.25.14',<br />
ruby_version => '2.0.0',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Cloning your git repo to your host ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''), for better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use ruby-1.9.3-p448<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rake spec<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
At the moment we support '''Ubuntu 12.04LTS Server''' and '''CentOS 6.4'''<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the Vagrantfile will creates an Ubuntu box. If you want to switch for CentOS, you have to comment out the lines regarding Ubuntu and uncomment the lines about CentOS<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested only on Ubuntu 12.04LTS server. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=2490Installation/Vagrant puppet capistrano2014-01-19T18:20:20Z<p>Joebew42: /* Cloning your git repo to you host */</p>
<hr />
<div>{{Work in progress}}<br />
<br />
= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.2 or above, and Capistrano 3.0 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure a fake FQDN in your system ==<br />
<br />
You will find a Vagrantfile, Puppet and Capistrano already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. Before start using these tools is necessary to update your ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy deploy:restart<br />
</pre><br />
<br />
Now, your diaspora* installation is up and running, you can go visit it at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Deploy a real diaspora* POD =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Cloning your git repo to your host ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''), for better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use ruby-1.9.3-p448<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rake spec<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
At the moment we support '''Ubuntu 12.04LTS Server''' and '''CentOS 6.4'''<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the Vagrantfile will creates an Ubuntu box. If you want to switch for CentOS, you have to comment out the lines regarding Ubuntu and uncomment the lines about CentOS<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested only on Ubuntu 12.04LTS server. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=2488Installation/Vagrant puppet capistrano2014-01-19T18:06:34Z<p>Joebew42: </p>
<hr />
<div>{{Work in progress}}<br />
<br />
= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.2 or above, and Capistrano 3.0 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure a fake FQDN in your system ==<br />
<br />
You will find a Vagrantfile, Puppet and Capistrano already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. Before start using these tools is necessary to update your ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy deploy:restart<br />
</pre><br />
<br />
Now, your diaspora* installation is up and running, you can go visit it at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Deploy a real diaspora* POD =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to set up a Development Environment =<br />
<br />
You can use these tools to easly set up a fully development environment for diaspora*. The ''development'' machine is configured within ''Vagrantfile'' with enough RAM (2GB) to run all tests.<br />
In this way you can write code using your preferred IDE or editor (''vim'', ''emacs'', ''eclipse'' and so on) directly from your local environment (the host machine), by executing tests within the ''development'' virtual machine.<br />
<br />
== Cloning your git repo to you host ==<br />
<br />
'''Vagrantfile''' is configured to sync an host directory (''src'') with a guest directory (''diaspora_src''), for better I/O performance read the [http://docs.vagrantup.com/v2/synced-folders/nfs.html '''Vagrant Synced Folder Documentation''']. The first step is to clone your own diaspora* git repository into the local directory ''src''.<br />
<br />
<pre><br />
cd diaspora_replica<br />
git clone your_own_diapora_git_repo src<br />
</pre><br />
<br />
== Run development virtual machine ==<br />
<br />
<pre><br />
vagrant up development<br />
</pre><br />
<br />
== Enabling vagrant user to use rvm (first time set up) ==<br />
<br />
<pre><br />
vagrant ssh development<br />
vagrant@development:~$ sudo usermod -aG rvm vagrant && newgrp rvm<br />
vagrant@development:~$ /bin/bash --login<br />
</pre><br />
<br />
== Prepare the Rails application ==<br />
<br />
<pre><br />
vagrant@development:~$ cd diaspora_src<br />
</pre><br />
<br />
Prepare your configuration files ''diaspora.yml'' and ''database.yml'', put it into ''config/'' directory.<br />
<br />
== Configure Rubies and Gemsets ==<br />
<br />
<pre><br />
vagrant@development:~$ rvm use ruby-1.9.3-p448<br />
vagrant@development:~$ rvm gemset create diaspora_dev<br />
vagrant@development:~$ rvm gemset use diaspora_dev<br />
</pre><br />
<br />
== Install gems and create databases ==<br />
<br />
<pre><br />
vagrant@development:~$ bundle<br />
vagrant@development:~$ rake db:create<br />
vagrant@development:~$ rake db:migrate<br />
</pre><br />
<br />
== Run all tests ==<br />
<br />
<pre><br />
vagrant@development:~$ rake spec<br />
</pre><br />
<br />
= Which Operating Systems are supported? =<br />
<br />
At the moment we support '''Ubuntu 12.04LTS Server''' and '''CentOS 6.4'''<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the Vagrantfile will creates an Ubuntu box. If you want to switch for CentOS, you have to comment out the lines regarding Ubuntu and uncomment the lines about CentOS<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested only on Ubuntu 12.04LTS server. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=2451Installation/Vagrant puppet capistrano2014-01-12T19:57:31Z<p>Joebew42: </p>
<hr />
<div>{{Work in progress}}<br />
<br />
= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.2 or above, and Capistrano 3.0 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
== Configure a fake FQDN in your system ==<br />
<br />
You will find a Vagrantfile, Puppet and Capistrano already configured to handle three kind of environment: ''development'', ''staging'' and ''production''. Before start using these tools is necessary to update your ''/etc/hosts'' file, adding to it the three FQDN for the local diaspora* installation.<br />
<br />
Put these entries in your ''/etc/hosts''<br />
<br />
<pre><br />
192.168.11.2 development.diaspora.local<br />
192.168.11.3 staging.diaspora.local<br />
192.168.11.4 production.diaspora.local<br />
</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up development</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy deploy:restart<br />
</pre><br />
<br />
Now, your diaspora* installation is up and running, you can go visit it at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
Simply execute<br />
<br />
<pre>vagrant up production</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Deploy a real diaspora* POD =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= Which Operating Systems are supported? =<br />
<br />
At the moment we support '''Ubuntu 12.04LTS Server''' and '''CentOS 6.4'''<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the Vagrantfile will creates an Ubuntu box. If you want to switch for CentOS, you have to comment out the lines regarding Ubuntu and uncomment the lines about CentOS<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested only on Ubuntu 12.04LTS server. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=2449Installation/Vagrant puppet capistrano2014-01-06T01:46:35Z<p>Joebew42: </p>
<hr />
<div>{{Work in progress}}<br />
<br />
= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.2 or above, and Capistrano 3.0 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Configure a fake FQDN in your system ==<br />
<br />
Put this entry in your ''/etc/hosts''<br />
<br />
<pre>192.168.11.2 development.diaspora.local</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy deploy:restart<br />
</pre><br />
<br />
Now, your diaspora* installation is up and running, you can go visit it at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
If you want to simulate a production installation of diaspora*, you can do that simply modifying the ''Vagrantfile'' and the ''puppet/manifests/site.pp''. In your ''Vagrantfile'', you have to specify the '''hostname''' of the machine to '''production.diaspora.local'''<br />
<br />
== puppet/manifests/site.pp ==<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
And edits your ''/etc/hosts'' putting this entry:<br />
<br />
<pre>192.168.11.2 production.diaspora.local</pre><br />
<br />
After that, execute vagrant:<br />
<br />
<pre>vagrant up</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Deploy a real diaspora* POD =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= Which Operating Systems are supported? =<br />
<br />
At the moment we support '''Ubuntu 12.04LTS Server''' and '''CentOS 6.4'''<br />
<br />
== Choosing the OS from Vagrantfile ==<br />
<br />
By default the Vagrantfile will creates an Ubuntu box. If you want to switch for CentOS, you have to comment out the lines regarding Ubuntu and uncomment the lines about CentOS<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested only on Ubuntu 12.04LTS server. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=2448Installation/Vagrant puppet capistrano2014-01-05T20:00:07Z<p>Joebew42: </p>
<hr />
<div>{{Work in progress}}<br />
<br />
= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.2 or above, and Capistrano 3.0 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
= Deploy a development pod =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Configure a fake FQDN in your system ==<br />
<br />
Put this entry in your ''/etc/hosts''<br />
<br />
<pre>192.168.11.2 development.diaspora.local</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano with bundle (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy deploy:restart<br />
</pre><br />
<br />
Now, your diaspora* installation is up and running, you can go visit it at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= Simulate a production deploy =<br />
<br />
If you want to simulate a production installation of diaspora*, you can do that simply modifying the ''Vagrantfile'' and the ''puppet/manifests/site.pp''. In your ''Vagrantfile'', you have to specify the '''hostname''' of the machine to '''production.diaspora.local'''<br />
<br />
== puppet/manifests/site.pp ==<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
And edits your ''/etc/hosts'' putting this entry:<br />
<br />
<pre>192.168.11.2 production.diaspora.local</pre><br />
<br />
After that, execute vagrant:<br />
<br />
<pre>vagrant up</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Deploy a real diaspora* POD =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* with Capistrano ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy deploy:restart<br />
</pre><br />
<br />
= Using PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested only on Ubuntu 12.04LTS server. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=2434Installation/Vagrant puppet capistrano2013-12-31T20:15:33Z<p>Joebew42: </p>
<hr />
<div>{{Work in progress}}<br />
<br />
= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.2 or above, and Capistrano 3.0 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
= How to start a development environment =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Configure a fake FQDN in your system ==<br />
<br />
Put this entry in your ''/etc/hosts''<br />
<br />
<pre>192.168.11.2 development.diaspora.local</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano from rubygem (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy<br />
cap development deploy:start<br />
</pre><br />
<br />
Now, your diaspora* installation is up and running, you can go visit it at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= How to simulate a production environment =<br />
<br />
If you want to simulate a production installation of diaspora*, you can do that simply modifying the ''Vagrantfile'' and the ''puppet/manifests/site.pp''. In your ''Vagrantfile'', you have to specify the '''hostname''' of the machine to '''production.diaspora.local'''<br />
<br />
== puppet/manifests/site.pp ==<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
And edit your ''/etc/hosts'' putting this entry:<br />
<br />
<pre>192.168.11.2 production.diaspora.local</pre><br />
<br />
After that, execute vagrant:<br />
<br />
<pre>vagrant up</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
cap production deploy:start<br />
</pre><br />
<br />
= How to start a real production environment =<br />
<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the git repository URL, the name of the branch and the user of the remote server.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
cap production deploy:start<br />
</pre><br />
<br />
= How to use PostgreSQL Database =<br />
<br />
If you want to use PostgreSQL [1] instead of the default MySQL, you can configure it through ''puppet/manifests/site.pp'':<br />
<br />
<pre><br />
node 'development.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'development',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'postgres',<br />
db_host => 'localhost',<br />
db_port => '5432',<br />
db_name => 'diaspora_development',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
note the ''db_provider'' and ''db_port'' parameters.<br />
<br />
And you have to uncomment the line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
That is present in your ''capistrano/config/deploy/development.rb''<br />
<br />
[1] Puppet will install PostgreSQL 9.1<br />
<br />
== PostgreSQL for Staging/Production environments ==<br />
<br />
Because of "--deployment" flag that is set up by default in capistrano bundler, it is necessary to fork diaspora* in a personal git repository and bundle it with PostgreSQL support:<br />
<br />
<pre><br />
$ DB=postgres bundle<br />
</pre><br />
<br />
and then add the generated Gemfile.lock under version control. Once you have done that, to enable PostgreSQL you have to uncomment this line:<br />
<br />
<pre><br />
# set :default_env, { DB: 'postgres' }<br />
</pre><br />
<br />
in ''capistrano/config/deploy/production.rb'' (or ''capistrano/config/deploy/staging.rb'', depends on which environment you are going to deploy.) Of course, you have to specify your git repository, too.<br />
<br />
= How to contribute this project =<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested only on Ubuntu 12.04LTS server. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS). The Database section of the Puppet does not consider parameters like hostname and port at the moment. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=2403Installation/Vagrant puppet capistrano2013-12-16T22:24:34Z<p>Joebew42: </p>
<hr />
<div>{{Work in progress}}<br />
<br />
= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.2 or above, and Capistrano 3.0 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
= How to start a development environment =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Configure a fake FQDN in your system ==<br />
<br />
Put this entry in your ''/etc/hosts''<br />
<br />
<pre>192.168.11.2 development.diaspora.local</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano from rubygem (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy<br />
</pre><br />
<br />
Now, your diaspora* installation is up and running, you can go visit it at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= How to simulate a production environment =<br />
<br />
If you want to simulate a production installation of diaspora*, you can do that simply modifying the ''Vagrantfile'' and the ''puppet/manifests/site.pp''. In your ''Vagrantfile'', you have to specify the '''hostname''' of the machine to '''production.diaspora.local'''<br />
<br />
== puppet/manifests/site.pp ==<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
And edit your ''/etc/hosts'' putting this entry:<br />
<br />
<pre>192.168.11.2 production.diaspora.local</pre><br />
<br />
After that, execute vagrant:<br />
<br />
<pre>vagrant up</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
cap production deploy:compile_assets<br />
cap production deploy:restart<br />
</pre><br />
<br />
= How to start a real production environment =<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the name of the branch used and the user of the remote server. If you want to specify a different git repository instead of using the official one, you have to edit the ''capistrano/config/deploy.rb''.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
cap production deploy:compile_assets<br />
cap production deploy:restart<br />
</pre><br />
<br />
== How to contribute this project ==<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested only on Ubuntu 12.04LTS server. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS).<br />
The Database section of the Puppet works only with MySQL/MariaDB and properties like hostname and port are not used at the moment. I would like to improve Puppet to include support over other DBMS, like PostgreSQL. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]<br />
[[Category:Developers]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=2402Installation/Vagrant puppet capistrano2013-12-16T22:07:59Z<p>Joebew42: </p>
<hr />
<div>{{Work in progress}}<br />
<br />
= Introduction =<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.2 or above, and Capistrano 3.0 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
= How to start a development environment =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Configure a fake FQDN in your system ==<br />
<br />
Put this entry in your ''/etc/hosts''<br />
<br />
<pre>192.168.11.2 development.diaspora.local</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano from rubygem (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy<br />
</pre><br />
<br />
Now, your diaspora* installation is up and running, you can go visit it at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= How to simulate a production environment =<br />
<br />
If you want to simulate a production installation of diaspora*, you can do that simply modifying the ''Vagrantfile'' and the ''puppet/manifests/site.pp''. In your ''Vagrantfile'', you have to specify the '''hostname''' of the machine to '''production.diaspora.local'''<br />
<br />
== puppet/manifests/site.pp ==<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
And edit your ''/etc/hosts'' putting this entry:<br />
<br />
<pre>192.168.11.2 production.diaspora.local</pre><br />
<br />
After that, execute vagrant:<br />
<br />
<pre>vagrant up</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
cap production deploy:compile_assets<br />
cap production deploy:restart<br />
</pre><br />
<br />
= How to start a real production environment =<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the name of the branch used and the user of the remote server. If you want to specify a different git repository instead of using the official one, you have to edit the ''capistrano/config/deploy.rb''.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
cap production deploy:compile_assets<br />
cap production deploy:restart<br />
</pre><br />
<br />
== How to contribute this project ==<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested only on Ubuntu 12.04LTS server. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS).<br />
The Database section of the Puppet works only with MySQL/MariaDB and properties like hostname and port are not used at the moment. I would like to improve Puppet to include support over other DBMS, like PostgreSQL. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]</div>Joebew42https://wiki.diasporafoundation.org/wiki/index.php?title=Installation/Vagrant_puppet_capistrano&diff=2401Installation/Vagrant puppet capistrano2013-12-16T21:51:16Z<p>Joebew42: </p>
<hr />
<div>{{Work in progress}}<br />
<br />
[https://github.com/joebew42/diaspora-replica '''diaspora* -Replica'''] Is a project that combines Vagrant, Puppet and Capistrano to automate the deploy of a POD. This project is under development, if you have some feedback or do you want to contribute to it, feel free to do it.<br />
At this time is necessary to do some test with real deploy on some cloud services (e.g. AWS, Digital Ocean, Rackspace, or other), even on non cloud service.<br />
<br />
'''Some advice before you start to use these tools:''' You must to have installed on your computer Vagrant 1.2 or above, and Capistrano 3.0 or above (to install Capistrano follow instructions below.)<br />
<br />
= diaspora* -Replica =<br />
<br />
The aim of this project is to provide some tools that can help you to deploy a full [https://github.com/diaspora/diaspora '''diaspora*'''] environment through the automation of two tasks:<br />
<br />
* The deploy and configuration of the machine with [http://www.vagrantup.com/ '''Vagrant 2'''] and [http://puppetlabs.com/ '''Puppet''']<br />
* The deploy of Diaspora* itself with [http://www.capistranorb.com/ '''Capistrano 3''']<br />
<br />
With these two tasks you can automatically set up different environments, from development to production installation.<br />
<br />
= How to start a development environment =<br />
<br />
If you are a developer and you want to try diaspora without messing up your computer by installing and configuring extra packages, you can set up a virtual machine that is executed by Vagrant and then automatically configured by Puppet.<br />
Now that you have a fully configured virtual machine ready to host a diaspora application, will be very easy to deploy it with Capistrano.<br />
<br />
== Configure a fake FQDN in your system ==<br />
<br />
Put this entry in your ''/etc/hosts''<br />
<br />
<pre>192.168.11.2 development.diaspora.local</pre><br />
<br />
== Initialize project ==<br />
<br />
<pre><br />
git clone https://github.com/joebew42/diaspora-replica.git<br />
cd diaspora_replica<br />
git submodule update --init<br />
</pre><br />
<br />
== Set up the virtual machine with Vagrant/Puppet ==<br />
<br />
<pre>vagrant up</pre><br />
<br />
Wait until the virtual machine is automatically setted up with puppet and is up and running.<br />
<br />
== Install Capistrano from rubygem (if you haven't) ==<br />
<br />
If you have not installed Capistrano on your computer, you can easily run bundle to install it.<br />
<br />
<pre><br />
cd capistrano/ && bundle<br />
</pre><br />
<br />
== Deploy diaspora* ==<br />
<br />
When the virtual machine is up and running, then you can deploy diaspora* on it using Capistrano<br />
<br />
<pre><br />
cd capistrano<br />
cap development deploy<br />
</pre><br />
<br />
Now, your diaspora* installation is up and running, you can go visit it at ''http://development.diaspora.local''<br />
<br />
== Start, stop and restart ==<br />
<br />
You can use Capistrano tasks to start, stop or restart diaspora*<br />
<br />
<pre><br />
cap development deploy:start<br />
cap development deploy:stop<br />
cap development deploy:restart<br />
</pre><br />
<br />
= How to simulate a production environment =<br />
<br />
If you want to simulate a production installation of diaspora*, you can do that simply modifying the ''Vagrantfile'' and the ''puppet/manifests/site.pp''. In your ''Vagrantfile'', you have to specify the '''hostname''' of the machine to '''production.diaspora.local'''<br />
<br />
== puppet/manifests/site.pp ==<br />
<br />
<pre><br />
node 'production.diaspora.local' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
And edit your ''/etc/hosts'' putting this entry:<br />
<br />
<pre>192.168.11.2 production.diaspora.local</pre><br />
<br />
After that, execute vagrant:<br />
<br />
<pre>vagrant up</pre><br />
<br />
and proceed to deploy diaspora* with capistrano:<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
cap production deploy:compile_assets<br />
cap production deploy:restart<br />
</pre><br />
<br />
= How to start a real production environment =<br />
If you want to use these tools to deploy a production environment (e.g. stage or production), you have to configure some properties inside ''Vagrantfile'', ''puppet/manifests/site.pp'', ''capistrano/config/deploy/production.rb'' and of course, SSL certs and private/public keys for the server.<br />
<br />
== Vagrantfile ==<br />
<br />
You have to configure your ''Vagrantfile'' based on the virtual machine provider you are going to use (e.g. Amazon AWS, DigitalOcean, and other). Please see the [http://docs.vagrantup.com/v2/providers/index.html '''Vagrant Provider Documentation'''] for detailed instructions. If you are not going to use vagrant you can skip this section and apply puppet manually, or configure a puppet master/agent environment. See the Puppet documentation for more informations.<br />
<br />
== puppets/manifests/site.pp ==<br />
<br />
<pre><br />
node 'myproduction.domain.com' {<br />
class { 'diaspora':<br />
hostname => $fqdn,<br />
environment => 'production',<br />
app_directory => '/home/diaspora',<br />
user => 'diaspora',<br />
group => 'diaspora',<br />
db_provider => 'mysql',<br />
db_host => 'localhost',<br />
db_port => '3306',<br />
db_name => 'diaspora_production',<br />
db_username => 'diaspora',<br />
db_password => 'diaspora',<br />
db_root_password => 'diaspora_root'<br />
}<br />
}<br />
</pre><br />
<br />
Of course, you have to change *myproduction.domain.com* with your real Fully Qualified Domain Name, and set up strong password.<br />
<br />
== Setup the SSL certificate for your server ==<br />
<br />
You have to put the SSL key and certificate in ''puppet/modules/diaspora/files/certs/''. The file names must contain the FQDN followed by .crt and .key. See the examples that already exists.<br />
<br />
== Setup the public key of the user ==<br />
<br />
Put in ''puppet/modules/diaspora/files/diaspora.pub'' the public key of the user that will be granted to execute commands from Capistrano.<br />
<br />
== Apply Puppet configuration ==<br />
<br />
Now that your Puppet configuration is complete, you have to execute it to your production server. If you use vagrant configured with one of the supported providers it can be done automatically. If you are not able to configure vagrant, you can apply puppet in other ways. But this topic will be not covered here. See the Puppet documentation for this.<br />
<br />
== capistrano/config/deploy/production.rb ==<br />
<br />
Here you have to configure the FQDN, the name of the branch used and the user of the remote server. If you want to specify a different git repository instead of using the official one, you have to edit the ''capistrano/config/deploy.rb''.<br />
<br />
== Capistrano public key ==<br />
<br />
In order to allow Capistrano to execute commands on the remote server you need to put in ''capistrano/ssh_keys'' the private and the public keys of the user. The public key should be the same of ''puppet/modules/diaspora/files/diaspora.pub''.<br />
<br />
== Deploy diaspora* ==<br />
<br />
Once you have successfully configured the server, you can deploy and start diaspora*<br />
<br />
<pre><br />
cd capistrano<br />
cap production deploy<br />
cap production deploy:compile_assets<br />
cap production deploy:restart<br />
</pre><br />
<br />
== How to contribute this project ==<br />
<br />
This project is under development. There are a lot of things to do. At the moment the Puppet provides support and, has been tested only on Ubuntu 12.04LTS server. It could be useful if someone can test it over other version of Ubuntu, or better, can provide support for other distributions (e.g. CentOS).<br />
The Database section of the Puppet works only with MySQL/MariaDB and properties like hostname and port are not used at the moment. I would like to improve Puppet to include support over other DBMS, like PostgreSQL. Furthermore there a lot of variables of diaspora.yml that are not covered (e.g. mail server configuration, unicorn workers, and more).<br />
[[Category:Podmin]]<br />
[[Category:Installation]]</div>Joebew42