Some fixes in configuration standalone server

 Allow replace config files
 Fix path to replication and add ability to native Gerrit replication
 Improve email section
 Typo fix plugin

Related-Prod: PROD:20905

Change-Id: If175275643ffee8baee5e7cb080122e7e7a0e6fc
diff --git a/gerrit/files/gerrit.config b/gerrit/files/gerrit.config
index d20660c..33eea00 100644
--- a/gerrit/files/gerrit.config
+++ b/gerrit/files/gerrit.config
@@ -64,6 +64,9 @@
 [sendemail]
     {%- if server.mail is defined %}
     smtpServer = {{ server.mail.host }}
+    smtpServerPort = {{ server.mail.port }}
+    smtpUser = {{ server.mail.user }}
+    smtpEncryption = {{ server.mail.encryption }}
     from = {{ server.mail.from }}
     includeDiff = {{ server.mail.include_diff }}
     {%- else %}
@@ -163,6 +166,11 @@
     {%- endif %}
 {%- endfor %}
 
+{%- if server.get('remote_admin', False) %}
+[plugins]
+    allowRemoteAdmin = true
+{%- endif%}
+
 {%- for plugin_name, plugin in server.get('plugin', {}).iteritems() %}
 {%- if plugin.url is defined %}
 [{{ plugin_name }}]
@@ -193,6 +201,8 @@
 [gitweb]
     {%- if server.ui.engine == 'gitweb' %}
     revision = "?p=${project}.git;a=commitdiff;h=${commit}"
+    cgi = /usr/share/gitweb/gitweb.cgi
+    type = gitweb
     {%- else %}
     type = cgit
     {%- endif %}
diff --git a/gerrit/files/replication.config b/gerrit/files/replication.config
index 1841f38..6609af0 100644
--- a/gerrit/files/replication.config
+++ b/gerrit/files/replication.config
@@ -2,7 +2,13 @@
 # This file is managed by salt.
 {%- for remote_host, replication in server.get('replication', {}).iteritems() %}
 [remote "{{ remote_host }}"]
-  url = {{ replication.remote_url }}/git/${name}.git
+  url = {{ replication.remote_url }}/${name}.git
+{%- if replication.get('mirror', False) %}
+  mirror = true
+{%- endif%}
+{%- if replication.remote_admin_url is defined %}
+  adminUrl = {{ replication.remote_admin_url }}/${name}.git
+{%- endif%}
   push = +refs/*:refs/*
   threads = 3
   defaultForceUpdate = false
diff --git a/gerrit/server/plugin.sls b/gerrit/server/plugin.sls
index 1e8738d..7518d24 100644
--- a/gerrit/server/plugin.sls
+++ b/gerrit/server/plugin.sls
@@ -8,10 +8,12 @@
 
 {%- if plugin.engine == "http" %}
 
-{{ server.dir.home }}/review_site/plugins/{{ plugin_name }}.jar
+{{ server.dir.home }}/review_site/plugins/{{ plugin_name }}.jar:
   file.managed:
   - source: {{ plugin.address }}
+  - skip_verify: True
   - user: gerrit2
+  - group: gerrit2
 
 {%- endif %}
 
diff --git a/gerrit/server/service.sls b/gerrit/server/service.sls
index ac6d3aa..175b28d 100644
--- a/gerrit/server/service.sls
+++ b/gerrit/server/service.sls
@@ -38,7 +38,7 @@
   - user: gerrit2
   - group: gerrit2
   - template: jinja
-  - replace: False
+  - replace: true
   - require:
     - file: gerrit_home
 
@@ -48,7 +48,7 @@
   - user: gerrit2
   - group: gerrit2
   - template: jinja
-  - replace: False
+  - replace: true
   - require:
     - file: gerrit_home