DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
# The host is assumed to have the hg-web role applied.
# Add the name of the host you wish to bootstrap to the "bootstrap"
# Ansible inventory group.
#
# instance: optionally bootstrap config for mirror or regular hgweb host. default: none
# ssh_workers: specify number of hgssh workers to use. default: 5
# hgweb_workers: specify number of hgweb workers to use. default: 8
#
# Usage:
#   $ ansible-playbook -i hosts bootstrap-hgweb.yml [-e instance=mirror]
#        [-e ssh_workers=8] [-e hgweb_workers=8]
---
- hosts: hgssh-prod-master
  become: true
  tasks:
    # We need to write this out on clients.
    - name: capture mirror key
      slurp: src=/etc/mercurial/mirror
      register: mirror_private_key

    - name: capture host key
      slurp: src=/etc/mercurial/ssh/ssh_host_rsa_key.pub
      register: mirror_host_key

    - name: execute hgssh bootstrap procedure
      command: /var/hg/venv_tools/bin/vcsreplicator-bootstrap-hgssh /etc/mercurial/hgrc /var/hg/venv_pash/bin/hg --workers {{ hgssh_workers | default(5) }} --output /home/hg/hgssh.json
      become_user: hg

    - name: get hgssh bootstrap object
      slurp: src=/home/hg/hgssh.json
      become_user: hg
      register: hgsshjson

- hosts: bootstrap
  become: true
  tasks:
    - name: set hostname
      hostname:
        name: "{{ bootstrap_hostname }}"

- name: bootstrap an hgweb instance
  import_playbook: deploy-hgweb.yml
  vars:
    var_hostgroup: bootstrap
  when: instance == 'hgweb'

- name: bootstrap an hgweb mirror
  import_playbook: deploy-mirrors.yml
  vars:
    var_hostgroup: bootstrap
  when: instance == 'mirror'

- hosts: bootstrap
  become: true
  tasks:
    - name: turn off Telegraf
      service:
        name: telegraf.service
        state: stopped

    - name: turn off vcsreplicator
      service: name=vcsreplicator@{{ item }}.service
               state=stopped
      with_items:
        - '0'
        - '1'
        - '2'
        - '3'
        - '4'
        - '5'
        - '6'
        - '7'

    - name: move hgssh json to hgweb
      copy: content="{{ hostvars[groups["hgssh-prod-master"][0]].hgsshjson.content | b64decode }}"
            dest=/etc/mercurial/hgssh.json
            mode=0775
            group=hg
            owner=hg

    - name: disable try repo in replication rules
      ini_file:
        path: /etc/mercurial/vcsreplicator.ini
        section: replicationrules
        option: include.tryrepos
        state: absent

    - block:
        - name: Execute hgweb bootstrap procedure
          command: /var/hg/venv_replication/bin/vcsreplicator-bootstrap-hgweb /etc/mercurial/vcsreplicator.ini /etc/mercurial/hgssh.json --workers {{ hgweb_workers | default(8) }}
          become_user: hg
      rescue:
        # If a repo is filtered from replication on a host, this registers as a failure
        # TODO make replication filtering a non-failure
        - debug:
            msg: "Something went wrong with the bootstrap procedure, check the output log for details"

    # TODO remove this try repo hack
    # Cloning the try repo via pulls (how vcsreplicator works) is inordinately slow.
    # Work around this using a stream clone for the try repos, and then regex
    # replace the rule in the replication rules filter
    - name: clone try repo
      command: /var/hg/venv_replication/bin/hg --config extensions.replicateowner=! --config extensions.vcsreplicator=! --config extensions.readonly=! --config ui.clonebundles=false --config experimental.evolution=true clone -U --stream https://hg.mozilla.org/try /repo/hg/mozilla/try
      become_user: hg

    - name: clone try-comm repo
      command: /var/hg/venv_replication/bin/hg --config extensions.replicateowner=! --config extensions.vcsreplicator=! --config extensions.readonly=! --config ui.clonebundles=false --config experimental.evolution=true clone -U --stream https://hg.mozilla.org/try-comm-central /repo/hg/mozilla/try-comm-central
      become_user: hg

    - name: enable try repo in replication rules
      ini_file:
        path: /etc/mercurial/vcsreplicator.ini
        section: replicationrules
        option: include.tryrepos
        value: 're:\{moz\}/try.*'
        state: present

    - name: fix permissions on instance_data.json
      file:
        path: /var/hg/instance_data.json
        owner: hg
        group: hg
        mode: 0600
        state: file

    - name: turn on vcsreplicator
      service: name=vcsreplicator@{{ item }}.service
               state=started
      with_items:
        - '0'
        - '1'
        - '2'
        - '3'
        - '4'
        - '5'
        - '6'
        - '7'

    - name: turn on Telegraf
      service:
        name: telegraf.service
        state: started

- hosts: hg-ssh-prod-master
  gather_facts: no
  tasks:
    - name: run `hg replicatehgrc` on try repos
      command: /var/hg/venv_tools/bin/hg -R /repo/hg/mozilla/{{ item }} replicatehgrc
      with_items:
        - try
        - try-comm-central