Skip to content

Commit 2469edd

Browse files
Merge pull request #163 from greg-hellings/fix_jenkins_url
Fix jenkins url
2 parents 3990f38 + c08a07c commit 2469edd

File tree

8 files changed

+33
-70
lines changed

8 files changed

+33
-70
lines changed

CHANGELOG

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
v 0.8.2 (12 Sep 2017)
2+
- Added jenkins_cli_shell_user and jenkins_cli_shell_user_home, to allow better
3+
configuration of where to configure Jenkins CLI users' SSH keys
4+
- Improved internal construction of the _jenkins_url variable to avoid possible
5+
SSL hostname mismatch errors
6+
- Removed pre-packaged SSH key. Changed to generating when needed
7+
18
v 0.8.1 (11 Sep 2017)
29
- Removed ansible RPM package from jenkins_master role
310

cinch/roles/jenkins_common/defaults/main.yml

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# Local path to a private SSH keyfile to upload into the remote system and
2-
# to set as an authorized keyfile for the Jenkins user
3-
jenkins_ssh_keyfile: id_rsa
41
# The Java version to install. Older versions are deprecated and will not be
52
# supported beyond the EOL support for their packages in the distribution of
63
# choice

cinch/roles/jenkins_common/files/id_rsa

-51
This file was deleted.

cinch/roles/jenkins_common/tasks/main.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@
4040
mode: 0700
4141
state: directory
4242

43-
- name: add private SSH key
44-
copy:
45-
src: "{{ jenkins_ssh_keyfile }}"
46-
dest: "{{ jenkins_user_home }}/.ssh/id_rsa"
47-
owner: "{{ jenkins_user }}"
48-
mode: 0600
43+
- name: generate new SSH key
44+
command: |-
45+
ssh-keygen -b 4096 -t rsa -f {{ jenkins_user_home }}/.ssh/id_rsa
46+
-N '' creates={{ jenkins_user_home }}/.ssh/id_rsa
47+
become: true
48+
become_user: "{{ jenkins_user }}"
4949
notify: generate public SSH key
5050

5151
- name: add ssh keys to authorized_keys for the jenkins user

cinch/roles/jenkins_master/defaults/main.yml

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ jenkins_backup: {}
8585
# cleanup_diffs: false
8686
# next_build_number: false
8787
# move_to_zip: false
88+
# The shell user on the master system whose SSH key is configured with admin access
89+
# on the Jenkins CLI. Also, the home directory for that user
90+
jenkins_cli_shell_user: "{{ jenkins_user }}"
91+
jenkins_cli_shell_user_home: "{{ jenkins_user_home }}"
8892

8993

9094
# ############################################################################

cinch/roles/jenkins_master/tasks/ensure_up.yml

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
- name: set listening port
1+
- name: check for running in a container
22
set_fact:
3-
_listening_port: "{{ https_enabled | ternary(443, 80) }}"
4-
when: ansible_connection != 'docker'
3+
_listening_port: "{{ https_enabled | ternary(8443, 8080) }}"
4+
when: ansible_connection == 'docker'
55
tags:
66
- jenkins_check_mode
77

8-
- name: check for running in a container
8+
- name: discover valid hostname
99
set_fact:
10-
_listening_port: "{{ https_enabled | ternary(8443, 8080) }}"
11-
when: ansible_connection == 'docker'
10+
_jenkins_host: "{{ ansible_host | default(inventory_hostname | default('localhost')) }}"
1211
tags:
1312
- jenkins_check_mode
1413

1514
- name: construct Jenkins URL
1615
set_fact:
17-
_jenkins_url: "http{{ https_enabled | ternary('s', '') }}://localhost:{{ _listening_port }}"
16+
_jenkins_url: "http{{ https_enabled | ternary('s', '') }}://{{ _jenkins_host }}"
17+
tags:
18+
- jenkins_check_mode
19+
20+
- name: modify Jenkins URL for non-standard ports
21+
set_fact:
22+
_jenkins_url: "{{ _jenkins_url }}:{{ _listening_port }}"
23+
when: _listening_port is defined
1824
tags:
1925
- jenkins_check_mode
2026

@@ -46,7 +52,7 @@
4652
remoting: "{{ jenkins_cli_remoting }}"
4753
register: jenkins_admin_api_key
4854
become: true
49-
become_user: "{{ jenkins_user }}"
55+
become_user: "{{ jenkins_cli_shell_user }}"
5056

5157
- name: save API key
5258
set_fact:

cinch/roles/jenkins_master/tasks/post_configure.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
jenkins_cli_user:
4848
jenkins_home: "{{ jenkins_home }}"
4949
jenkins_user: "{{ item }}"
50-
key_file: "{{ jenkins_user_home }}/.ssh/id_rsa.pub"
50+
key_file: "{{ jenkins_cli_shell_user_home }}/.ssh/id_rsa.pub"
5151
state: present
5252
become: true
5353
notify: restart Jenkins

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
setup(
1111
name='cinch',
12-
version='0.8.1',
12+
version='0.8.2',
1313
description='Cinch continuous integration setup',
1414
long_description=description,
1515
url='https://github.com/RedHatQE/cinch',

0 commit comments

Comments
 (0)