Skip to content

Commit

Permalink
Add support for Ubuntu 18.04 (bionic) (#60)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
nre-ableton authored and emmetog committed Jan 1, 2020
1 parent b0a3d53 commit f619ece
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 1 deletion.
16 changes: 16 additions & 0 deletions molecule/bionic/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -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
46 changes: 46 additions & 0 deletions molecule/bionic/jenkins-configs/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version='1.1' encoding='UTF-8'?>
<hudson>
<disabledAdministrativeMonitors/>
<version>2.176.1</version>
<installStateName>RESTART</installStateName>
<numExecutors>1</numExecutors>
<mode>EXCLUSIVE</mode>
<useSecurity>true</useSecurity>
<authorizationStrategy class="hudson.security.AuthorizationStrategy$Unsecured"/>
<securityRealm class="hudson.security.HudsonPrivateSecurityRealm">
<disableSignup>false</disableSignup>
<enableCaptcha>false</enableCaptcha>
</securityRealm>
<disableRememberMe>false</disableRememberMe>
<projectNamingStrategy class="jenkins.model.ProjectNamingStrategy$DefaultProjectNamingStrategy"/>
<workspaceDir>${JENKINS_HOME}/workspace/${ITEM_FULLNAME}</workspaceDir>
<buildsDir>${ITEM_ROOTDIR}/builds</buildsDir>
<markupFormatter class="hudson.markup.EscapedMarkupFormatter"/>
<jdks/>
<viewsTabBar class="hudson.views.DefaultViewsTabBar"/>
<myViewsTabBar class="hudson.views.DefaultMyViewsTabBar"/>
<clouds/>
<quietPeriod>0</quietPeriod>
<scmCheckoutRetryCount>0</scmCheckoutRetryCount>
<views>
<hudson.model.AllView>
<owner class="hudson" reference="../../.."/>
<name>all</name>
<filterExecutors>false</filterExecutors>
<filterQueue>false</filterQueue>
<properties class="hudson.model.View$PropertyList"/>
</hudson.model.AllView>
</views>
<primaryView>all</primaryView>
<slaveAgentPort>0</slaveAgentPort>
<disabledAgentProtocols>
<string>JNLP-connect</string>
<string>JNLP2-connect</string>
</disabledAgentProtocols>
<label>master</label>
<crumbIssuer class="hudson.security.csrf.DefaultCrumbIssuer">
<excludeClientIPFromCrumb>false</excludeClientIPFromCrumb>
</crumbIssuer>
<nodeProperties/>
<globalNodeProperties/>
</hudson>
31 changes: 31 additions & 0 deletions molecule/bionic/molecule.yml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions molecule/bionic/playbook.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions molecule/bionic/tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__/
22 changes: 22 additions & 0 deletions molecule/bionic/tests/test_default.py
Original file line number Diff line number Diff line change
@@ -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'
1 change: 0 additions & 1 deletion tasks/apt/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,4 @@
- name: Install Jenkins binary package
apt:
name: "jenkins={{ jenkins_version }}"
force: true
update_cache: true

0 comments on commit f619ece

Please sign in to comment.