Skip to content

Commit

Permalink
Configure Ubuntu 24.04 using fam
Browse files Browse the repository at this point in the history
  • Loading branch information
adamruzicka committed Dec 3, 2024
1 parent 6a33c85 commit 578f05d
Showing 1 changed file with 27 additions and 34 deletions.
61 changes: 27 additions & 34 deletions roles/foreman_provisioning/tasks/configure_ubuntu_24_04.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,29 @@
- name: 'create Ubuntu 24.04'
shell: >
{{ foreman_provisioning_hammer }} os info --title "Ubuntu 24.04" ||
{{ foreman_provisioning_hammer }} os create
--name Ubuntu --major 24 --minor 04 --release-name 'artful' --architectures x86_64 --family 'Debian' --media 'Ubuntu mirror' --partition-tables 'Preseed default'
- name: "Find all relevant templates" # noqa: args[module]
theforeman.foreman.resource_info:
resource: provisioning_templates
search: name ~ "Preseed default" or name = "Linux host_init_config default"
register: result

- name: 'find Ubuntu 24.04'
shell: >
{{ foreman_provisioning_hammer }} --output json os info --name "Ubuntu 24.04" ||
{{ foreman_provisioning_hammer }} --output json os info --title "Ubuntu 24.04"
register: foreman_provisioning_ubuntu2404_json
ignore_errors: True
- name: "Ensure Ubuntu 24.04" # noqa: args[module]
theforeman.foreman.operatingsystem:
name: Ubuntu
family: Debian
major: "24.04"
release_name: artful
architectures:
- x86_64
media:
- Ubuntu mirror
provisioning_templates: "{{ result.resources | map(attribute='name') }}"
ptables:
- Preseed default
state: present
password_hash: "SHA256"

- name: 'get Ubuntu 24.04 info'
set_fact:
foreman_provisioning_ubuntu2404: "{{ foreman_provisioning_ubuntu2404_json.stdout|from_json }}"

- name: 'find preseed templates'
shell: >
{{ foreman_provisioning_hammer }} --output=json template list
--search 'name ~ "Preseed default"'
register: preseed_templates_json

- name: 'set preseed templates'
set_fact:
preseed_templates: "{{ preseed_templates_json.stdout|from_json }}"

- name: 'associate preseed templates to Ubuntu 24.04'
shell: >
{{ foreman_provisioning_hammer }} template add-operatingsystem --id {{ item.Id }} --operatingsystem 'Ubuntu 24.04'
with_items: "{{ preseed_templates }}"

- name: 'set default templates for Ubuntu 24.04'
shell: >
{{ foreman_provisioning_hammer }} os set-default-template --id {{ foreman_provisioning_ubuntu2404.Id }} --provisioning-template-id {{ item.Id }}
with_items: "{{ preseed_templates }}"
- name: "Set default template for Ubuntu 24.04" # noqa: args[module]
theforeman.foreman.os_default_template:
operatingsystem: "Ubuntu 24.04"
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 578f05d

Please sign in to comment.