]> Git Repo - VerusCoin.git/commitdiff
Add Buildbot worker setup to Ansible playbook
authorJack Grigg <[email protected]>
Mon, 10 Jul 2017 16:08:36 +0000 (11:08 -0500)
committerJack Grigg <[email protected]>
Fri, 14 Jul 2017 17:33:55 +0000 (12:33 -0500)
Currently assumes the host uses systemd

contrib/ci-workers/templates/buildbot-worker.service.j2 [new file with mode: 0644]
contrib/ci-workers/templates/host.j2 [new file with mode: 0644]
contrib/ci-workers/unix.yml
contrib/ci-workers/vars/buildbot.yml [new file with mode: 0644]

diff --git a/contrib/ci-workers/templates/buildbot-worker.service.j2 b/contrib/ci-workers/templates/buildbot-worker.service.j2
new file mode 100644 (file)
index 0000000..1fee26a
--- /dev/null
@@ -0,0 +1,17 @@
+[Unit]
+Description=Buildbot worker
+Wants=network.target
+After=network.target
+
+[Service]
+Type=forking
+PIDFile=/home/{{ buildbot_worker_user }}/{{ buildbot_worker_name }}/twistd.pid
+WorkingDirectory=/home/{{ buildbot_worker_user }}
+ExecStart=/usr/local/bin/buildbot-worker start {{ buildbot_worker_name }}
+ExecReload=/usr/local/bin/buildbot-worker restart {{ buildbot_worker_name }}
+ExecStop=/usr/local/bin/buildbot-worker stop {{ buildbot_worker_name }}
+Restart=always
+User={{ buildbot_worker_user }}
+
+[Install]
+WantedBy=multi-user.target
diff --git a/contrib/ci-workers/templates/host.j2 b/contrib/ci-workers/templates/host.j2
new file mode 100644 (file)
index 0000000..708baf6
--- /dev/null
@@ -0,0 +1,4 @@
+OS: {{ ansible_distribution }} {{ ansible_distribution_version }}
+Memory: {{ ansible_memtotal_mb }} MB
+CPU: {{ ansible_processor[1] }}
+{{ buildbot_worker_version.stdout }}
index 6fd56a0a8169164433f34be7edb70cad29d72945..ecc8264805c6a5d863ae66c4dc5421e5b1aa5004 100644 (file)
@@ -6,6 +6,17 @@
 
   vars_files:
     - vars/default.yml
+    - vars/buildbot.yml
+
+  vars_prompt:
+    - name: "buildbot_worker_admin"
+      prompt: "Admin details"
+      default: "Zcash <[email protected]>"
+    - name: "buildbot_worker_name"
+      prompt: "Buildbot worker name (provided by ZECC)"
+      private: no
+    - name: "buildbot_worker_password"
+      prompt: "Buildbot worker password (provided by ZECC)"
 
   pre_tasks:
     - name: Install Python 2 for Ansible and Buildbot
         name: "{{ item }}"
         state: latest
       with_items: "{{ python_modules }}"
+      notify: restart buildbot-worker
+
+    - name: Get installed Buildbot version
+      command: buildbot-worker --version
+      register: buildbot_worker_version
+
+    - name: Set up the Buildbot worker user
+      user:
+        name: "{{ buildbot_worker_user }}"
+        comment: Buildbot worker
+        shell: /bin/bash
+        state: present
+
+    - name: Create Buildbot worker
+      command: >
+        buildbot-worker create-worker ~/{{ buildbot_worker_name }}
+        {{ buildbot_master_host }}:{{ buildbot_master_port }}
+        {{ buildbot_worker_name|quote }} {{ buildbot_worker_password|quote }}
+      args:
+        creates: "~/{{ buildbot_worker_name }}/buildbot.tac"
+      become_user: "{{ buildbot_worker_user }}"
+
+    - name: Set admin details for Buildbot worker
+      copy:
+        content: "{{ buildbot_worker_admin }}"
+        dest: "~/{{ buildbot_worker_name }}/info/admin"
+      become_user: "{{ buildbot_worker_user }}"
+
+    - name: Set host details for Buildbot worker
+      template:
+        src: templates/host.j2
+        dest: "~/{{ buildbot_worker_name }}/info/host"
+      become_user: "{{ buildbot_worker_user }}"
+
+    - name: Copy Buildbot worker systemd service unit
+      template:
+        src: templates/buildbot-worker.service.j2
+        dest: "/etc/systemd/system/buildbot-worker.service"
+        owner: root
+        group: root
+        mode: "0644"
+      notify: reload systemd
+
+    - name: Start Buildbot worker.
+      service:
+        name: buildbot-worker
+        state: started
+        enabled: yes
+
+  handlers:
+    - name: restart buildbot-worker
+      service:
+        name: buildbot-worker
+        state: restarted
+
+    - name: reload systemd
+      command: /bin/systemctl daemon-reload
diff --git a/contrib/ci-workers/vars/buildbot.yml b/contrib/ci-workers/vars/buildbot.yml
new file mode 100644 (file)
index 0000000..3d21f40
--- /dev/null
@@ -0,0 +1,4 @@
+---
+buildbot_worker_user: zcbbworker
+buildbot_master_host: dev-ci.z.cash
+buildbot_master_port: 9899
This page took 0.029363 seconds and 4 git commands to generate.