Skip to content

Commit 2e4abab

Browse files
committed
Merge remote-tracking branch 'greg/issue176' into issue176
2 parents a28eff7 + 4915f2c commit 2e4abab

File tree

15 files changed

+51
-30
lines changed

15 files changed

+51
-30
lines changed

CHANGELOG

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
v 0.8.4
1+
v 0.8.4 (25 Sep 2017)
22
- Bump to linchpin 1.0.4 and Ansible >= 2.3.2 because of syntax errors (GH #176)
3+
- Capture errors from jenkins-cli.jar more robustly (GH #151)
4+
- Streamline installation of the Python pip module (GH #147)
35

46
v 0.8.3 (13 Sep 2017)
57
- Clean up TravisCI tests

cinch/group_vars/all

-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ repository_defaults:
99
skip_if_unavailable: false
1010
gpgcheck: false
1111

12-
# This is the default name of this package, but it's not the same on every
13-
# system
14-
python_pip_package: python2-pip
1512
# Default user and directory to place the Jenkins files in
1613
jenkins_user: jenkins
1714
jenkins_user_home: /var/lib/jenkins

cinch/group_vars/cent6

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
gcc_compat_package: compat-gcc-34
2+
python_pip_package: python-pip
23

34
_repositories:
45
- name: epel-testing

cinch/group_vars/fedora

+3-6
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,14 @@ repositories:
33
mirrorlist: "{{ fedora_mirrors }}repo=rawhide"
44

55
_download_repositories:
6-
- http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
6+
- https://fedorapeople.org/~semyers/jenkins-rpm/jenkins1651.repo
77

88
jenkins_master_repositories: []
99
jenkins_slave_repositories: []
1010

1111
jenkins_master_download_repositories: "{{ _download_repositories }}"
1212
jenkins_slave_download_repositories: []
1313

14-
rpm_key_imports:
15-
- key: http://pkg.jenkins-ci.org/redhat-stable/jenkins.io.key
16-
validate_certs: true
17-
18-
python_pip_package: python-pip
1914
version_pin_file: /etc/dnf/dnf.conf
15+
python_pip_package: "{{ (ansible_distribution_major_version > 26) | ternary('python2-pip',
16+
'python-pip') }}"

cinch/group_vars/rhel6

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
gcc_compat_package: compat-gcc-34
2+
python_pip_package: python-pip
23

34
all_repositories:
45
latest:

cinch/library/jenkins_user_api.py

+31-11
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,40 @@ def main():
6060
process = process_named_args + process_positional_args
6161
# The groovy code simply prints out the value of the API key, so we want
6262
# to be able to capture that output
63+
err, output = None, None
6364
p = subprocess.Popen(process,
6465
stdout=subprocess.PIPE,
6566
stderr=subprocess.PIPE)
66-
output, err = p.communicate()
67-
os.unlink(groovy.name)
68-
success = False
69-
# It's possible the Popen process has an error code for a whole host of
70-
# reasons
71-
if p.returncode == 0:
72-
success = True
73-
module.exit_json(api_key=output.strip(),
74-
err=err,
75-
changed=False,
76-
success=success)
67+
try:
68+
output, err = p.communicate()
69+
os.unlink(groovy.name)
70+
# It's possible the Popen process has an error code for a whole host of
71+
# reasons
72+
if p.returncode == 0:
73+
module.exit_json(api_key=output.strip(),
74+
err=err,
75+
changed=False,
76+
success=True)
77+
else:
78+
msg = "Error occurred while executing jenkins-cli.jar"
79+
except subprocess.CalledProcessError:
80+
msg = "Error received while attempting to execute Java"
81+
# If err and output are some type of empty, but not the empty string,
82+
# then we reached this point without any output. If they are the empty
83+
# string, then we reached this point but the subprocess output nothing
84+
# on the specified pipe. Providing this data, or a status message such
85+
# as these defaults, provides a better way for users to diagnose the
86+
# problems encountered
87+
if not err and err != "":
88+
err = "No stderr detected"
89+
if not output and output != "":
90+
output = "No stdout detected"
91+
# There are lots of reasons to fall through to here. But if we have, then
92+
# something has most definitely gone wrong. We should report on that
93+
module.fail_json(msg=msg,
94+
stderr=err,
95+
stdout=output,
96+
api_key='')
7797

7898

7999
main()

cinch/roles/jenkins_common/defaults/main.yml

+2
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ jenkins_authorized_keys: []
1515
# A list of additional packages that you wish to install on both masters and
1616
# slaves using the default package manager.
1717
extra_rpms: []
18+
# The name of the RPM that includes pip
19+
python_pip_package: python2-pip

cinch/roles/jenkins_common/tasks/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- gcc
1616
- redhat-rpm-config
1717
- git
18+
- "{{ python_pip_package }}"
1819
retries: 2
1920
register: install_deps
2021
until: install_deps|success

cinch/roles/jenkins_master/tasks/firewalld.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
- name: ensure firewalld is installed
22
package:
3-
name: firewalld
3+
name: firewalld,python-firewall
44
state: present
55
become: true
66

cinch/roles/jenkins_master/tasks/install.yml

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
state: present
1313
with_items:
1414
- "{{ jenkins_rpm }}"
15-
- "{{ python_pip_package }}"
1615
- libvirt-devel
1716
- python-virtualenv
1817
- libyaml-devel

cinch/roles/jenkins_slave/defaults/main.yml

-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,5 @@ jenkins_slave_password: ''
3232
# unless you really know what you're doing
3333
jslave_rpm_deps:
3434
- wget
35-
- python-pip
3635

3736
jslave_extra_rpms: []

vagrant/master_slave_fedora/Vagrantfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
require "../shared.rb"
22

33
Vagrant.configure("2") do |config|
4-
vm(config, "master", "fedora/25-cloud-base")
5-
vm(config, "slave", "fedora/25-cloud-base") do |ansible|
4+
vm(config, "master", "fedora/26-cloud-base")
5+
vm(config, "slave", "fedora/26-cloud-base") do |ansible|
66
ansible.groups = {
77
"jenkins_master" => ["master"],
88
"jenkins_slave" => ["slave"],
99
"fedora" => ["master", "slave"],
1010
"repositories" => ["master"],
1111
"jenkins_slave:vars" => {
12-
"jenkins_master_url" => "http://{{ hostvars['master']['ansible_default_ipv4']['address'] }}:8080"
12+
"jenkins_master_url" => "http://{{ hostvars['master']['ansible_default_ipv4']['address'] }}"
1313
}
1414
}
1515
end

vagrant/shared.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ def get_image(base_box)
1515
if base_box == 'centos/7'
1616
return 'CentOS-7-x86_64-GenericCloud-released-latest'
1717
elsif base_box == 'centos/6'
18-
return 'CentOS-6-x86_64-GenericCloud-released-latest'
18+
return 'CentOS-6-x86_64-GenericCloud-1612'
19+
elsif base_box == 'fedora/26-cloud-base'
20+
return 'Fedora-Cloud-Base-26-compose-latest'
1921
elsif base_box == 'fedora/25-cloud-base'
2022
return 'Fedora-Cloud-Base-25-compose-latest'
2123
elsif base_box == 'fedora/24-cloud-base'

vagrant/slave/Vagrantfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Vagrant.configure("2") do |config|
1212
"cent7" => ["master", "slave"],
1313
"repositories" => ["master", "slave"],
1414
"jenkins_slave:vars" => {
15-
"jenkins_master_url" => "http://{{ hostvars['master']['ansible_default_ipv4']['address'] }}:8080",
15+
"jenkins_master_url" => "http://{{ hostvars['master']['ansible_default_ipv4']['address'] }}",
1616
"jenkins_user_password" => "vagrant",
1717
"jenkins_user" => "jenkins",
1818
"jenkins_user_home" => "/var/lib/jenkins"

vagrant/slave_cent6/Vagrantfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Vagrant.configure("2") do |config|
1010
"cent6" => ["slave"],
1111
"repositories" => ["master", "slave"],
1212
"jenkins_slave:vars" => {
13-
"jenkins_master_url" => "http://192.168.8.2:8080",
13+
"jenkins_master_url" => "http://{{ hostvars['master']['ansible_default_ipv4']['address'] }}",
1414
"jenkins_user_password" => "vagrant",
1515
"jenkins_user" => "jenkins",
1616
"jenkins_user_home" => "/var/lib/jenkins"

0 commit comments

Comments
 (0)