From fdae161d301c1d3e89e4bdafdf34a7e09ff0d663 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Thu, 28 Aug 2014 16:21:56 +0000 Subject: Configure distbuild with Ansible --- distbuild/manifest | 19 +++- .../distbuild-setup/ansible/distbuild-setup.yml | 105 +++++++++++++++++++++ distbuild/usr/lib/distbuild-setup/ansible/hosts | 1 + .../usr/lib/systemd/system/distbuild-setup.service | 16 ++++ .../lib/systemd/system/morph-cache-server.service | 3 + .../systemd/system/morph-controller-helper.service | 3 + .../lib/systemd/system/morph-controller.service | 3 + .../lib/systemd/system/morph-worker-helper.service | 3 + .../usr/lib/systemd/system/morph-worker.service | 3 + .../distbuild-setup.service | 1 + .../morph-cache-server.service | 1 - .../morph-controller-helper.service | 1 - .../morph-controller.service | 1 - .../morph-worker-helper.service | 1 - .../multi-user.target.wants/morph-worker.service | 1 - .../share/distbuild-setup/morph-cache-server.conf | 5 + .../distbuild-setup/morph-controller-helper.conf | 5 + .../share/distbuild-setup/morph-controller.conf | 6 ++ .../share/distbuild-setup/morph-worker-helper.conf | 4 + .../usr/share/distbuild-setup/morph-worker.conf | 4 + distbuild/usr/share/distbuild-setup/morph.conf | 13 +++ 21 files changed, 189 insertions(+), 10 deletions(-) create mode 100644 distbuild/usr/lib/distbuild-setup/ansible/distbuild-setup.yml create mode 100644 distbuild/usr/lib/distbuild-setup/ansible/hosts create mode 100644 distbuild/usr/lib/systemd/system/distbuild-setup.service create mode 120000 distbuild/usr/lib/systemd/system/multi-user.target.wants/distbuild-setup.service delete mode 120000 distbuild/usr/lib/systemd/system/multi-user.target.wants/morph-cache-server.service delete mode 120000 distbuild/usr/lib/systemd/system/multi-user.target.wants/morph-controller-helper.service delete mode 120000 distbuild/usr/lib/systemd/system/multi-user.target.wants/morph-controller.service delete mode 120000 distbuild/usr/lib/systemd/system/multi-user.target.wants/morph-worker-helper.service delete mode 120000 distbuild/usr/lib/systemd/system/multi-user.target.wants/morph-worker.service create mode 100644 distbuild/usr/share/distbuild-setup/morph-cache-server.conf create mode 100644 distbuild/usr/share/distbuild-setup/morph-controller-helper.conf create mode 100644 distbuild/usr/share/distbuild-setup/morph-controller.conf create mode 100644 distbuild/usr/share/distbuild-setup/morph-worker-helper.conf create mode 100644 distbuild/usr/share/distbuild-setup/morph-worker.conf create mode 100644 distbuild/usr/share/distbuild-setup/morph.conf diff --git a/distbuild/manifest b/distbuild/manifest index eba7c9f1..35047028 100644 --- a/distbuild/manifest +++ b/distbuild/manifest @@ -4,6 +4,10 @@ 0100755 0 0 /lib/systemd/system-generators/ccache-nfs-mount-generator 0040755 0 0 /usr 0040755 0 0 /usr/lib +0040755 0 0 /usr/lib/distbuild-setup +0040755 0 0 /usr/lib/distbuild-setup/ansible +0100644 0 0 /usr/lib/distbuild-setup/ansible/hosts +0100644 0 0 /usr/lib/distbuild-setup/ansible/distbuild-setup.yml 0040755 0 0 /usr/lib/systemd 0040755 0 0 /usr/lib/systemd/system 0100755 0 0 /usr/lib/systemd/system/morph-cache-server.service @@ -11,9 +15,14 @@ 0100755 0 0 /usr/lib/systemd/system/morph-controller-helper.service 0100755 0 0 /usr/lib/systemd/system/morph-worker.service 0100755 0 0 /usr/lib/systemd/system/morph-worker-helper.service +0100755 0 0 /usr/lib/systemd/system/distbuild-setup.service 0040755 0 0 /usr/lib/systemd/system/multi-user.target.wants -0120755 0 0 /usr/lib/systemd/system/multi-user.target.wants/morph-cache-server.service -0120755 0 0 /usr/lib/systemd/system/multi-user.target.wants/morph-controller.service -0120755 0 0 /usr/lib/systemd/system/multi-user.target.wants/morph-controller-helper.service -0120755 0 0 /usr/lib/systemd/system/multi-user.target.wants/morph-worker.service -0120755 0 0 /usr/lib/systemd/system/multi-user.target.wants/morph-worker-helper.service +0120755 0 0 /usr/lib/systemd/system/multi-user.target.wants/distbuild-setup.service +0040755 0 0 /usr/share +0040755 0 0 /usr/share/distbuild-setup +0100644 0 0 /usr/share/distbuild-setup/morph.conf +0100644 0 0 /usr/share/distbuild-setup/morph-cache-server.conf +0100644 0 0 /usr/share/distbuild-setup/morph-controller.conf +0100644 0 0 /usr/share/distbuild-setup/morph-controller-helper.conf +0100644 0 0 /usr/share/distbuild-setup/morph-worker.conf +0100644 0 0 /usr/share/distbuild-setup/morph-worker-helper.conf diff --git a/distbuild/usr/lib/distbuild-setup/ansible/distbuild-setup.yml b/distbuild/usr/lib/distbuild-setup/ansible/distbuild-setup.yml new file mode 100644 index 00000000..e4f94f54 --- /dev/null +++ b/distbuild/usr/lib/distbuild-setup/ansible/distbuild-setup.yml @@ -0,0 +1,105 @@ +--- +- hosts: localhost + vars_files: + - "/etc/distbuild/distbuild.conf" + tasks: + + - set_fact: ARTIFACT_CACHE_SERVER={{ TROVE_HOST }} + when: ARTIFACT_CACHE_SERVER is not defined + + - name: Create mountpoint for extra disk space /srv/distbuild/ + file: path=/srv/distbuild state=directory owner=root group=root mode=0755 + + - name: Create the morph and morph-cache-server configuration files + template: src=/usr/share/distbuild-setup/{{ item }} dest=/etc/{{ item }} + with_items: + - morph.conf + - morph-cache-server.conf + + - name: Link the morph log file + file: src=/srv/distbuild/morph.log dest=/var/log/morph.log state=link force=yes + + - name: Create the controller configuration files + template: src=/usr/share/distbuild-setup/{{ item }} dest=/etc/{{ item }} + with_items: + - morph-controller.conf + - morph-controller-helper.conf + when: DISTBUILD_CONTROLLER + + - name: Link the controller log files + file: src=/srv/distbuild/{{ item }} dest=/var/log/{{ item }} state=link force=yes + with_items: + - morph-controller.log + - morph-controller-helper.log + when: DISTBUILD_CONTROLLER + + - name: Create the worker configuration files + template: src=/usr/share/distbuild-setup/{{ item }} dest=/etc/{{ item }} + with_items: + - morph-worker.conf + - morph-worker-helper.conf + when: DISTBUILD_WORKER + + - name: Link the controller log files + file: src=/srv/distbuild/{{ item }} dest=/var/log/{{ item }} state=link force=yes + with_items: + - morph-worker.log + - morph-worker-helper.log + when: DISTBUILD_WORKER + + - name: Create /root/.ssh directory + file: path=/root/.ssh state=directory owner=root group=root mode=0700 + + - name: Copy the worker ssh key + copy: src={{ WORKER_SSH_KEY }} dest=/root/.ssh/id_rsa owner=root group=root mode=0600 + + - name: Create ssh public key + shell: ssh-keygen -y -f /root/.ssh/id_rsa > /root/.ssh/id_rsa.pub creates=/root/.ssh/id_rsa.pub + + - name: Add trove's host key + shell: | + trove_key="$(ssh-keyscan -t dsa,ecdsa,rsa {{ TROVE_HOST|quote }})" + if [ -n "$trove_key" ]; then + echo "$trove_key" > /etc/ssh/ssh_known_hosts + fi + creates=/etc/ssh/ssh_known_hosts + + + - name: Enable the morph-cache-server service + service: name=morph-cache-server.service enabled=yes + register: morph_cache_server_service + - name: Restart the morph-cache-server service + service: name=morph-cache-server state=restarted + when: morph_cache_server_service|changed + + - name: Enable the morph-worker service + service: name=morph-worker.service enabled=yes + register: morph_worker_service + when: DISTBUILD_WORKER + - name: Restart the morph-worker service + service: name=morph-worker state=restarted + when: morph_worker_service|changed + + - name: Enable the morph-worker-helper service + service: name=morph-worker-helper.service enabled=yes + register: morph_worker_helper_service + when: DISTBUILD_WORKER + - name: Restart the morph-worker-helper service + service: name=morph-worker-helper state=restarted + when: morph_worker_helper_service|changed + + - name: Enable the morph-controller service + service: name=morph-controller.service enabled=yes + register: morph_controller_service + when: DISTBUILD_CONTROLLER + - name: Restart the morph-controller service + service: name=morph-controller state=restarted + when: morph_controller_service|changed + + - name: Enable the morph-controller-helper service + service: name=morph-controller-helper.service enabled=yes + register: morph_controller_helper_service + when: DISTBUILD_CONTROLLER + - name: Restart the morph-controller-helper service + service: name=morph-controller-helper state=restarted + when: morph_controller_helper_service|changed diff --git a/distbuild/usr/lib/distbuild-setup/ansible/hosts b/distbuild/usr/lib/distbuild-setup/ansible/hosts new file mode 100644 index 00000000..5b97818d --- /dev/null +++ b/distbuild/usr/lib/distbuild-setup/ansible/hosts @@ -0,0 +1 @@ +localhost ansible_connection=local diff --git a/distbuild/usr/lib/systemd/system/distbuild-setup.service b/distbuild/usr/lib/systemd/system/distbuild-setup.service new file mode 100644 index 00000000..ec5f5a2d --- /dev/null +++ b/distbuild/usr/lib/systemd/system/distbuild-setup.service @@ -0,0 +1,16 @@ +[Unit] +Description=Run distbuild-setup Ansible scripts +Requires=network.target +After=network.target +Requires=opensshd.service +After=opensshd.service + +# If there's a shared /var subvolume, it must be mounted before this +# unit runs. +Requires=local-fs.target +After=local-fs.target + +ConditionPathExists=/etc/distbuild/distbuild.conf + +[Service] +ExecStart=/usr/bin/ansible-playbook -v -i /usr/lib/distbuild-setup/ansible/hosts /usr/lib/distbuild-setup/ansible/distbuild-setup.yml diff --git a/distbuild/usr/lib/systemd/system/morph-cache-server.service b/distbuild/usr/lib/systemd/system/morph-cache-server.service index 7ee5e167..f55f3b6d 100644 --- a/distbuild/usr/lib/systemd/system/morph-cache-server.service +++ b/distbuild/usr/lib/systemd/system/morph-cache-server.service @@ -1,3 +1,6 @@ +[Install] +WantedBy=multi-user.target + [Unit] Description=Morph cache server Requires=local-fs.target network.target diff --git a/distbuild/usr/lib/systemd/system/morph-controller-helper.service b/distbuild/usr/lib/systemd/system/morph-controller-helper.service index 9e5bd3c8..3f30cbcf 100644 --- a/distbuild/usr/lib/systemd/system/morph-controller-helper.service +++ b/distbuild/usr/lib/systemd/system/morph-controller-helper.service @@ -1,3 +1,6 @@ +[Install] +WantedBy=multi-user.target + [Unit] Description=Morph distributed build controller helper Requires=morph-controller.service diff --git a/distbuild/usr/lib/systemd/system/morph-controller.service b/distbuild/usr/lib/systemd/system/morph-controller.service index b3ba93b4..1556d232 100644 --- a/distbuild/usr/lib/systemd/system/morph-controller.service +++ b/distbuild/usr/lib/systemd/system/morph-controller.service @@ -1,3 +1,6 @@ +[Install] +WantedBy=multi-user.target + [Unit] Description=Morph distributed build controller Requires=local-fs.target network.target diff --git a/distbuild/usr/lib/systemd/system/morph-worker-helper.service b/distbuild/usr/lib/systemd/system/morph-worker-helper.service index 14c082ce..28400701 100644 --- a/distbuild/usr/lib/systemd/system/morph-worker-helper.service +++ b/distbuild/usr/lib/systemd/system/morph-worker-helper.service @@ -1,3 +1,6 @@ +[Install] +WantedBy=multi-user.target + [Unit] Description=Morph distributed build worker helper Requires=morph-worker.service diff --git a/distbuild/usr/lib/systemd/system/morph-worker.service b/distbuild/usr/lib/systemd/system/morph-worker.service index 26dcb9ad..90fea404 100644 --- a/distbuild/usr/lib/systemd/system/morph-worker.service +++ b/distbuild/usr/lib/systemd/system/morph-worker.service @@ -1,3 +1,6 @@ +[Install] +WantedBy=multi-user.target + [Unit] Description=Morph distributed build worker Requires=local-fs.target network.target diff --git a/distbuild/usr/lib/systemd/system/multi-user.target.wants/distbuild-setup.service b/distbuild/usr/lib/systemd/system/multi-user.target.wants/distbuild-setup.service new file mode 120000 index 00000000..8f06febd --- /dev/null +++ b/distbuild/usr/lib/systemd/system/multi-user.target.wants/distbuild-setup.service @@ -0,0 +1 @@ +../distbuild-setup.service \ No newline at end of file diff --git a/distbuild/usr/lib/systemd/system/multi-user.target.wants/morph-cache-server.service b/distbuild/usr/lib/systemd/system/multi-user.target.wants/morph-cache-server.service deleted file mode 120000 index e624a31d..00000000 --- a/distbuild/usr/lib/systemd/system/multi-user.target.wants/morph-cache-server.service +++ /dev/null @@ -1 +0,0 @@ -../morph-cache-server.service \ No newline at end of file diff --git a/distbuild/usr/lib/systemd/system/multi-user.target.wants/morph-controller-helper.service b/distbuild/usr/lib/systemd/system/multi-user.target.wants/morph-controller-helper.service deleted file mode 120000 index 1554df76..00000000 --- a/distbuild/usr/lib/systemd/system/multi-user.target.wants/morph-controller-helper.service +++ /dev/null @@ -1 +0,0 @@ -../morph-controller-helper.service \ No newline at end of file diff --git a/distbuild/usr/lib/systemd/system/multi-user.target.wants/morph-controller.service b/distbuild/usr/lib/systemd/system/multi-user.target.wants/morph-controller.service deleted file mode 120000 index 9d92814b..00000000 --- a/distbuild/usr/lib/systemd/system/multi-user.target.wants/morph-controller.service +++ /dev/null @@ -1 +0,0 @@ -../morph-controller.service \ No newline at end of file diff --git a/distbuild/usr/lib/systemd/system/multi-user.target.wants/morph-worker-helper.service b/distbuild/usr/lib/systemd/system/multi-user.target.wants/morph-worker-helper.service deleted file mode 120000 index 298c582f..00000000 --- a/distbuild/usr/lib/systemd/system/multi-user.target.wants/morph-worker-helper.service +++ /dev/null @@ -1 +0,0 @@ -../morph-worker-helper.service \ No newline at end of file diff --git a/distbuild/usr/lib/systemd/system/multi-user.target.wants/morph-worker.service b/distbuild/usr/lib/systemd/system/multi-user.target.wants/morph-worker.service deleted file mode 120000 index 3f8d58a8..00000000 --- a/distbuild/usr/lib/systemd/system/multi-user.target.wants/morph-worker.service +++ /dev/null @@ -1 +0,0 @@ -../morph-worker.service \ No newline at end of file diff --git a/distbuild/usr/share/distbuild-setup/morph-cache-server.conf b/distbuild/usr/share/distbuild-setup/morph-cache-server.conf new file mode 100644 index 00000000..b9020e7d --- /dev/null +++ b/distbuild/usr/share/distbuild-setup/morph-cache-server.conf @@ -0,0 +1,5 @@ +[config] +port = 8080 +artifact-dir = /srv/distbuild/artifacts +direct-mode = True +fcgi-server = False diff --git a/distbuild/usr/share/distbuild-setup/morph-controller-helper.conf b/distbuild/usr/share/distbuild-setup/morph-controller-helper.conf new file mode 100644 index 00000000..99d38739 --- /dev/null +++ b/distbuild/usr/share/distbuild-setup/morph-controller-helper.conf @@ -0,0 +1,5 @@ +[config] +log = /srv/distbuild/morph-controller-helper.log +log-max = 100M +parent-port = 5656 +parent-address = 127.0.0.1 diff --git a/distbuild/usr/share/distbuild-setup/morph-controller.conf b/distbuild/usr/share/distbuild-setup/morph-controller.conf new file mode 100644 index 00000000..c16c0343 --- /dev/null +++ b/distbuild/usr/share/distbuild-setup/morph-controller.conf @@ -0,0 +1,6 @@ +[config] +log = /srv/distbuild/morph-controller.log +log-max = 100M +writeable-cache-server = http://{{ ARTIFACT_CACHE_SERVER }}:8081/ +worker = {{ WORKERS }} +controller-helper-address = 127.0.0.1 diff --git a/distbuild/usr/share/distbuild-setup/morph-worker-helper.conf b/distbuild/usr/share/distbuild-setup/morph-worker-helper.conf new file mode 100644 index 00000000..29d4ef3f --- /dev/null +++ b/distbuild/usr/share/distbuild-setup/morph-worker-helper.conf @@ -0,0 +1,4 @@ +[config] +log = /srv/distbuild/morph-worker-helper.log +log-max = 100M +parent-address = 127.0.0.1 diff --git a/distbuild/usr/share/distbuild-setup/morph-worker.conf b/distbuild/usr/share/distbuild-setup/morph-worker.conf new file mode 100644 index 00000000..fb382bad --- /dev/null +++ b/distbuild/usr/share/distbuild-setup/morph-worker.conf @@ -0,0 +1,4 @@ +[config] +log = /srv/distbuild/morph-worker.log +log-max = 100M +controller-initiator-address = diff --git a/distbuild/usr/share/distbuild-setup/morph.conf b/distbuild/usr/share/distbuild-setup/morph.conf new file mode 100644 index 00000000..29de684c --- /dev/null +++ b/distbuild/usr/share/distbuild-setup/morph.conf @@ -0,0 +1,13 @@ +[config] +log = /srv/distbuild/morph.log +log-max = 100M +cachedir = /srv/distbuild +tempdir = /srv/distbuild/tmp +trove-host = {{ TROVE_HOST }} +trove-id = {{ TROVE_ID }} +controller-initiator-address = {{ CONTROLLERHOST }} +tempdir-min-space = 4G +cachedir-min-space = 4G +build-ref-prefix = {{ TROVE_ID }} +artifact-cache-server = http://{{ ARTIFACT_CACHE_SERVER }}:8080/ +git-resolve-cache-server = http://{{ TROVE_HOST }}:8080/ -- cgit v1.2.1