From 02faf51e91a8c55adfbb6d953bca354ab99bf261 Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Tue, 2 Jun 2015 08:40:27 +0000 Subject: Move all the directories used for install-files into a subdirectory Change-Id: I309c183ce8b9ff9d0f5ac4807244547f2cc4ddf5 --- .../distbuild-setup/ansible/distbuild-setup.yml | 115 +++++++++++++++++++++ .../usr/lib/distbuild-setup/ansible/hosts | 1 + .../usr/lib/systemd/system/distbuild-setup.service | 16 +++ .../lib/systemd/system/morph-cache-server.service | 12 +++ .../systemd/system/morph-controller-helper.service | 13 +++ .../lib/systemd/system/morph-controller.service | 12 +++ .../lib/systemd/system/morph-worker-helper.service | 13 +++ .../usr/lib/systemd/system/morph-worker.service | 13 +++ .../distbuild-setup.service | 1 + 9 files changed, 196 insertions(+) create mode 100644 install-files/distbuild/usr/lib/distbuild-setup/ansible/distbuild-setup.yml create mode 100644 install-files/distbuild/usr/lib/distbuild-setup/ansible/hosts create mode 100644 install-files/distbuild/usr/lib/systemd/system/distbuild-setup.service create mode 100644 install-files/distbuild/usr/lib/systemd/system/morph-cache-server.service create mode 100644 install-files/distbuild/usr/lib/systemd/system/morph-controller-helper.service create mode 100644 install-files/distbuild/usr/lib/systemd/system/morph-controller.service create mode 100644 install-files/distbuild/usr/lib/systemd/system/morph-worker-helper.service create mode 100644 install-files/distbuild/usr/lib/systemd/system/morph-worker.service create mode 120000 install-files/distbuild/usr/lib/systemd/system/multi-user.target.wants/distbuild-setup.service (limited to 'install-files/distbuild/usr/lib') diff --git a/install-files/distbuild/usr/lib/distbuild-setup/ansible/distbuild-setup.yml b/install-files/distbuild/usr/lib/distbuild-setup/ansible/distbuild-setup.yml new file mode 100644 index 00000000..c3074c63 --- /dev/null +++ b/install-files/distbuild/usr/lib/distbuild-setup/ansible/distbuild-setup.yml @@ -0,0 +1,115 @@ +--- +- 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 + + # This is a kludge. We can add the host key for the TROVE_HOST that was + # specified, but users may access the Trove by other names, e.g. IP address + # or domain name. Distbuild is currently not safe to run except on a private + # network where host key checking is not important, so we disable it by + # default to avoid errors when users don't stick to using the exact same + # TROVE_HOST in repo URLs. + - name: Disable strict SSH host key checking + lineinfile: + dest: /etc/ssh/ssh_config + line: StrictHostKeyChecking no + + - 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/install-files/distbuild/usr/lib/distbuild-setup/ansible/hosts b/install-files/distbuild/usr/lib/distbuild-setup/ansible/hosts new file mode 100644 index 00000000..5b97818d --- /dev/null +++ b/install-files/distbuild/usr/lib/distbuild-setup/ansible/hosts @@ -0,0 +1 @@ +localhost ansible_connection=local diff --git a/install-files/distbuild/usr/lib/systemd/system/distbuild-setup.service b/install-files/distbuild/usr/lib/systemd/system/distbuild-setup.service new file mode 100644 index 00000000..ec5f5a2d --- /dev/null +++ b/install-files/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/install-files/distbuild/usr/lib/systemd/system/morph-cache-server.service b/install-files/distbuild/usr/lib/systemd/system/morph-cache-server.service new file mode 100644 index 00000000..f55f3b6d --- /dev/null +++ b/install-files/distbuild/usr/lib/systemd/system/morph-cache-server.service @@ -0,0 +1,12 @@ +[Install] +WantedBy=multi-user.target + +[Unit] +Description=Morph cache server +Requires=local-fs.target network.target +After=local-fs.target network.target +ConditionPathExists=/etc/morph-cache-server.conf + +[Service] +ExecStart=/usr/bin/morph-cache-server +Restart=always diff --git a/install-files/distbuild/usr/lib/systemd/system/morph-controller-helper.service b/install-files/distbuild/usr/lib/systemd/system/morph-controller-helper.service new file mode 100644 index 00000000..3f30cbcf --- /dev/null +++ b/install-files/distbuild/usr/lib/systemd/system/morph-controller-helper.service @@ -0,0 +1,13 @@ +[Install] +WantedBy=multi-user.target + +[Unit] +Description=Morph distributed build controller helper +Requires=morph-controller.service +After=morph-controller.service +ConditionPathExists=/etc/morph-controller.conf +ConditionPathExists=/etc/morph-controller-helper.conf + +[Service] +ExecStart=/usr/bin/distbuild-helper --config /etc/morph-controller-helper.conf +Restart=always diff --git a/install-files/distbuild/usr/lib/systemd/system/morph-controller.service b/install-files/distbuild/usr/lib/systemd/system/morph-controller.service new file mode 100644 index 00000000..1556d232 --- /dev/null +++ b/install-files/distbuild/usr/lib/systemd/system/morph-controller.service @@ -0,0 +1,12 @@ +[Install] +WantedBy=multi-user.target + +[Unit] +Description=Morph distributed build controller +Requires=local-fs.target network.target +After=local-fs.target network.target +ConditionPathExists=/etc/morph-controller.conf + +[Service] +ExecStart=/usr/bin/morph controller-daemon --config /etc/morph-controller.conf +Restart=always diff --git a/install-files/distbuild/usr/lib/systemd/system/morph-worker-helper.service b/install-files/distbuild/usr/lib/systemd/system/morph-worker-helper.service new file mode 100644 index 00000000..28400701 --- /dev/null +++ b/install-files/distbuild/usr/lib/systemd/system/morph-worker-helper.service @@ -0,0 +1,13 @@ +[Install] +WantedBy=multi-user.target + +[Unit] +Description=Morph distributed build worker helper +Requires=morph-worker.service +After=morph-worker.service +ConditionPathExists=/etc/morph-worker.conf +ConditionPathExists=/etc/morph-worker-helper.conf + +[Service] +ExecStart=/usr/bin/distbuild-helper --config /etc/morph-worker-helper.conf +Restart=always diff --git a/install-files/distbuild/usr/lib/systemd/system/morph-worker.service b/install-files/distbuild/usr/lib/systemd/system/morph-worker.service new file mode 100644 index 00000000..90fea404 --- /dev/null +++ b/install-files/distbuild/usr/lib/systemd/system/morph-worker.service @@ -0,0 +1,13 @@ +[Install] +WantedBy=multi-user.target + +[Unit] +Description=Morph distributed build worker +Requires=local-fs.target network.target +Wants=srv-distbuild-ccache.mount +After=local-fs.target network.target srv-distbuild-ccache.mount +ConditionPathExists=/etc/morph-worker.conf + +[Service] +ExecStart=/usr/bin/morph worker-daemon --config /etc/morph-worker.conf +Restart=always diff --git a/install-files/distbuild/usr/lib/systemd/system/multi-user.target.wants/distbuild-setup.service b/install-files/distbuild/usr/lib/systemd/system/multi-user.target.wants/distbuild-setup.service new file mode 120000 index 00000000..8f06febd --- /dev/null +++ b/install-files/distbuild/usr/lib/systemd/system/multi-user.target.wants/distbuild-setup.service @@ -0,0 +1 @@ +../distbuild-setup.service \ No newline at end of file -- cgit v1.2.1