From 6e9d557368c1c1a2cffa4ef84349d7ebbdc848b9 Mon Sep 17 00:00:00 2001 From: Tobias Richter Date: Thu, 4 Aug 2022 17:40:47 +0200 Subject: [PATCH 1/3] Raise plugin- and/or role versions --- defaults/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 1240134..cf87ee2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -48,13 +48,13 @@ jenkins_casc_no_log: true # Plugins needed for configuration-as-code jenkins_casc_plugins_present: - name: configuration-as-code - version: "1414.v878271fc496f" + version: "1512.vb_79d418d5fc8" - name: configuration-as-code-groovy version: "1.1" - name: snakeyaml-api - version: "1.29.1" + version: "1.30.2-76.vc104f7ce9870" - name: job-dsl - version: "1.78.3" + version: "1.81" # Plugins no longer needed for configuration-as-code jenkins_casc_plugins_absent: From 5cfa83dd1f5a12a139d12617581d5c6bea5a0ab3 Mon Sep 17 00:00:00 2001 From: Tobias Richter Date: Tue, 9 Aug 2022 16:08:27 +0200 Subject: [PATCH 2/3] Fix ansible-lint issues --- defaults/main.yml | 5 +++-- meta/main.yml | 2 +- tasks/configure.yml | 8 ++++---- tasks/main.yml | 2 +- tasks/reload.yml | 4 ++-- tasks/secrets.yml | 14 +++++++------- tasks/upload.yml | 12 ++++++------ 7 files changed, 24 insertions(+), 23 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index cf87ee2..9152ff8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -35,8 +35,9 @@ jenkins_casc_config_path_configure: false # Config files/templates to upload jenkins_casc_config_fileglobs: [] -# Controls if files that existing files in the 'jenkins_casc_config_path' are deleted when they are not included in the 'jenkins_casc_config_fileglobs' -# Deletion will only be executed when at least one file was uploaded to the 'jenkins_casc_config_path' +# Controls if files that existing files in the 'jenkins_casc_config_path' are deleted +# when they are not included in the 'jenkins_casc_config_fileglobs'. Deletion will only +# be executed when at least one file was uploaded to the 'jenkins_casc_config_path' jenkins_casc_config_unmanaged_delete: false # The timeout for jenkins_script tasks in seconds diff --git a/meta/main.yml b/meta/main.yml index 6e80e48..096c8df 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -7,7 +7,7 @@ galaxy_info: company: pro!vision issue_tracker_url: https://wcm-io.atlassian.net license: Apache - min_ansible_version: 2.7 + min_ansible_version: "2.7" platforms: - name: EL diff --git a/tasks/configure.yml b/tasks/configure.yml index a004a3e..51a97cc 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -1,11 +1,11 @@ --- - name: "configure : check if '{{ jenkins_casc_config_path }}' exists." - stat: + ansible.builtin.stat: path: "{{ jenkins_casc_config_path }}" register: jenkins_casc_config_path_result - name: "Fail when '{{ jenkins_casc_config_path }}' does not exist." - fail: + ansible.builtin.fail: msg: >- No file or directory found with path '{{ jenkins_casc_config_path }}'. Ensure that the configuration is on the instance before calling this role." @@ -26,12 +26,12 @@ | regex_replace('\\s*Result:\\s*(.*)\\n*$', '\\1') | from_json).changed - name: "configure : set _jenkins_casc_plugin_configure_result fact." - set_fact: + ansible.builtin.set_fact: _jenkins_casc_plugin_configure_result: "{{ (_jenkins_casc_plugin_configure_result.output | regex_replace('\\s*Result:\\s*(.*)\\n*$', '\\1') | from_json) }}" - name: "configure : fail when configuration throws exception." - fail: + ansible.builtin.fail: msg: - Exception thrown during applying of configuration, check your configuration! - "{{ _jenkins_casc_plugin_configure_result.msg }}" diff --git a/tasks/main.yml b/tasks/main.yml index 068fb3d..9f46699 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -14,7 +14,7 @@ when: jenkins_casc_config_path_configure - name: "trigger reload handler when necessary." - command: /bin/true + ansible.builtin.command: /bin/true changed_when: true when: # only trigger when configure result is false, since this will do a implicit reload diff --git a/tasks/reload.yml b/tasks/reload.yml index 0af95b2..563b8ee 100644 --- a/tasks/reload.yml +++ b/tasks/reload.yml @@ -13,12 +13,12 @@ - jcasc-reload - name: "reload : set _jenkins_casc_upload_files_result fact." - set_fact: + ansible.builtin.set_fact: _jenkins_casc_upload_files_result: "{{ (_jenkins_casc_upload_files_result.output | regex_replace('\\s*Result:\\s*(.*)\\n*$', '\\1') | from_json) }}" - name: "reload : fail when configuration throws exception." - fail: + ansible.builtin.fail: msg: - Exception thrown during applying of configuration, check your configuration! - "{{ _jenkins_casc_upload_files_result.msg }}" diff --git a/tasks/secrets.yml b/tasks/secrets.yml index 09a937c..a8e0c40 100644 --- a/tasks/secrets.yml +++ b/tasks/secrets.yml @@ -1,18 +1,18 @@ --- - name: "secrets : get user home dir." become: yes - getent: + ansible.builtin.getent: database: passwd key: "{{ jenkins_casc_owner }}" split: ":" - name: "secrets : set user home dir." - set_fact: + ansible.builtin.set_fact: _secrets_home_dir: "{{ getent_passwd[jenkins_casc_owner][4] }}" failed_when: _secrets_home_dir | length == 0 - name: "secrets : create secrets dir." - file: + ansible.builtin.file: path: "{{ jenkins_casc_secrets_dir }}" state: directory owner: "{{ jenkins_casc_owner }}" @@ -20,7 +20,7 @@ mode: 0700 - name: "secrets : deploy secret." - copy: + ansible.builtin.copy: dest: "{{ jenkins_casc_secrets_dir }}/{{ secret.id }}" content: "{{ secret.value }}" owner: "{{ jenkins_casc_owner }}" @@ -34,12 +34,12 @@ - name: "secrets : unmanaged." block: - name: "secrets : unmanaged : find files in {{ jenkins_casc_secrets_dir }}." - find: + ansible.builtin.find: paths: "{{ jenkins_casc_secrets_dir }}" register: _jenkins_casc_secrets_existing_files - name: "secrets : unmanaged : delete unmanaged secrets." - file: + ansible.builtin.file: path: "{{ jenkins_casc_secrets_dir }}/{{ item }}" state: absent with_items: "{{ _jenkins_casc_secrets_existing_files.files | map(attribute='path') | map('basename') | list @@ -48,7 +48,7 @@ when: jenkins_casc_secrets_unmanaged_delete - name: "secrets : configure secrets env var." - blockinfile: + ansible.builtin.blockinfile: dest: "{{ _secrets_home_dir }}/.profile" create: yes owner: "{{ jenkins_casc_owner }}" diff --git a/tasks/upload.yml b/tasks/upload.yml index 612c2f5..8a02a98 100644 --- a/tasks/upload.yml +++ b/tasks/upload.yml @@ -1,11 +1,11 @@ --- - name: "upload : calculate files to upload order to check that no files exist with overlapping names." - set_fact: + ansible.builtin.set_fact: _jenkins_casc_found_config_files: "{{ _jenkins_casc_found_config_files | default([]) + [item] }}" with_fileglob: "{{ jenkins_casc_config_fileglobs }}" - name: "upload : fail on overlapping file names." - fail: + ansible.builtin.fail: msg: - "Found duplicate file(s) to deploy!" - "Please ensure that the filenames are unique, otherwise unexpected result may occur!" @@ -15,7 +15,7 @@ _jenkins_casc_found_config_files | default({}) | map('basename') | list | unique - name: "upload : create configuration dir." - file: + ansible.builtin.file: path: "{{ jenkins_casc_config_path }}" state: directory owner: "{{ jenkins_casc_owner }}" @@ -23,7 +23,7 @@ mode: 0770 - name: "upload : upload files/templates." - template: + ansible.builtin.template: src: "{{ item }}" owner: "{{ jenkins_casc_owner }}" group: "{{ jenkins_casc_group }}" @@ -35,12 +35,12 @@ - name: "upload : unmanaged." block: - name: "upload : unmanaged : find files in {{ jenkins_casc_config_path }}." - find: + ansible.builtin.find: paths: "{{ jenkins_casc_config_path }}" register: _jenkins_casc_config_existing_files - name: "upload : unmanaged : delete unmanaged files." - file: + ansible.builtin.file: path: "{{ item }}" state: absent # build list of uploaded and found file paths and delete the difference From a7d6dc540a8fc6b0e195e36bb068525c60b3c7bd Mon Sep 17 00:00:00 2001 From: Tobias Richter Date: Tue, 9 Aug 2022 16:16:36 +0200 Subject: [PATCH 3/3] Fix ansible-lint issues --- tasks/main.yml | 6 +++--- tasks/secrets.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 9f46699..1398802 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,14 +1,14 @@ --- -- include_tasks: secrets.yml +- ansible.builtin.include_tasks: secrets.yml tags: - jcasc-secrets when: jenkins_casc_secrets | length > 0 -- include_tasks: upload.yml +- ansible.builtin.include_tasks: upload.yml tags: - jcasc-upload -- include_tasks: configure.yml +- ansible.builtin.include_tasks: configure.yml tags: - jcasc-configure when: jenkins_casc_config_path_configure diff --git a/tasks/secrets.yml b/tasks/secrets.yml index a8e0c40..e162e2d 100644 --- a/tasks/secrets.yml +++ b/tasks/secrets.yml @@ -60,7 +60,7 @@ register: _profile_result - name: Restart Jenkins when required. # noqa 503 - include_role: + ansible.builtin.include_role: name: wcm_io_devops.jenkins_service vars: jenkins_service_state: "restarted"