-
Notifications
You must be signed in to change notification settings - Fork 204
Fix foreman_provisioning role #1866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 11 commits
57b6842
66ad55a
d38aefa
9dec420
4a3404b
ce85689
62cc747
0cd5277
6a33c85
578f05d
d0c74e9
605a7cf
954d5c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,30 @@ | ||||||
| - 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: "Ensure Debian 12.7" # noqa: args[module] | ||||||
| theforeman.foreman.operatingsystem: | ||||||
| name: Debian | ||||||
| family: Debian | ||||||
| major: 12 | ||||||
| minor: 7 | ||||||
| release_name: bookworm | ||||||
| architectures: | ||||||
| - x86_64 | ||||||
| media: | ||||||
| - Debian mirror | ||||||
| provisioning_templates: "{{ result.resources | map(attribute='name') }}" | ||||||
| ptables: | ||||||
| - Preseed default | ||||||
| state: present | ||||||
| password_hash: "SHA256" | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like CentOS
Suggested change
|
||||||
|
|
||||||
| - name: "Set default template for Debian 12.7" # noqa: args[module] | ||||||
| theforeman.foreman.os_default_template: | ||||||
| operatingsystem: "Debian 12.7" | ||||||
| template_kind: "{{ item.template_kind_name }}" | ||||||
| provisioning_template: "{{ item.name }}" | ||||||
| state: present | ||||||
| loop: "{{ result.resources | sort(attribute='name') | unique(attribute='template_kind_name') }}" | ||||||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,28 @@ | ||||||
| - 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: "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" | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| - 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') }}" | ||||||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| - 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: "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: "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') }}" | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,19 +2,20 @@ | |
| - name: 'Setup CentOS 9 provisioning' | ||
| import_tasks: configure_centos_9.yml | ||
|
|
||
| - name: 'Setup Fedora 27 provisioning' | ||
| import_tasks: configure_fedora_27.yml | ||
| - name: 'Setup Fedora 40 provisioning' | ||
| import_tasks: configure_fedora_40.yml | ||
|
|
||
| - name: 'Setup Debian 9.3 provisioning' | ||
| import_tasks: configure_debian_9_3.yml | ||
| - name: 'Setup Debian 12.7 provisioning' | ||
| import_tasks: configure_debian_12_7.yml | ||
|
|
||
| - name: 'Setup Ubuntu 17.10 provisioning' | ||
| import_tasks: configure_ubuntu_17_10.yml | ||
| - name: 'Setup Ubuntu 24.04 provisioning' | ||
| import_tasks: configure_ubuntu_24_04.yml | ||
|
|
||
| # TODO verify - should not be needed, DNS should work just fine | ||
| - name: 'set unattended_url' | ||
| shell: > | ||
| {{ foreman_provisioning_hammer }} settings set --name unattended_url --value 'http://{{ foreman_provisioning_ip_address }}' | ||
| theforeman.foreman.setting: | ||
| name: unattended_url | ||
| value: "http://{{ foreman_provisioning_ip_address }}" | ||
|
|
||
| - name: 'find hostgroup Base' | ||
| shell: > | ||
|
|
@@ -37,30 +38,30 @@ | |
| --name 'Base' | ||
| --architecture x86_64 | ||
| --domain {{ foreman_provisioning_domain }} | ||
| --environment production | ||
| --puppet-environment production | ||
| --puppet-ca-proxy-id {{ foreman_provisioning_smart_proxy.Id }} | ||
| --puppet-proxy-id {{ foreman_provisioning_smart_proxy.Id }} | ||
| --subnet '{{ foreman_provisioning_network }}/24' | ||
| {{ foreman_provisioning_compute_profile_option }} | ||
| {{ foreman_provisioning_compute_resource_option }} | ||
| --root-pass changeme | ||
| --root-password changeme | ||
| --pxe-loader "PXELinux BIOS" | ||
| --organization '{{ foreman_provisioning_organization }}' | ||
| {{ foreman_provisioning_hammer_taxonomy_params }} | ||
| when: foreman_provisioning_hostgroup_base.stderr.find('not found') != -1 | ||
|
|
||
| - name: 'find hostgroup CentOS 7' | ||
| - name: 'find hostgroup CentOS 9' | ||
| shell: > | ||
| {{ foreman_provisioning_hammer }} hostgroup info --name 'CentOS 7 Mirror' | ||
| {{ foreman_provisioning_hammer }} hostgroup info --name 'CentOS 9 Mirror' | ||
| register: foreman_provisioning_hostgroup_centos_mirror | ||
| ignore_errors: True | ||
|
|
||
| - name: 'create hostgroup CentOS 7 Mirror' | ||
| - name: 'create hostgroup CentOS 9 Mirror' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we replace the hammer logic with FAM here too? theforeman.foreman.hostgroup should be way easier to maintain: - name: "Ensure CentOS 9 Mirror hostgroup"
theforeman.foreman.hostgroup:
name: 'CentOS 9 Mirror'
operatingsystem: 'CentOS_Stream 9'
medium: '{{ foreman_provisioning_centos_medium_name }}'
ptable: 'Kickstart default'
parent: 'Base'Not sure how to convert And the same for the |
||
| shell: > | ||
| {{ foreman_provisioning_hammer }} hostgroup create | ||
| --name 'CentOS 7 Mirror' | ||
| --operatingsystem 'CentOS 7' | ||
| --medium '{{ centos_medium_name }}' | ||
| --name 'CentOS 9 Mirror' | ||
| --operatingsystem 'CentOS_Stream 9' | ||
| --medium 'CentOS Stream 9 mirror' | ||
|
||
| --partition-table 'Kickstart default' | ||
| --parent 'Base' | ||
| {{ foreman_provisioning_hammer_taxonomy_params }} | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In #1888 I had a go at rewriting much of this file to also use FAM. I'd appreciate if you could take a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this work as a replacement for the Hammer stuff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost, if I'm reading it correctly, the current hammer-based implementation associates all templates which start with "Preseed default" with the os. This one associates just the ones which are explicitly listed? Unless I'm missing something, fam doesn't really give us options to list with search and the reuse the result so I'd have to fallback to a mix of hammer and this to associate all the relevant templates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've also often wondered how we can make this better. We already know the operating systems that are compatible (since the template lists them) so should Foreman have some option to automatically associate all compatible options? And by that I mean server side, without having to specify them.
@evgeni any thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FAM can do searches (I can drop you an example if you want), but yeah, automatic in Foreman would be cooler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you'd indulge me
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Untested:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But now I wonder, how should an OS have multiple default templates of the same kind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, not of the same kind. The search should return several templates of different kinds. It would be nice to not have to do this https://github.com/theforeman/forklift/pull/1885/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right! Updated the snippet above to do that, can you try it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mhh, but it'd still be a problem for
PXE*ones, as there are two of them? 🤔