From f619ece3cf4d2c120bc0f06d8767d360f8bc29e5 Mon Sep 17 00:00:00 2001 From: Nik Reiman Date: Wed, 1 Jan 2020 02:41:01 +0100 Subject: [PATCH] Add support for Ubuntu 18.04 (bionic) (#60) * Don't force installation of apt packages The Ansible documentation warns against using this option, and the corresponding apt argument has been removed as of Ubuntu 18.04 (bionic). * Add test for deployment on Ubuntu 18.04 (bionic) --- molecule/bionic/Dockerfile.j2 | 16 ++++++++ molecule/bionic/jenkins-configs/config.xml | 46 ++++++++++++++++++++++ molecule/bionic/molecule.yml | 31 +++++++++++++++ molecule/bionic/playbook.yml | 11 ++++++ molecule/bionic/tests/.gitignore | 1 + molecule/bionic/tests/test_default.py | 22 +++++++++++ tasks/apt/install.yml | 1 - 7 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 molecule/bionic/Dockerfile.j2 create mode 100644 molecule/bionic/jenkins-configs/config.xml create mode 100644 molecule/bionic/molecule.yml create mode 100644 molecule/bionic/playbook.yml create mode 100644 molecule/bionic/tests/.gitignore create mode 100644 molecule/bionic/tests/test_default.py diff --git a/molecule/bionic/Dockerfile.j2 b/molecule/bionic/Dockerfile.j2 new file mode 100644 index 0000000..6db723c --- /dev/null +++ b/molecule/bionic/Dockerfile.j2 @@ -0,0 +1,16 @@ +# Molecule managed + +{% if item.registry is defined %} +FROM {{ item.registry.url }}/{{ item.image }} +{% else %} +FROM {{ item.image }} +{% endif %} + +RUN apt-get update && \ + apt-get install -y gpg apt-transport-https aptitude bash ca-certificates sudo \ + python python-apt && \ + apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key 04EE7237B7D453EC && \ + apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key 648ACFD622F3D138 && \ + apt-get clean + +RUN useradd -G sudo molecule diff --git a/molecule/bionic/jenkins-configs/config.xml b/molecule/bionic/jenkins-configs/config.xml new file mode 100644 index 0000000..2c34ddf --- /dev/null +++ b/molecule/bionic/jenkins-configs/config.xml @@ -0,0 +1,46 @@ + + + + 2.176.1 + RESTART + 1 + EXCLUSIVE + true + + + false + false + + false + + ${JENKINS_HOME}/workspace/${ITEM_FULLNAME} + ${ITEM_ROOTDIR}/builds + + + + + + 0 + 0 + + + + all + false + false + + + + all + 0 + + JNLP-connect + JNLP2-connect + + + + false + + + + \ No newline at end of file diff --git a/molecule/bionic/molecule.yml b/molecule/bionic/molecule.yml new file mode 100644 index 0000000..884ca26 --- /dev/null +++ b/molecule/bionic/molecule.yml @@ -0,0 +1,31 @@ +--- +dependency: + name: galaxy +driver: + name: docker +lint: + name: yamllint +platforms: + - name: instance + image: ubuntu:18.04 + privileged: true + exposed_ports: + - 8080/tcp + published_ports: + - 0.0.0.0:8080:8080/tcp + env: + JENKINS_HOME: /jenkins +provisioner: + name: ansible + log: true + lint: + name: ansible-lint + options: + # E602: Don't compare to empty string + # All workarounds for this are uglier than just comparing to empty strings. See: + # https://github.com/ansible/ansible-lint/issues/457 + x: ['602'] +verifier: + name: testinfra + lint: + name: flake8 diff --git a/molecule/bionic/playbook.yml b/molecule/bionic/playbook.yml new file mode 100644 index 0000000..35ca136 --- /dev/null +++ b/molecule/bionic/playbook.yml @@ -0,0 +1,11 @@ +--- +- name: Converge + hosts: all + vars: + jenkins_config_owner: "jenkins" + jenkins_config_group: "jenkins" + jenkins_home: "/jenkins" + jenkins_install_via: "apt" + jenkins_version: "2.176.1" + roles: + - ansible-jenkins diff --git a/molecule/bionic/tests/.gitignore b/molecule/bionic/tests/.gitignore new file mode 100644 index 0000000..c18dd8d --- /dev/null +++ b/molecule/bionic/tests/.gitignore @@ -0,0 +1 @@ +__pycache__/ diff --git a/molecule/bionic/tests/test_default.py b/molecule/bionic/tests/test_default.py new file mode 100644 index 0000000..31177f8 --- /dev/null +++ b/molecule/bionic/tests/test_default.py @@ -0,0 +1,22 @@ +import os + +import testinfra.utils.ansible_runner + +from jenkins import Jenkins + + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +def test_jenkins_installed(host): + package = host.package('jenkins') + + assert package.is_installed + + +def test_jenkins_version(): + master = Jenkins('http://127.0.0.1:8080') + version = master.get_version() + + assert version == '2.176.1' diff --git a/tasks/apt/install.yml b/tasks/apt/install.yml index 4e6ec6c..fe1bed7 100644 --- a/tasks/apt/install.yml +++ b/tasks/apt/install.yml @@ -64,5 +64,4 @@ - name: Install Jenkins binary package apt: name: "jenkins={{ jenkins_version }}" - force: true update_cache: true