summaryrefslogtreecommitdiff
path: root/baserock_gerrit/instance-mirroring-config.yml
blob: 19ac76cc37e8a510879ff7023bdceebb63984e8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# This Ansible playbook configures mirroring in and out of Gerrit.
#
# To run it, use:
#   ansible-playbook -i hosts baserock_gerrit/instance-mirroring-config.yml
#
# It expects the SSH key for the 'lorry' user to exist at
# ../keys/lorry-gerrit.key.
#
# This script currently doesn't handle the lorry-controller.conf file that
# controls what lorry-controller mirrors into Gerrit. To set up or modify
# lorry-controller configuration you need to commit your changes to the
# 'local-config/lorries' project on the Gerrit.
---
- hosts: gerrit
  gather_facts: no
  sudo: yes
  tasks:
    - name: Lorry user
      user: name=lorry comment="Lorry mirroring service"

    # Ansible can generate a new SSH key for Lorry when we add the user,
    # but it seems tricky to then extract this and add it to the 'lorry' Gerrit
    # user.
    - name: SSH private key for Lorry user
      copy: src=../keys/lorry-gerrit.key dest=~/.ssh/id_rsa mode=600
      sudo_user: lorry

    - name: SSH public key for Lorry user
      copy: src=../keys/lorry-gerrit.key.pub dest=~/.ssh/id_rsa.pub mode=644
      sudo_user: lorry

    - name: directory in /etc for Lorry Controller system configuration
      file: dest=/etc/lorry-controller state=directory

    - name: Lorry tool configuration
      copy: src=lorry.conf dest=/etc/lorry.conf

    - name: Lorry Controller system configuration
      copy:
        src=lorry-controller/{{ item }}
        dest=/etc/lorry-controller/{{ item }}
      with_items:
        - minion.conf
        - webapp.conf

    - name: enable and restart core lorry controller services.
      service: name={{ item }} enabled=yes state=restarted
      with_items:
        - lighttpd-lorry-controller-webapp.service
        - lorry-controller-minion@1.service

    - name: enable lorry-controller scheduled activity timers
      service: name={{ item }} enabled=yes
      with_items:
        - lorry-controller-ls-troves.timer
        - lorry-controller-readconf.timer
        - lorry-controller-remove-ghost-jobs.timer
        - lorry-controller-remove-old-jobs.timer
        - lorry-controller-status.timer

    - name: gerrit-replication configuration
      copy: src=replication.config dest=/srv/gerrit/etc
      notify:
        - restart gerrit

handlers:
  - name: restart gerrit
    service: name=gerrit state=restarted