From 36359846b02ed165a6ec3af915e43c9a51cf7e72 Mon Sep 17 00:00:00 2001 From: Gregory Hellings Date: Wed, 13 Sep 2017 21:39:53 -0500 Subject: [PATCH 01/10] Fix master URL in vagrant --- vagrant/slave/Vagrantfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vagrant/slave/Vagrantfile b/vagrant/slave/Vagrantfile index 83d3485..8357371 100644 --- a/vagrant/slave/Vagrantfile +++ b/vagrant/slave/Vagrantfile @@ -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" From 81dc9ffeae73cbccd03e2ee823828a1ee85ad818 Mon Sep 17 00:00:00 2001 From: Gregory Hellings Date: Fri, 15 Sep 2017 22:03:37 -0500 Subject: [PATCH 02/10] Update Vagrant for Fedora and others Updates the variables used for Fedora and for testing --- vagrant/master_slave_fedora/Vagrantfile | 6 +++--- vagrant/shared.rb | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/vagrant/master_slave_fedora/Vagrantfile b/vagrant/master_slave_fedora/Vagrantfile index 108b4e5..c0a2dc6 100644 --- a/vagrant/master_slave_fedora/Vagrantfile +++ b/vagrant/master_slave_fedora/Vagrantfile @@ -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 diff --git a/vagrant/shared.rb b/vagrant/shared.rb index 30960aa..ae670b6 100644 --- a/vagrant/shared.rb +++ b/vagrant/shared.rb @@ -16,6 +16,8 @@ def get_image(base_box) return 'CentOS-7-x86_64-GenericCloud-released-latest' elsif base_box == 'centos/6' return 'CentOS-6-x86_64-GenericCloud-released-latest' + 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' From 7c5e257a41d80aaad507cb18edb62ce846cb91a7 Mon Sep 17 00:00:00 2001 From: Gregory Hellings Date: Fri, 15 Sep 2017 22:09:13 -0500 Subject: [PATCH 03/10] Clean up python-pip Python pip is common to both Jenkins masters and slaves. Making it common to both should be straightforward here. However, it is named python2-pip in both EPEL7 and Fedora >= 26. But in Fedora 25, which is technically still in support it is named python-pip, instead. So, we need to support that. --- cinch/group_vars/all | 3 --- cinch/group_vars/fedora | 9 +++------ cinch/roles/jenkins_common/defaults/main.yml | 2 ++ cinch/roles/jenkins_common/tasks/main.yml | 1 + cinch/roles/jenkins_master/tasks/install.yml | 1 - cinch/roles/jenkins_slave/defaults/main.yml | 1 - 6 files changed, 6 insertions(+), 11 deletions(-) diff --git a/cinch/group_vars/all b/cinch/group_vars/all index d799c82..60eeed1 100644 --- a/cinch/group_vars/all +++ b/cinch/group_vars/all @@ -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 diff --git a/cinch/group_vars/fedora b/cinch/group_vars/fedora index 4812b15..d3efb4b 100644 --- a/cinch/group_vars/fedora +++ b/cinch/group_vars/fedora @@ -3,7 +3,7 @@ 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: [] @@ -11,9 +11,6 @@ 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') }}" diff --git a/cinch/roles/jenkins_common/defaults/main.yml b/cinch/roles/jenkins_common/defaults/main.yml index c15f816..f5ee763 100644 --- a/cinch/roles/jenkins_common/defaults/main.yml +++ b/cinch/roles/jenkins_common/defaults/main.yml @@ -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 diff --git a/cinch/roles/jenkins_common/tasks/main.yml b/cinch/roles/jenkins_common/tasks/main.yml index bf3cb7c..3cc372d 100644 --- a/cinch/roles/jenkins_common/tasks/main.yml +++ b/cinch/roles/jenkins_common/tasks/main.yml @@ -15,6 +15,7 @@ - gcc - redhat-rpm-config - git + - "{{ python_pip_package }}" retries: 2 register: install_deps until: install_deps|success diff --git a/cinch/roles/jenkins_master/tasks/install.yml b/cinch/roles/jenkins_master/tasks/install.yml index a908f3f..23e9242 100644 --- a/cinch/roles/jenkins_master/tasks/install.yml +++ b/cinch/roles/jenkins_master/tasks/install.yml @@ -12,7 +12,6 @@ state: present with_items: - "{{ jenkins_rpm }}" - - "{{ python_pip_package }}" - libvirt-devel - python-virtualenv - libyaml-devel diff --git a/cinch/roles/jenkins_slave/defaults/main.yml b/cinch/roles/jenkins_slave/defaults/main.yml index 98cf0e5..bee8042 100644 --- a/cinch/roles/jenkins_slave/defaults/main.yml +++ b/cinch/roles/jenkins_slave/defaults/main.yml @@ -32,6 +32,5 @@ jenkins_slave_password: '' # unless you really know what you're doing jslave_rpm_deps: - wget - - python-pip jslave_extra_rpms: [] From 5dc51c3b8e3676a66ce62ec60cbd56698668baab Mon Sep 17 00:00:00 2001 From: Gregory Hellings Date: Fri, 15 Sep 2017 22:10:36 -0500 Subject: [PATCH 04/10] Add python firewalld bindings firewalld bindings are not installed by default on Fedora hosts. Ensure that they are installed so that the playbooks can succeed on those targets --- cinch/roles/jenkins_master/tasks/firewalld.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cinch/roles/jenkins_master/tasks/firewalld.yml b/cinch/roles/jenkins_master/tasks/firewalld.yml index 0c7ce5f..8f42add 100644 --- a/cinch/roles/jenkins_master/tasks/firewalld.yml +++ b/cinch/roles/jenkins_master/tasks/firewalld.yml @@ -1,6 +1,6 @@ - name: ensure firewalld is installed package: - name: firewalld + name: firewalld,python-firewall state: present become: true From 519de770b7609bdea51b364b2b127e0f71426a6a Mon Sep 17 00:00:00 2001 From: Gregory Hellings Date: Fri, 15 Sep 2017 22:20:13 -0500 Subject: [PATCH 05/10] Add python-pip support to Cent/RHEL6 --- cinch/group_vars/cent6 | 1 + cinch/group_vars/rhel6 | 1 + vagrant/shared.rb | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cinch/group_vars/cent6 b/cinch/group_vars/cent6 index 06237d6..a920fda 100644 --- a/cinch/group_vars/cent6 +++ b/cinch/group_vars/cent6 @@ -1,4 +1,5 @@ gcc_compat_package: compat-gcc-34 +python_pip_package: python-pip _repositories: - name: epel-testing diff --git a/cinch/group_vars/rhel6 b/cinch/group_vars/rhel6 index 688202c..ba0065d 100644 --- a/cinch/group_vars/rhel6 +++ b/cinch/group_vars/rhel6 @@ -1,4 +1,5 @@ gcc_compat_package: compat-gcc-34 +python_pip_package: python-pip all_repositories: latest: diff --git a/vagrant/shared.rb b/vagrant/shared.rb index ae670b6..b677474 100644 --- a/vagrant/shared.rb +++ b/vagrant/shared.rb @@ -15,7 +15,7 @@ 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' From 3cea55731c20edd1da919b9f9c7669ec968e466e Mon Sep 17 00:00:00 2001 From: Gregory Hellings Date: Fri, 15 Sep 2017 22:44:17 -0500 Subject: [PATCH 06/10] Update CentOS 6 based master URL in Vagrant --- vagrant/slave_cent6/Vagrantfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vagrant/slave_cent6/Vagrantfile b/vagrant/slave_cent6/Vagrantfile index 19a4cca..d7e2951 100644 --- a/vagrant/slave_cent6/Vagrantfile +++ b/vagrant/slave_cent6/Vagrantfile @@ -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" From c5274259116051cde706d86f539a747d842c5c2f Mon Sep 17 00:00:00 2001 From: Gregory Hellings Date: Fri, 15 Sep 2017 22:46:54 -0500 Subject: [PATCH 07/10] Add changes for 0.8.4 cycle --- CHANGELOG | 3 +++ setup.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index df2a988..7424ffe 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +v 0.8.4 +- Streamline installation of the Python pip module + v 0.8.3 (13 Sep 2017) - Clean up TravisCI tests - Clean up Docker UID variable for OpenShift support diff --git a/setup.py b/setup.py index ca29ffc..80aa0d0 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setup( name='cinch', - version='0.8.3', + version='0.8.4', description='Cinch continuous integration setup', long_description=description, url='https://github.com/RedHatQE/cinch', From 9007ef572d58a537018aa46f22f6a6b69fd4bcf7 Mon Sep 17 00:00:00 2001 From: Gregory Hellings Date: Fri, 15 Sep 2017 22:54:51 -0500 Subject: [PATCH 08/10] Add GH issue to CHANGELOG --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 7424ffe..872e07c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,5 @@ v 0.8.4 -- Streamline installation of the Python pip module +- Streamline installation of the Python pip module (GH #147) v 0.8.3 (13 Sep 2017) - Clean up TravisCI tests From 28e18591dfc48f68af048da20c4528536e779c56 Mon Sep 17 00:00:00 2001 From: Gregory Hellings Date: Fri, 15 Sep 2017 23:57:39 -0500 Subject: [PATCH 09/10] Make jenkins_user_api.py more robust The jenkins_user_api module was not properly capturing errors and incorrect exit codes when the module was being executed improperly. Now, more of those cases should be handled properly and trigger an error state in Ansible. Fixes: #151 --- CHANGELOG | 3 +++ cinch/library/jenkins_user_api.py | 37 ++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index df2a988..e16f8c6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +v 0.8.4 + - Capture errors from jenkins-cli.jar more robustly (GH #151) + v 0.8.3 (13 Sep 2017) - Clean up TravisCI tests - Clean up Docker UID variable for OpenShift support diff --git a/cinch/library/jenkins_user_api.py b/cinch/library/jenkins_user_api.py index 4d7e0f1..b973042 100644 --- a/cinch/library/jenkins_user_api.py +++ b/cinch/library/jenkins_user_api.py @@ -60,20 +60,35 @@ 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 + 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() From 09bc47a40401dbb45f845a726fc607eb0eec141a Mon Sep 17 00:00:00 2001 From: Gregory Hellings Date: Thu, 21 Sep 2017 08:09:42 -0500 Subject: [PATCH 10/10] More verbose comments on finding error message --- cinch/library/jenkins_user_api.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cinch/library/jenkins_user_api.py b/cinch/library/jenkins_user_api.py index b973042..6acd393 100644 --- a/cinch/library/jenkins_user_api.py +++ b/cinch/library/jenkins_user_api.py @@ -78,7 +78,12 @@ def main(): 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 + # 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 != "":