From 6a33c8595912d9b933d088129e7479cb4b25a564 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Tue, 3 Dec 2024 13:11:10 +0100 Subject: [PATCH] Configure Fedora 40 using fam --- .../tasks/configure_fedora_40.yml | 60 ++++++++----------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/roles/foreman_provisioning/tasks/configure_fedora_40.yml b/roles/foreman_provisioning/tasks/configure_fedora_40.yml index f145830ec..768b359d3 100644 --- a/roles/foreman_provisioning/tasks/configure_fedora_40.yml +++ b/roles/foreman_provisioning/tasks/configure_fedora_40.yml @@ -1,36 +1,28 @@ -- name: 'create Fedora 40' - shell: > - {{ foreman_provisioning_hammer }} os info --title "Fedora 40" || - {{ foreman_provisioning_hammer }} os create - --name Fedora --major 40 --architectures x86_64 --family 'Redhat' --media 'Fedora mirror' --partition-tables 'Kickstart default' +- name: "Find all relevant templates" # noqa: args[module] + theforeman.foreman.resource_info: + resource: provisioning_templates + search: name ~ "Kickstart default" or name = "Linux host_init_config default" + register: result -- name: 'find Fedora 40' - shell: > - {{ foreman_provisioning_hammer }} --output json os info --name "Fedora 40" || - {{ foreman_provisioning_hammer }} --output json os info --title "Fedora 40" - register: foreman_provisioning_fedora40_json - ignore_errors: True +- name: "Ensure Fedora 40" # noqa: args[module] + theforeman.foreman.operatingsystem: + name: Fedora + family: Redhat + major: 40 + architectures: + - x86_64 + media: + - Fedora mirror + provisioning_templates: "{{ result.resources | map(attribute='name') }}" + ptables: + - Kickstart default + state: present + password_hash: "SHA256" -- name: 'get Fedora 40 info' - set_fact: - foreman_provisioning_fedora40: "{{ foreman_provisioning_fedora40_json.stdout|from_json }}" - -- name: 'find kickstart templates' - shell: > - {{ foreman_provisioning_hammer }} --output=json template list - --search 'name ~ "Kickstart default"' - register: kickstart_templates_json - -- name: 'set kickstart templates' - set_fact: - kickstart_templates: "{{ kickstart_templates_json.stdout|from_json }}" - -- name: 'associate kickstart templates to Fedora 40' - shell: > - {{ foreman_provisioning_hammer }} template add-operatingsystem --id {{ item.Id }} --operatingsystem 'Fedora 40' - with_items: "{{ kickstart_templates }}" - -- name: 'set default templates for Fedora 40' - shell: > - {{ foreman_provisioning_hammer }} os set-default-template --id {{ foreman_provisioning_fedora40.Id }} --provisioning-template-id {{ item.Id }} - with_items: "{{ kickstart_templates }}" +- name: "Set default template for Fedora 40" # noqa: args[module] + theforeman.foreman.os_default_template: + operatingsystem: "Fedora 40" + template_kind: "{{ item.template_kind_name }}" + provisioning_template: "{{ item.name }}" + state: present + loop: "{{ result.resources | sort(attribute='name') | unique(attribute='template_kind_name') }}"