Skip to content

Commit

Permalink
Merge remote-tracking branch 'greg/issue176' into issue176
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-hellings committed Sep 25, 2017
2 parents a28eff7 + 4915f2c commit 2e4abab
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 30 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
v 0.8.4
v 0.8.4 (25 Sep 2017)
- Bump to linchpin 1.0.4 and Ansible >= 2.3.2 because of syntax errors (GH #176)
- Capture errors from jenkins-cli.jar more robustly (GH #151)
- Streamline installation of the Python pip module (GH #147)

v 0.8.3 (13 Sep 2017)
- Clean up TravisCI tests
Expand Down
3 changes: 0 additions & 3 deletions cinch/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ repository_defaults:
skip_if_unavailable: false
gpgcheck: false

# This is the default name of this package, but it's not the same on every
# system
python_pip_package: python2-pip
# Default user and directory to place the Jenkins files in
jenkins_user: jenkins
jenkins_user_home: /var/lib/jenkins
Expand Down
1 change: 1 addition & 0 deletions cinch/group_vars/cent6
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
gcc_compat_package: compat-gcc-34
python_pip_package: python-pip

_repositories:
- name: epel-testing
Expand Down
9 changes: 3 additions & 6 deletions cinch/group_vars/fedora
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@ repositories:
mirrorlist: "{{ fedora_mirrors }}repo=rawhide"

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

jenkins_master_repositories: []
jenkins_slave_repositories: []

jenkins_master_download_repositories: "{{ _download_repositories }}"
jenkins_slave_download_repositories: []

rpm_key_imports:
- key: http://pkg.jenkins-ci.org/redhat-stable/jenkins.io.key
validate_certs: true

python_pip_package: python-pip
version_pin_file: /etc/dnf/dnf.conf
python_pip_package: "{{ (ansible_distribution_major_version > 26) | ternary('python2-pip',
'python-pip') }}"
1 change: 1 addition & 0 deletions cinch/group_vars/rhel6
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
gcc_compat_package: compat-gcc-34
python_pip_package: python-pip

all_repositories:
latest:
Expand Down
42 changes: 31 additions & 11 deletions cinch/library/jenkins_user_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,40 @@ def main():
process = process_named_args + process_positional_args
# The groovy code simply prints out the value of the API key, so we want
# to be able to capture that output
err, output = None, None
p = subprocess.Popen(process,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
output, err = p.communicate()
os.unlink(groovy.name)
success = False
# It's possible the Popen process has an error code for a whole host of
# reasons
if p.returncode == 0:
success = True
module.exit_json(api_key=output.strip(),
err=err,
changed=False,
success=success)
try:
output, err = p.communicate()
os.unlink(groovy.name)
# It's possible the Popen process has an error code for a whole host of
# reasons
if p.returncode == 0:
module.exit_json(api_key=output.strip(),
err=err,
changed=False,
success=True)
else:
msg = "Error occurred while executing jenkins-cli.jar"
except subprocess.CalledProcessError:
msg = "Error received while attempting to execute Java"
# If err and output are some type of empty, but not the empty string,
# then we reached this point without any output. If they are the empty
# string, then we reached this point but the subprocess output nothing
# on the specified pipe. Providing this data, or a status message such
# as these defaults, provides a better way for users to diagnose the
# problems encountered
if not err and err != "":
err = "No stderr detected"
if not output and output != "":
output = "No stdout detected"
# There are lots of reasons to fall through to here. But if we have, then
# something has most definitely gone wrong. We should report on that
module.fail_json(msg=msg,
stderr=err,
stdout=output,
api_key='')


main()
2 changes: 2 additions & 0 deletions cinch/roles/jenkins_common/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ jenkins_authorized_keys: []
# A list of additional packages that you wish to install on both masters and
# slaves using the default package manager.
extra_rpms: []
# The name of the RPM that includes pip
python_pip_package: python2-pip
1 change: 1 addition & 0 deletions cinch/roles/jenkins_common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- gcc
- redhat-rpm-config
- git
- "{{ python_pip_package }}"
retries: 2
register: install_deps
until: install_deps|success
Expand Down
2 changes: 1 addition & 1 deletion cinch/roles/jenkins_master/tasks/firewalld.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- name: ensure firewalld is installed
package:
name: firewalld
name: firewalld,python-firewall
state: present
become: true

Expand Down
1 change: 0 additions & 1 deletion cinch/roles/jenkins_master/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
state: present
with_items:
- "{{ jenkins_rpm }}"
- "{{ python_pip_package }}"
- libvirt-devel
- python-virtualenv
- libyaml-devel
Expand Down
1 change: 0 additions & 1 deletion cinch/roles/jenkins_slave/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,5 @@ jenkins_slave_password: ''
# unless you really know what you're doing
jslave_rpm_deps:
- wget
- python-pip

jslave_extra_rpms: []
6 changes: 3 additions & 3 deletions vagrant/master_slave_fedora/Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require "../shared.rb"

Vagrant.configure("2") do |config|
vm(config, "master", "fedora/25-cloud-base")
vm(config, "slave", "fedora/25-cloud-base") do |ansible|
vm(config, "master", "fedora/26-cloud-base")
vm(config, "slave", "fedora/26-cloud-base") do |ansible|
ansible.groups = {
"jenkins_master" => ["master"],
"jenkins_slave" => ["slave"],
"fedora" => ["master", "slave"],
"repositories" => ["master"],
"jenkins_slave:vars" => {
"jenkins_master_url" => "http://{{ hostvars['master']['ansible_default_ipv4']['address'] }}:8080"
"jenkins_master_url" => "http://{{ hostvars['master']['ansible_default_ipv4']['address'] }}"
}
}
end
Expand Down
4 changes: 3 additions & 1 deletion vagrant/shared.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def get_image(base_box)
if base_box == 'centos/7'
return 'CentOS-7-x86_64-GenericCloud-released-latest'
elsif base_box == 'centos/6'
return 'CentOS-6-x86_64-GenericCloud-released-latest'
return 'CentOS-6-x86_64-GenericCloud-1612'
elsif base_box == 'fedora/26-cloud-base'
return 'Fedora-Cloud-Base-26-compose-latest'
elsif base_box == 'fedora/25-cloud-base'
return 'Fedora-Cloud-Base-25-compose-latest'
elsif base_box == 'fedora/24-cloud-base'
Expand Down
2 changes: 1 addition & 1 deletion vagrant/slave/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Vagrant.configure("2") do |config|
"cent7" => ["master", "slave"],
"repositories" => ["master", "slave"],
"jenkins_slave:vars" => {
"jenkins_master_url" => "http://{{ hostvars['master']['ansible_default_ipv4']['address'] }}:8080",
"jenkins_master_url" => "http://{{ hostvars['master']['ansible_default_ipv4']['address'] }}",
"jenkins_user_password" => "vagrant",
"jenkins_user" => "jenkins",
"jenkins_user_home" => "/var/lib/jenkins"
Expand Down
2 changes: 1 addition & 1 deletion vagrant/slave_cent6/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Vagrant.configure("2") do |config|
"cent6" => ["slave"],
"repositories" => ["master", "slave"],
"jenkins_slave:vars" => {
"jenkins_master_url" => "http://192.168.8.2:8080",
"jenkins_master_url" => "http://{{ hostvars['master']['ansible_default_ipv4']['address'] }}",
"jenkins_user_password" => "vagrant",
"jenkins_user" => "jenkins",
"jenkins_user_home" => "/var/lib/jenkins"
Expand Down

0 comments on commit 2e4abab

Please sign in to comment.