diff --git a/.zuul.yaml b/.zuul.yaml index cece9ea..e006dd1 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -44,12 +44,23 @@ parent: ansible-role-nodepool-src nodeset: ubuntu-bionic +# Testing for nodepool_install_method: docker +- job: + name: ansible-role-nodepool-docker + parent: ansible-role-nodepool-base + nodeset: ubuntu-bionic + vars: + nodepool_install_method: docker + nodepool_file_nodepool_builder_service_src: etc/systemd/system/nodepool-builder.service.j2 + nodepool_file_nodepool_launcher_service_src: etc/systemd/system/nodepool-launcher.service.j2 + - project: templates: - windmill-jobs-fedora-latest - windmill-jobs-bionic check: jobs: + - ansible-role-nodepool-docker - ansible-role-nodepool-fedora-latest - ansible-role-nodepool-ubuntu-bionic - ansible-role-nodepool-src-fedora-latest @@ -58,6 +69,7 @@ - windmill-tox-molecule gate: jobs: + - ansible-role-nodepool-docker - ansible-role-nodepool-fedora-latest - ansible-role-nodepool-ubuntu-bionic - ansible-role-nodepool-src-fedora-latest diff --git a/README.rst b/README.rst index 495c443..b19f38c 100644 --- a/README.rst +++ b/README.rst @@ -21,6 +21,12 @@ Requirements ------------ * pip3 to be installed if using nodepool_install_method: (git|pip) +* docker to be installed if using nodepool_install_method: docker + *NOTE* + Docker support should be consider experimental. You will need to create + systemd service files manually. There are too many possible settings + for docker, which make is almost impossible to support via Ansible. + Packages ~~~~~~~~ diff --git a/bindep.txt b/bindep.txt index a62fb2d..4b62b2b 100644 --- a/bindep.txt +++ b/bindep.txt @@ -3,3 +3,4 @@ docker.io [test platform:dpkg] docker [test platform:fedora] +python-docker [test platform:dpkg] diff --git a/defaults/main.yaml b/defaults/main.yaml index 886aa00..6f35209 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -69,6 +69,10 @@ nodepool_pip_name: nodepool # nodepool_pip_virtualenv_python: # nodepool_pip_virtualenv: +nodepool_docker_name: + - zuul/nodepool-builder + - zuul/nodepool-launcher + # tasks/service.yaml nodepool_file_nodepool_builder_service_manage: true nodepool_file_nodepool_builder_service_group: root diff --git a/requirements.txt b/requirements.txt index f3a3f52..172f0d4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ ansible>=2.4.0 +docker diff --git a/tasks/install/docker.yaml b/tasks/install/docker.yaml new file mode 100644 index 0000000..4a49914 --- /dev/null +++ b/tasks/install/docker.yaml @@ -0,0 +1,19 @@ +# Copyright 2018 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +--- +- name: Install nodepool using docker + become: true + docker_image: + name: "{{ item }}" + with_items: "{{ nodepool_docker_name }}" diff --git a/test-requirements.txt b/test-requirements.txt index 6a1de18..1662abc 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,3 +1,2 @@ ara -docker molecule diff --git a/tests/playbooks/pre.yaml b/tests/playbooks/pre.yaml index 5386849..1237d83 100644 --- a/tests/playbooks/pre.yaml +++ b/tests/playbooks/pre.yaml @@ -12,3 +12,13 @@ dest: /etc/pip.conf regexp: ^extra-index-url state: absent + + - name: Execute bindep role + include_role: + name: bindep + vars: + bindep_profile: ansible test + + - name: Execute test-setup role + include_role: + name: test-setup diff --git a/tests/playbooks/templates/etc/systemd/system/nodepool-builder.service.j2 b/tests/playbooks/templates/etc/systemd/system/nodepool-builder.service.j2 new file mode 100644 index 0000000..edbb013 --- /dev/null +++ b/tests/playbooks/templates/etc/systemd/system/nodepool-builder.service.j2 @@ -0,0 +1,14 @@ +[Unit] +Description=Nodepool Builder Service +After=docker.service +Requires=docker.service + +[Service] +Type=simple +# Options to pass to nodepool-builder. +Environment="ARGS=-l /etc/nodepool/builder-logging.conf" +ExecStart=/usr/bin/docker run --rm --name nodepool-builder -u 1001:1001 -v /var/lib/nodepool:/var/lib/nodepool -v /etc/nodepool:/etc/nodepool -v /opt/nodepool:/opt/nodepool -v /var/log/nodepool:/var/log/nodepool -h nodepool-builder zuul/nodepool-builder nodepool-builder -d $ARGS +ExecStop=/usr/bin/docker stop nodepool-builder + +[Install] +WantedBy=multi-user.target diff --git a/tests/playbooks/templates/etc/systemd/system/nodepool-launcher.service.j2 b/tests/playbooks/templates/etc/systemd/system/nodepool-launcher.service.j2 new file mode 100644 index 0000000..29cdf30 --- /dev/null +++ b/tests/playbooks/templates/etc/systemd/system/nodepool-launcher.service.j2 @@ -0,0 +1,14 @@ +[Unit] +Description=Nodepool Launcher Service +After=docker.service +Requires=docker.service + +[Service] +Type=simple +# Options to pass to nodepool-launcher. +Environment="ARGS=-l /etc/nodepool/launcher-logging.conf --no-webapp" +ExecStart=/usr/bin/docker run --rm --name nodepool-launcher -u 1001:1001 -v /var/lib/nodepool:/var/lib/nodepool -v /etc/nodepool:/etc/nodepool -v /opt/nodepool:/opt/nodepool -v /var/log/nodepool:/var/log/nodepool -h nodepool-launcher zuul/nodepool-launcher nodepool-launcher -d $ARGS +ExecStop=/usr/bin/docker stop nodepool-launcher + +[Install] +WantedBy=multi-user.target