<commit_before># Complete Agora Voting deployment system

This document describes the complete deployment of an Agora Voting system
with two Authorities.

## agora-dev-box

First of all we need to download the ansible deployment project:

    $ git clone https://github.com/agoravoting/agora-dev-box.git

## Servers

We need at least 3 servers to deploy a secure environment. We'll have two
authorities and then other server with the authentication (authapi), the
web interface (agora-core-view) and the ballot box (aogra\_elections).

The deployment is tested with ubuntu/trusty64, it should work with other
ubuntu distributions, but maybe the deployment needs some tweaks.

## Vagrant machines

If you have real machines you can skip this step, but be sure to modify
each config file to use your currently real ips.

First of all we'll create the three servers we need with vagrant, copy the
agora-dev-box folder three times with different names, one for each server:

    $ cp agora-dev-box auth1
    $ cp agora-dev-box auth2
    $ cp agora-dev-box agora

Then we can create each Vagrant machine:

    $ cd auth1
    auth1 $ cp doc/Vagrantfile.auth1 Vagrantfile
    auth1 $ vagrant up --no-provision
    auth1 $ vagrant ssh-config > ./vagrant.ssh.config

    $ cd auth2
    auth2 $ cp doc/Vagrantfile.auth2 Vagrantfile
    auth2 $ vagrant up --no-provision
    auth2 $ vagrant ssh-config > ./vagrant.ssh.config

    $ cd agora
    agora $ cp doc/Vagrantfile.agora Vagrantfile
    agora $ vagrant up --no-provision
    agora $ vagrant ssh-config > ./vagrant.ssh.config

Now we've three basic ubuntu machines connected with this ips:

 * auth1: 192.168.50.2
 * auth2: 192.168.50.3
 * agora: 192.168.50.4

So you should add this to your /etc/hosts to be able to access:

    echo "192.168.50.2 local-auth1" >> /etc/hosts
    echo "192.168.50.3 local-auth2" >> /etc/hosts
    echo "192.168.50.4 agora" >> /etc/hosts

## Authorities server

We need to deploy the two authorities and connect them. The process is the
same for deploy this two authorities.

    $ cd auth1
    auth1 $ cp doc/auth1.config.yml config.yml
    auth1 $ cp doc/auth.playbook.yml playbook.yml
    auth1 $ vagrant provision
    auth1 $ vagrant ssh
    local-auth1 $ sudo eopeers --show-mine | tee /home/vagrant/auth1.pkg >/dev/null
    local-auth1 $ exit
    auth1 $ scp -F vagrant.ssh.config default:/home/vagrant/auth1.pkg auth1.pkg

    $ cd auth2
    auth2 $ cp doc/auth2.config.yml config.yml
    auth2 $ cp doc/auth.playbook.yml playbook.yml
    auth2 $ vagrant provision
    auth2 $ vagrant ssh
    local-auth2 $ sudo eopeers --show-mine | tee /home/vagrant/auth2.pkg >/dev/null
    local-auth2 $ exit
    auth2 $ scp -F vagrant.ssh.config default:/home/vagrant/auth2.pkg auth2.pkg

Then we've these two servers running with all authority software installed
and running.

### Connecting auth1 with auth2

Authorities talks to other authorities using ssl and client certificate so
the authority server doesn't accept querires from not known servers. In a
real election system it's a good idea to not publish authorities ips and
ports to avoid malicious attacks.

The deployment script creates a certificate for each authority in
/srv/cert/serlfsigned/ and we manage the authority communication and
certificate sharing with eopeers tool.

    $ cd auth1
    auth1 $ scp -F vagrant.ssh.config ../auth2/auth2.pkg default:/home/vagrant/auth2.pkg
    auth1 $ vagrant ssh
    auth1 $ sudo eopeers --install /home/vagrant/auth2.pkg
    auth1 $ sudo service nginx restart

    $ cd auth2
    auth2 $ scp -F vagrant.ssh.config ../auth1/auth1.pkg default:/home/vagrant/auth1.pkg
    auth2 $ vagrant ssh
    auth2 $ sudo eopeers --install /home/vagrant/auth1.pkg
    auth2 $ sudo service nginx restart

### Test the authorities connection

To test the authorities real connection there's a tool installed, so after
the certificate installation you can run the test command:

    $ cd auth1
    auth1 $ vagrant ssh
    local-auth1 $ eotest full --vmnd --vcount 100

To view the software working in the other authority you can use the eolog
in other terminal.

    $ cd auth2
    auth2 $ vagrant ssh
    local-auth2 $ sudo eolog

## Agora server

    $ cd agora
    agora $ cp doc/agora.config.yml config.yml
    agora $ cp doc/agora.playbook.yml playbook.yml
    agora $ vagrant provision

    agora $ vagrant ssh
    agora $ sudo eopeers --show-mine | tee /home/vagrant/agora.pkg >/dev/null

    agora $ sudo supervisorctl stop agora-elections
    agora $ sudo su - agoraelections
    agora $ cd /home/agoraelections/agora-elections<commit_msg>adding missing sudo to eolog cmd invocation<commit_after># Complete Agora Voting deployment system

This document describes the complete deployment of an Agora Voting system
with two Authorities.

## agora-dev-box

First of all we need to download the ansible deployment project:

    $ git clone https://github.com/agoravoting/agora-dev-box.git

## Servers

We need at least 3 servers to deploy a secure environment. We'll have two
authorities and then other server with the authentication (authapi), the
web interface (agora-core-view) and the ballot box (aogra\_elections).

The deployment is tested with ubuntu/trusty64, it should work with other
ubuntu distributions, but maybe the deployment needs some tweaks.

## Vagrant machines

If you have real machines you can skip this step, but be sure to modify
each config file to use your currently real ips.

First of all we'll create the three servers we need with vagrant, copy the
agora-dev-box folder three times with different names, one for each server:

    $ cp agora-dev-box auth1
    $ cp agora-dev-box auth2
    $ cp agora-dev-box agora

Then we can create each Vagrant machine:

    $ cd auth1
    auth1 $ cp doc/Vagrantfile.auth1 Vagrantfile
    auth1 $ vagrant up --no-provision
    auth1 $ vagrant ssh-config > ./vagrant.ssh.config

    $ cd auth2
    auth2 $ cp doc/Vagrantfile.auth2 Vagrantfile
    auth2 $ vagrant up --no-provision
    auth2 $ vagrant ssh-config > ./vagrant.ssh.config

    $ cd agora
    agora $ cp doc/Vagrantfile.agora Vagrantfile
    agora $ vagrant up --no-provision
    agora $ vagrant ssh-config > ./vagrant.ssh.config

Now we've three basic ubuntu machines connected with this ips:

 * auth1: 192.168.50.2
 * auth2: 192.168.50.3
 * agora: 192.168.50.4

So you should add this to your /etc/hosts to be able to access:

    echo "192.168.50.2 local-auth1" >> /etc/hosts
    echo "192.168.50.3 local-auth2" >> /etc/hosts
    echo "192.168.50.4 agora" >> /etc/hosts

## Authorities server

We need to deploy the two authorities and connect them. The process is the
same for deploy this two authorities.

    $ cd auth1
    auth1 $ cp doc/auth1.config.yml config.yml
    auth1 $ cp doc/auth.playbook.yml playbook.yml
    auth1 $ vagrant provision
    auth1 $ vagrant ssh
    local-auth1 $ sudo eopeers --show-mine | tee /home/vagrant/auth1.pkg >/dev/null
    local-auth1 $ exit
    auth1 $ scp -F vagrant.ssh.config default:/home/vagrant/auth1.pkg auth1.pkg

    $ cd auth2
    auth2 $ cp doc/auth2.config.yml config.yml
    auth2 $ cp doc/auth.playbook.yml playbook.yml
    auth2 $ vagrant provision
    auth2 $ vagrant ssh
    local-auth2 $ sudo eopeers --show-mine | tee /home/vagrant/auth2.pkg >/dev/null
    local-auth2 $ exit
    auth2 $ scp -F vagrant.ssh.config default:/home/vagrant/auth2.pkg auth2.pkg

Then we've these two servers running with all authority software installed
and running.

### Connecting auth1 with auth2

Authorities talks to other authorities using ssl and client certificate so
the authority server doesn't accept querires from not known servers. In a
real election system it's a good idea to not publish authorities ips and
ports to avoid malicious attacks.

The deployment script creates a certificate for each authority in
/srv/cert/serlfsigned/ and we manage the authority communication and
certificate sharing with eopeers tool.

    $ cd auth1
    auth1 $ scp -F vagrant.ssh.config ../auth2/auth2.pkg default:/home/vagrant/auth2.pkg
    auth1 $ vagrant ssh
    auth1 $ sudo eopeers --install /home/vagrant/auth2.pkg
    auth1 $ sudo service nginx restart

    $ cd auth2
    auth2 $ scp -F vagrant.ssh.config ../auth1/auth1.pkg default:/home/vagrant/auth1.pkg
    auth2 $ vagrant ssh
    auth2 $ sudo eopeers --install /home/vagrant/auth1.pkg
    auth2 $ sudo service nginx restart

### Test the authorities connection

To test the authorities real connection there's a tool installed, so after
the certificate installation you can run the test command:

    $ cd auth1
    auth1 $ vagrant ssh
    local-auth1 $ sudo eotest full --vmnd --vcount 100

To view the software working in the other authority you can use the eolog
in other terminal.

    $ cd auth2
    auth2 $ vagrant ssh
    local-auth2 $ sudo eolog

## Agora server

    $ cd agora
    agora $ cp doc/agora.config.yml config.yml
    agora $ cp doc/agora.playbook.yml playbook.yml
    agora $ vagrant provision

    agora $ vagrant ssh
    agora $ sudo eopeers --show-mine | tee /home/vagrant/agora.pkg >/dev/null

    agora $ sudo supervisorctl stop agora-elections
    agora $ sudo su - agoraelections
    agora $ cd /home/agoraelections/agora-elections
{'fraction_non_alphanumeric': 0.075634792004322, 'fraction_numerical': 0.027228525121555915, 'mean_word_length': 3.135835567470956, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 12, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1329767', 'n_tokens_mistral': 3118, 'n_tokens_neox': 2856, 'n_words': 1092}