Skip to content

Commit

Permalink
Configure Fedora 40 using fam
Browse files Browse the repository at this point in the history
  • Loading branch information
adamruzicka committed Dec 3, 2024
1 parent 0cd5277 commit 6a33c85
Showing 1 changed file with 26 additions and 34 deletions.
60 changes: 26 additions & 34 deletions roles/foreman_provisioning/tasks/configure_fedora_40.yml
Original file line number Diff line number Diff line change
@@ -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') }}"

0 comments on commit 6a33c85

Please sign in to comment.