From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07BF61865FA for ; Mon, 28 Jul 2025 01:14:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753665281; cv=none; b=iiZVfL6UPVtH0VYzUP0KL9FN5kKfiwn5NxOQ47QvUNqT0FhiWj4BWdesheIKzTAJSNZQ4B4I6GRHwJ+hte/UrM98ISE6wwCw0NihZGMJn+C0nvlT2r/NPe1un7cKNjfceUNQ8od/QbVNWZhOoB1jRkPQ5zN9W1Ut73zXWMj63Lo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753665281; c=relaxed/simple; bh=eqhplgKpQxY39DFe8d2gD8YBxnB74SOTNfQ/k7e7ut4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jIVynoKlknBWRoMcGyd3035dK2oeHjYxvO2V7jeai3AE4v1PA9D6l9b6WawM5CmlNUEQndFspuT5byFS4MpWruOvV9NxnrHc89qgXoHdvhgsPZmcF7m7Z87xc142lF6mQ6+hfCkJtLH560F8pk2bwjG2+f9gCgOR6N7WScl19B8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=y/QQOoBO; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="y/QQOoBO" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=WtyqUc7BK//BNHbfqXUpLrb6nHkIUFFjyJK+frE1XHE=; b=y/QQOoBOUkTQAfx6bXrnZ3Gohm S4WRJdu/b5kQCqnQsFpghTOcvd5PcD0xQuirn41bcRzNx5Z7MtwvKYbkJBVRZnhkE9+ILAswSHBCG x8BgJ2lIQxBeNCaqQqC6lqcOzucU77bVViX3J1/7lqHBZ+wSeKiSnPnTRmYqS+PQMXKQL2nyWBp97 Z0hkJQrGtvQbjbeahm3ixvieO01XrnOtdVXFC7wTMnAyuFXgz3EMcyQClHCnZ0E8CRyZFbHVskZiA HX87Xr2Q6xV82PXi6vB3qN70SIu7wY+ez2wJ3BPjusib1yv/JitC0tUBNandMehsq1oW66mOfqJS/ N6sAQuNw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98.2 #2 (Red Hat Linux)) id 1ugCRo-0000000DPk6-0Tfh; Mon, 28 Jul 2025 01:14:36 +0000 From: Luis Chamberlain To: Chuck Lever , Daniel Gomez , kdevops@lists.linux.dev Cc: Chuck Lever Subject: [PATCH v2 17/33] bootlinux: Simplify tasks that select the kernel .config to build Date: Sun, 27 Jul 2025 18:14:17 -0700 Message-ID: <20250728011434.3197091-18-mcgrof@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250728011434.3197091-1-mcgrof@kernel.org> References: <20250728011434.3197091-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain From: Chuck Lever Simplify/modernize the selection tasks by using convenience functions that are built into Ansible. I'm hoping this makes the tasks easier to read, easier to maintain, and faster. Signed-off-by: Chuck Lever --- playbooks/roles/bootlinux/tasks/config.yml | 109 ++++++--------------- 1 file changed, 29 insertions(+), 80 deletions(-) diff --git a/playbooks/roles/bootlinux/tasks/config.yml b/playbooks/roles/bootlinux/tasks/config.yml index 5cf03e7f..c1ecbaed 100644 --- a/playbooks/roles/bootlinux/tasks/config.yml +++ b/playbooks/roles/bootlinux/tasks/config.yml @@ -1,89 +1,38 @@ --- -- name: Check whether config-kdevops exists - stat: - path: "{{ role_path }}/templates/config-kdevops" - register: config_kdevops - delegate_to: localhost - -- name: Found config-kdevops, using it for template - set_fact: - linux_config: "config-kdevops" - when: config_kdevops.stat.exists - -- name: No config-kdevops, looking for {{ target_linux_config }} - set_fact: - linux_config: "{{ target_linux_config }}" - when: not config_kdevops.stat.exists +- name: Initialize the kernel config file names search list + ansible.builtin.set_fact: + search_list: + - "{{ role_path }}/templates/config-kdevops" + - "{{ role_path }}/templates/{{ target_linux_config }}" -- name: Check if specific kernel config exists for {{ target_linux_ref }} - stat: - path: "{{ role_path }}/templates/{{ target_linux_config }}" - register: kernel_config +- name: Find all linux-next kernel config files delegate_to: localhost - -- name: Find all linux-next configs if a your custom config-kdevops and ref config was not found - find: + run_once: true + ansible.builtin.find: paths: "{{ role_path }}/templates" - patterns: "config-next*" + patterns: "config-next-*" file_type: file - recurse: no - register: found_configs - delegate_to: localhost - when: - - not config_kdevops.stat.exists - - not kernel_config.stat.exists - -- name: Extract the date from the filenames - set_fact: - configs_with_dates: "{{ configs_with_dates | default([]) + [{'file': item.path, 'date': (item.path | regex_search('config-next-(\\d{8})')).split('-')[-1]}] }}" - loop: "{{ found_configs.files }}" - when: - - not config_kdevops.stat.exists - - not kernel_config.stat.exists - - item.path is search('config-next-(\\d{8})') - no_log: true - delegate_to: localhost - -- name: Sort configs based on date extracted from filename - set_fact: - sorted_configs: "{{ configs_with_dates | selectattr('date', 'defined') | sort(attribute='date', reverse=True) | map(attribute='file') | list }}" + register: linux_next_configs + +- name: Build a list of linux-next kernel config file names + ansible.builtin.set_fact: + config_file_names: "{{ config_file_names | default([]) + [item.path] }}" + loop: "{{ linux_next_configs.files }}" + loop_control: + label: "Adding {{ item.path | basename }}..." when: - - not config_kdevops.stat.exists - - not kernel_config.stat.exists - - configs_with_dates | length > 0 - delegate_to: localhost + - linux_next_configs.matched > 0 -- name: Set latest linux-next config if configs are found - set_fact: - latest_linux_next_config: "{{ sorted_configs[0] }}" +- name: Append the name of the most recent linux-next kernel config to the search list + vars: + config_file_names_sorted: "{{ config_file_names | community.general.version_sort }}" + ansible.builtin.set_fact: + search_list: "{{ search_list + [config_file_names_sorted[-1]] }}" when: - - not config_kdevops.stat.exists and not kernel_config.stat.exists - - sorted_configs | length > 0 - delegate_to: localhost - -- name: Use the specific kernel config or fallback to the latest linux-next - set_fact: - linux_config: "{{ target_linux_config | default('') if kernel_config.stat.exists else (latest_linux_next_config | default('') | basename) }}" - when: - - not config_kdevops.stat.exists - - not kernel_config.stat.exists - - latest_linux_next_config is defined - delegate_to: localhost + - linux_next_configs.matched > 0 -- name: Verify config used - debug: - msg: "Linux config used: {{ role_path }}/templates/{{ linux_config }}" - delegate_to: localhost - -- name: Verify that the Linux configuration file exists - stat: - path: "{{ role_path }}/templates/{{ linux_config }}" - register: config_stat - delegate_to: localhost - when: linux_config is defined - -- name: Fail if the configuration file does not exist - fail: - msg: "The configuration file {{ role_path }}/templates/{{ linux_config }} does not exist." - when: not config_stat.stat.exists - delegate_to: localhost +- name: Set the .config file for building the test kernel + ansible.builtin.set_fact: + linux_config: "{{ item | basename }}" + with_first_found: + - files: "{{ search_list }}" -- 2.47.2