-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improvements to README - Re-order sections so that important stuff comes first - Replace sample Jenkins config.xml with something more minimal (the old one had EC2 plugin configuration stuff, etc) - Fix indentation in example playbook, improve example vars used there - Improve documentation for HTTPS - Various cleanups and minor improvements Sorry for the large diff! * Copy SSL certificates to secrets dir, not home They are much safer here, since that directory is mode 0700. * Copy CA certificate private key to server Should have been done in c2652e6. * Fix HTTPS option strings for config file - Use the ">-" multi-line operator to trim newlines - Fix the destination path by using the basename filter * Merge configure-config.yml -> configure-jenkins.yml Sorry, it was not really necessary to introduce a new task file here. The configure-jenkins.yml file should handle the main Jenkins-related configuration, which also includes SSL stuff. * Cleanup: improve task names, sort attributes * Always create secrets dir Even if copying a local secrets directory is not desired, we need to ensure that the secrets dir exists and is owned by the Jenkins user. We'll potentially copy SSL secrets here. * Set HTTP*_PORT variables in config file Previous to this change, we were using lineinfile to set HTTP_PORT, but just ignoring that value in JENKINS_ARGS. This change fixes that, and also adds another variable for HTTPS_PORT, which is not defined by default in some package distribution versions of this file. * Add a molecule scenario for HTTPS
- Loading branch information
1 parent
d0e55de
commit 510104b
Showing
11 changed files
with
400 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Molecule managed | ||
|
||
{% if item.registry is defined %} | ||
FROM {{ item.registry.url }}/{{ item.image }} | ||
{% else %} | ||
FROM {{ item.image }} | ||
{% endif %} | ||
|
||
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 648ACFD622F3D138 && \ | ||
apt-get update && \ | ||
apt-get install -y apt-transport-https aptitude bash ca-certificates sudo python \ | ||
python-apt && \ | ||
apt-get clean | ||
|
||
RUN useradd -G sudo molecule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version='1.1' encoding='UTF-8'?> | ||
<hudson> | ||
<disabledAdministrativeMonitors/> | ||
<version>2.190.2</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> | ||
<nodeProperties/> | ||
<globalNodeProperties/> | ||
</hudson> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
driver: | ||
name: docker | ||
lint: | ||
name: yamllint | ||
platforms: | ||
- name: instance | ||
image: ubuntu:16.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 | ||
env: | ||
# Instruct the python-jenkins library to ignore SSL verification errors, which are | ||
# caused by the self-signed certificate. | ||
PYTHONHTTPSVERIFY: "0" | ||
lint: | ||
name: flake8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
vars: | ||
jenkins_auth: "none" | ||
jenkins_config_owner: "jenkins" | ||
jenkins_config_group: "jenkins" | ||
jenkins_home: "/jenkins" | ||
jenkins_https_keystore: "{{ playbook_dir }}/ssl/test-cert.jks" | ||
# NOTE: For testing purposes, we are using a self-signed certificate with the password | ||
# of "password". You are of course advised to store such data in an Ansible vault. | ||
jenkins_https_keystore_password: "password" | ||
jenkins_https_validate_certs: false | ||
jenkins_install_via: "apt" | ||
jenkins_port: "-1" | ||
jenkins_port_https: "8080" | ||
jenkins_version: "2.190.2" | ||
roles: | ||
- ansible-jenkins |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
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('https://127.0.0.1:8080') | ||
version = master.get_version() | ||
|
||
assert version == '2.190.2' | ||
|
||
|
||
def test_jenkins_java_process(host): | ||
process = host.process.get(command='/usr/bin/java') | ||
|
||
assert '-Djenkins.install.runSetupWizard=false' in process.args | ||
assert '--httpsKeyStore=/jenkins/secrets/test-cert.jks' in process.args | ||
assert '--httpsKeyStorePassword=password' in process.args |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters